@unchainedshop/api 1.2.49 → 1.2.51
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/lib/createGraphQLServer.js +0 -3
- package/lib/createGraphQLServer.js.map +1 -1
- package/lib/loaders/index.js +5 -9
- package/lib/loaders/index.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortment.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortment.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentLink.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentLink.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/updateEnrollment.d.ts +1 -1
- package/lib/resolvers/mutations/filters/removeFilter.js +1 -1
- package/lib/resolvers/mutations/filters/removeFilter.js.map +1 -1
- package/lib/resolvers/mutations/pageView.d.ts +1 -1
- package/lib/resolvers/mutations/pageView.js +2 -2
- package/lib/resolvers/mutations/pageView.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProduct.d.ts +1 -1
- package/lib/resolvers/mutations/products/removeProduct.js +5 -8
- package/lib/resolvers/mutations/products/removeProduct.js.map +1 -1
- package/lib/resolvers/queries/products/productCatalogPrices.js +0 -1
- package/lib/resolvers/queries/products/productCatalogPrices.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-filter-types.js +0 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-link-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-link-types.js +0 -2
- package/lib/resolvers/type/assortment/assortment-link-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-media-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-media-types.js +2 -0
- package/lib/resolvers/type/assortment/assortment-media-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-path-link-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-path-link-types.js +1 -0
- package/lib/resolvers/type/assortment/assortment-path-link-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-product-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-product-types.js +0 -2
- package/lib/resolvers/type/assortment/assortment-product-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-types.js +8 -4
- package/lib/resolvers/type/assortment/assortment-types.js.map +1 -1
- package/lib/resolvers/type/bookmark-types.d.ts +1 -1
- package/lib/resolvers/type/bookmark-types.js +0 -1
- package/lib/resolvers/type/bookmark-types.js.map +1 -1
- package/lib/resolvers/type/country-types.d.ts +1 -1
- package/lib/resolvers/type/delivery-provider-types.d.ts +1 -1
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-payment-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-period-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js +0 -1
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-types.d.ts +2 -2
- package/lib/resolvers/type/event-types.d.ts +1 -1
- package/lib/resolvers/type/filter/filter-option-types.d.ts +2 -2
- package/lib/resolvers/type/filter/filter-types.d.ts +2 -2
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.js +0 -3
- package/lib/resolvers/type/order/order-item-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-card-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-generic-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-invoice-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-types.d.ts +1 -1
- package/lib/resolvers/type/price-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-assortment-path-types.js +1 -0
- package/lib/resolvers/type/product/product-assortment-path-types.js.map +1 -1
- package/lib/resolvers/type/product/product-bundle-item-types.js +0 -1
- package/lib/resolvers/type/product/product-bundle-item-types.js.map +1 -1
- package/lib/resolvers/type/product/product-discount.d.ts +1 -1
- package/lib/resolvers/type/product/product-media-types.js +2 -0
- package/lib/resolvers/type/product/product-media-types.js.map +1 -1
- package/lib/resolvers/type/product/product-review-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-review-types.js +0 -1
- package/lib/resolvers/type/product/product-review-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js +0 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js.map +1 -1
- package/lib/resolvers/type/quotation-types.d.ts +2 -2
- package/lib/resolvers/type/quotation-types.js +0 -1
- package/lib/resolvers/type/quotation-types.js.map +1 -1
- package/lib/resolvers/type/shop-types.d.ts +1 -1
- package/lib/resolvers/type/user-types.d.ts +1 -1
- package/lib/resolvers/type/work-types.d.ts +1 -1
- package/package.json +9 -9
- package/src/createGraphQLServer.ts +0 -4
- package/src/loaders/index.ts +27 -35
- package/src/resolvers/mutations/assortments/removeAssortment.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentFilter.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentLink.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentProduct.ts +1 -1
- package/src/resolvers/mutations/filters/removeFilter.ts +1 -1
- package/src/resolvers/mutations/pageView.js +2 -2
- package/src/resolvers/mutations/products/removeProduct.ts +6 -8
- package/src/resolvers/queries/products/productCatalogPrices.ts +0 -1
- package/src/resolvers/type/assortment/assortment-filter-types.ts +0 -1
- package/src/resolvers/type/assortment/assortment-link-types.ts +0 -2
- package/src/resolvers/type/assortment/assortment-media-types.ts +2 -0
- package/src/resolvers/type/assortment/assortment-path-link-types.ts +1 -0
- package/src/resolvers/type/assortment/assortment-product-types.ts +0 -2
- package/src/resolvers/type/assortment/assortment-types.ts +9 -4
- package/src/resolvers/type/bookmark-types.ts +0 -1
- package/src/resolvers/type/enrollment/enrollment-plan-tyes.ts +0 -1
- package/src/resolvers/type/order/order-item-types.ts +0 -3
- package/src/resolvers/type/product/product-assortment-path-types.ts +1 -0
- package/src/resolvers/type/product/product-bundle-item-types.ts +0 -1
- package/src/resolvers/type/product/product-media-types.ts +2 -0
- package/src/resolvers/type/product/product-review-types.ts +0 -1
- package/src/resolvers/type/product/product-variation-assignment-types.ts +0 -1
- package/src/resolvers/type/quotation-types.ts +0 -1
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { Context, Root } from '@unchainedshop/types/api';
|
|
3
|
-
import { ProductNotFoundError,
|
|
3
|
+
import { ProductNotFoundError, InvalidIdError } from '../../../errors';
|
|
4
4
|
|
|
5
5
|
export default async function removeProduct(
|
|
6
6
|
root: Root,
|
|
7
7
|
{ productId }: { productId: string },
|
|
8
|
-
|
|
8
|
+
context: Context,
|
|
9
9
|
) {
|
|
10
|
+
const { modules, services, userId } = context;
|
|
10
11
|
log(`mutation removeProduct ${productId}`, { userId });
|
|
11
12
|
|
|
12
13
|
if (!productId) throw new InvalidIdError({ productId });
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
if (!(await modules.products.productExists({ productId })))
|
|
16
|
+
throw new ProductNotFoundError({ productId });
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await modules.assortments.products.delete(productId as string, {}, userId);
|
|
20
|
-
await modules.products.delete(productId, userId);
|
|
18
|
+
await services.products.removeProduct({ productId, userId: context.userId }, context);
|
|
21
19
|
|
|
22
20
|
return modules.products.findProduct({ productId });
|
|
23
21
|
}
|
|
@@ -13,7 +13,6 @@ export const AssortmentFilter: AssortmentFilterHelperTypes = {
|
|
|
13
13
|
assortment: async (obj, _, { loaders }) => {
|
|
14
14
|
const assortment = await loaders.assortmentLoader.load({
|
|
15
15
|
assortmentId: obj.assortmentId,
|
|
16
|
-
includeInactive: true,
|
|
17
16
|
});
|
|
18
17
|
return assortment;
|
|
19
18
|
},
|
|
@@ -12,7 +12,6 @@ export const AssortmentLink: AssortmentLinkHelperTypes = {
|
|
|
12
12
|
child: async (obj, _, { loaders }) => {
|
|
13
13
|
const assortment = await loaders.assortmentLoader.load({
|
|
14
14
|
assortmentId: obj.childAssortmentId,
|
|
15
|
-
includeInactive: true,
|
|
16
15
|
});
|
|
17
16
|
return assortment;
|
|
18
17
|
},
|
|
@@ -20,7 +19,6 @@ export const AssortmentLink: AssortmentLinkHelperTypes = {
|
|
|
20
19
|
parent: async (obj, _, { loaders }) => {
|
|
21
20
|
const assortment = await loaders.assortmentLoader.load({
|
|
22
21
|
assortmentId: obj.parentAssortmentId,
|
|
23
|
-
includeInactive: true,
|
|
24
22
|
});
|
|
25
23
|
return assortment;
|
|
26
24
|
},
|
|
@@ -13,11 +13,13 @@ export interface AssortmentMediaHelperTypes {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const AssortmentMedia: AssortmentMediaHelperTypes = {
|
|
16
|
+
// TODO: Loader for assortment media texts!
|
|
16
17
|
texts: (obj, { forceLocale }, { modules, localeContext }) =>
|
|
17
18
|
modules.assortments.media.texts.findLocalizedMediaText({
|
|
18
19
|
assortmentMediaId: obj._id,
|
|
19
20
|
locale: forceLocale || localeContext.normalized,
|
|
20
21
|
}),
|
|
21
22
|
|
|
23
|
+
// TODO: Loader for files!
|
|
22
24
|
file: (obj, _, { modules }) => modules.files.findFile({ fileId: obj.mediaId }),
|
|
23
25
|
};
|
|
@@ -17,6 +17,7 @@ export interface AssortmentPathLinkHelperTypes {
|
|
|
17
17
|
|
|
18
18
|
export const AssortmentPathLink: AssortmentPathLinkHelperTypes = {
|
|
19
19
|
link: async ({ assortmentId, childAssortmentId }, _, { modules }) => {
|
|
20
|
+
// TODO: Loader
|
|
20
21
|
return modules.assortments.links.findLink({
|
|
21
22
|
parentAssortmentId: assortmentId,
|
|
22
23
|
childAssortmentId,
|
|
@@ -16,7 +16,6 @@ export const AssortmentProduct: AssortmentProductHelperTypes = {
|
|
|
16
16
|
assortment: async (obj, _, { loaders }) => {
|
|
17
17
|
const assortment = await loaders.assortmentLoader.load({
|
|
18
18
|
assortmentId: obj.assortmentId,
|
|
19
|
-
includeInactive: true,
|
|
20
19
|
});
|
|
21
20
|
return assortment;
|
|
22
21
|
},
|
|
@@ -24,7 +23,6 @@ export const AssortmentProduct: AssortmentProductHelperTypes = {
|
|
|
24
23
|
product: async (obj, _, { loaders }) => {
|
|
25
24
|
const product = await loaders.productLoader.load({
|
|
26
25
|
productId: obj.productId,
|
|
27
|
-
includeDrafts: true,
|
|
28
26
|
});
|
|
29
27
|
return product;
|
|
30
28
|
},
|
|
@@ -62,10 +62,11 @@ export const Assortment: AssortmentHelperTypes = {
|
|
|
62
62
|
},
|
|
63
63
|
|
|
64
64
|
childrenCount: async (assortment, { includeInactive = false }, { modules }) => {
|
|
65
|
-
|
|
65
|
+
// TODO: Loader
|
|
66
|
+
const assortmentChildLinks = await modules.assortments.links.findLinks({
|
|
66
67
|
parentAssortmentId: assortment._id,
|
|
67
68
|
});
|
|
68
|
-
const assortmentIds =
|
|
69
|
+
const assortmentIds = assortmentChildLinks.map(({ childAssortmentId }) => childAssortmentId);
|
|
69
70
|
|
|
70
71
|
const selector: Query = {
|
|
71
72
|
assortmentIds,
|
|
@@ -77,6 +78,7 @@ export const Assortment: AssortmentHelperTypes = {
|
|
|
77
78
|
},
|
|
78
79
|
|
|
79
80
|
filterAssignments: async (obj, _, { modules }) => {
|
|
81
|
+
// TODO: Loader & move default sort to module
|
|
80
82
|
return modules.assortments.filters.findFilters(
|
|
81
83
|
{
|
|
82
84
|
assortmentId: obj._id,
|
|
@@ -87,7 +89,8 @@ export const Assortment: AssortmentHelperTypes = {
|
|
|
87
89
|
);
|
|
88
90
|
},
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
async linkedAssortments(obj, _, { modules }) {
|
|
93
|
+
// TODO: Loader
|
|
91
94
|
return modules.assortments.links.findLinks({
|
|
92
95
|
assortmentId: obj._id,
|
|
93
96
|
});
|
|
@@ -100,7 +103,8 @@ export const Assortment: AssortmentHelperTypes = {
|
|
|
100
103
|
});
|
|
101
104
|
},
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
async productAssignments(obj, _, { modules }) {
|
|
107
|
+
// TODO: Loader & move default sort to core module
|
|
104
108
|
return modules.assortments.products.findProducts(
|
|
105
109
|
{
|
|
106
110
|
assortmentId: obj._id,
|
|
@@ -124,6 +128,7 @@ export const Assortment: AssortmentHelperTypes = {
|
|
|
124
128
|
assortmentId: obj._id,
|
|
125
129
|
ignoreChildAssortments: query.ignoreChildAssortments,
|
|
126
130
|
});
|
|
131
|
+
|
|
127
132
|
const filterIds = await context.modules.assortments.filters.findFilterIds({
|
|
128
133
|
assortmentId: obj._id,
|
|
129
134
|
});
|
|
@@ -70,7 +70,6 @@ export const OrderItem: OrderItemHelperTypes = {
|
|
|
70
70
|
});
|
|
71
71
|
const product = await loaders.productLoader.load({
|
|
72
72
|
productId: obj.productId,
|
|
73
|
-
includeDrafts: true,
|
|
74
73
|
});
|
|
75
74
|
|
|
76
75
|
return Promise.all(
|
|
@@ -103,7 +102,6 @@ export const OrderItem: OrderItemHelperTypes = {
|
|
|
103
102
|
originalProduct: async (obj, _, { loaders }) => {
|
|
104
103
|
const product = await loaders.productLoader.load({
|
|
105
104
|
productId: obj.originalProductId,
|
|
106
|
-
includeDrafts: true,
|
|
107
105
|
});
|
|
108
106
|
return product;
|
|
109
107
|
},
|
|
@@ -111,7 +109,6 @@ export const OrderItem: OrderItemHelperTypes = {
|
|
|
111
109
|
product: async (obj, _, { loaders }) => {
|
|
112
110
|
const product = await loaders.productLoader.load({
|
|
113
111
|
productId: obj.productId,
|
|
114
|
-
includeDrafts: true,
|
|
115
112
|
});
|
|
116
113
|
return product;
|
|
117
114
|
},
|
|
@@ -2,6 +2,7 @@ import { ProductAssortmentPathHelperTypes } from '@unchainedshop/types/products'
|
|
|
2
2
|
|
|
3
3
|
export const ProductAssortmentPath: ProductAssortmentPathHelperTypes = {
|
|
4
4
|
assortmentProduct: async ({ _id }, _, { modules }) => {
|
|
5
|
+
// TODO: Loader
|
|
5
6
|
return modules.assortments.products.findProduct({
|
|
6
7
|
assortmentProductId: _id,
|
|
7
8
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProductMediaHelperTypes } from '@unchainedshop/types/products.media';
|
|
2
2
|
|
|
3
3
|
export const ProductMedia: ProductMediaHelperTypes = {
|
|
4
|
+
// TODO: Loader for product media texts!
|
|
4
5
|
texts: async (obj, { forceLocale }, { modules, localeContext }) => {
|
|
5
6
|
return modules.products.media.texts.findLocalizedMediaText({
|
|
6
7
|
productMediaId: obj._id,
|
|
@@ -9,6 +10,7 @@ export const ProductMedia: ProductMediaHelperTypes = {
|
|
|
9
10
|
},
|
|
10
11
|
|
|
11
12
|
file: async (obj, _, { modules }) => {
|
|
13
|
+
// TODO: Loader
|
|
12
14
|
return modules.files.findFile({ fileId: obj.mediaId });
|
|
13
15
|
},
|
|
14
16
|
};
|
|
@@ -14,7 +14,6 @@ export const ProductVariationAssignment: ProductVariationAssignmentHelperTypes =
|
|
|
14
14
|
product: async ({ assignment }, _, { loaders }) => {
|
|
15
15
|
const product = await loaders.productLoader.load({
|
|
16
16
|
productId: assignment.productId,
|
|
17
|
-
includeDrafts: true,
|
|
18
17
|
});
|
|
19
18
|
return product;
|
|
20
19
|
},
|