@unchainedshop/api 2.0.0-beta6 → 2.0.0-beta8
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/api-index.d.ts +4 -7
- package/lib/api-index.js +24 -14
- package/lib/api-index.js.map +1 -1
- package/lib/context.d.ts +0 -1
- package/lib/context.js +0 -11
- package/lib/context.js.map +1 -1
- package/lib/createGraphQLServer.d.ts +2 -2
- package/lib/createGraphQLServer.js +12 -53
- package/lib/createGraphQLServer.js.map +1 -1
- package/lib/errors.js +8 -3
- package/lib/errors.js.map +1 -1
- package/lib/express/createApolloMiddleware.d.ts +4 -0
- package/lib/express/createApolloMiddleware.js +34 -0
- package/lib/express/createApolloMiddleware.js.map +1 -0
- package/lib/express/createBulkImportMiddleware.d.ts +2 -0
- package/lib/express/createBulkImportMiddleware.js +79 -0
- package/lib/express/createBulkImportMiddleware.js.map +1 -0
- package/lib/express/createERCMetadataMiddleware.d.ts +3 -0
- package/lib/express/createERCMetadataMiddleware.js +56 -0
- package/lib/express/createERCMetadataMiddleware.js.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts +6 -0
- package/lib/express/createSingleSignOnMiddleware.js +71 -0
- package/lib/express/createSingleSignOnMiddleware.js.map +1 -0
- package/lib/express/index.d.ts +6 -0
- package/lib/express/index.js +27 -0
- package/lib/express/index.js.map +1 -0
- package/lib/loaders/index.js +50 -0
- package/lib/loaders/index.js.map +1 -1
- package/lib/resolvers/index.js +1 -1
- package/lib/resolvers/index.js.map +1 -1
- package/lib/resolvers/mutations/accounts/changePassword.d.ts +0 -2
- package/lib/resolvers/mutations/accounts/changePassword.js +2 -2
- package/lib/resolvers/mutations/accounts/changePassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/createUser.js +2 -2
- package/lib/resolvers/mutations/accounts/createUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/enrollUser.js +1 -1
- package/lib/resolvers/mutations/accounts/enrollUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.js +3 -3
- package/lib/resolvers/mutations/accounts/loginWithPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/setPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/setPassword.js +1 -1
- package/lib/resolvers/mutations/accounts/setPassword.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/filters/updateFilter.js +2 -1
- package/lib/resolvers/mutations/filters/updateFilter.js.map +1 -1
- package/lib/resolvers/mutations/index.d.ts +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/product.js +1 -1
- package/lib/resolvers/queries/products/productCatalogPrices.d.ts +1 -1
- package/lib/resolvers/queries/products/productCatalogPrices.js +5 -2
- package/lib/resolvers/queries/products/productCatalogPrices.js.map +1 -1
- package/lib/resolvers/queries/products/products.js +1 -1
- package/lib/resolvers/queries/products/products.js.map +1 -1
- package/lib/resolvers/scalars/LowerCaseString.d.ts +1 -1
- package/lib/resolvers/scalars/index.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-filter-types.js +13 -6
- 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 +14 -6
- 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-path-link-types.d.ts +1 -4
- package/lib/resolvers/type/assortment/assortment-path-link-types.js +0 -7
- 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 +14 -6
- 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/bookmark-types.d.ts +1 -1
- package/lib/resolvers/type/bookmark-types.js +6 -2
- 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 +6 -2
- 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 +13 -6
- 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-bundle-item-types.js +4 -2
- 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-review-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-review-types.js +6 -2
- package/lib/resolvers/type/product/product-review-types.js.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.js +1 -0
- package/lib/resolvers/type/product/product-tokenized-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js +4 -2
- 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 +7 -3
- package/lib/resolvers/type/quotation-types.js.map +1 -1
- package/lib/resolvers/type/shop-types.d.ts +1 -1
- package/lib/resolvers/type/token-types.d.ts +1 -1
- package/lib/resolvers/type/user-types.d.ts +1 -3
- package/lib/resolvers/type/user-types.js +0 -12
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +1 -1
- package/lib/resolvers/type/work-types.d.ts +1 -1
- package/lib/schema/{types/log.d.ts → directives.d.ts} +0 -0
- package/lib/schema/directives.js +15 -0
- package/lib/schema/directives.js.map +1 -0
- package/lib/schema/index.js +2 -1
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/inputTypes.js +0 -15
- package/lib/schema/inputTypes.js.map +1 -1
- package/lib/schema/mutation.js +4 -23
- package/lib/schema/mutation.js.map +1 -1
- package/lib/schema/query.js +28 -10
- package/lib/schema/query.js.map +1 -1
- package/lib/schema/types/assortment.js +9 -10
- package/lib/schema/types/assortment.js.map +1 -1
- package/lib/schema/types/color.js +1 -1
- package/lib/schema/types/country.js +1 -1
- package/lib/schema/types/currency.js +1 -1
- package/lib/schema/types/delivery.js +3 -2
- package/lib/schema/types/delivery.js.map +1 -1
- package/lib/schema/types/dimensions.js +1 -1
- package/lib/schema/types/discount.js +1 -1
- package/lib/schema/types/dispatch.js +1 -0
- package/lib/schema/types/dispatch.js.map +1 -1
- package/lib/schema/types/filter.js +5 -8
- package/lib/schema/types/filter.js.map +1 -1
- package/lib/schema/types/geo-position.js +1 -1
- package/lib/schema/types/language.js +1 -1
- package/lib/schema/types/media.js +1 -1
- package/lib/schema/types/payment.js +3 -3
- package/lib/schema/types/price.js +2 -2
- package/lib/schema/types/product/bundle-product.js +2 -3
- package/lib/schema/types/product/bundle-product.js.map +1 -1
- package/lib/schema/types/product/configurable-product.js +7 -7
- package/lib/schema/types/product/plan-product.js +4 -3
- package/lib/schema/types/product/plan-product.js.map +1 -1
- package/lib/schema/types/product/product.js +11 -11
- package/lib/schema/types/product/simple-product.js +5 -4
- package/lib/schema/types/product/simple-product.js.map +1 -1
- package/lib/schema/types/product/tokenized-product.js +6 -3
- package/lib/schema/types/product/tokenized-product.js.map +1 -1
- package/lib/schema/types/search.js +3 -8
- package/lib/schema/types/search.js.map +1 -1
- package/lib/schema/types/shop.js +2 -2
- package/lib/schema/types/stock.js +1 -0
- package/lib/schema/types/stock.js.map +1 -1
- package/lib/schema/types/types.js +1 -1
- package/lib/schema/types/user.js +1 -3
- package/lib/schema/types/user.js.map +1 -1
- package/lib/schema/types/warehousing.js +3 -3
- package/package.json +31 -19
- package/src/api-index.ts +25 -29
- package/src/context.ts +0 -19
- package/src/createGraphQLServer.ts +11 -56
- package/src/errors.ts +8 -3
- package/src/express/createApolloMiddleware.ts +40 -0
- package/src/express/createBulkImportMiddleware.ts +90 -0
- package/src/express/createERCMetadataMiddleware.ts +72 -0
- package/src/express/createSingleSignOnMiddleware.ts +83 -0
- package/src/express/index.ts +48 -0
- package/src/loaders/index.ts +63 -3
- package/src/resolvers/index.ts +1 -1
- package/src/resolvers/mutations/accounts/changePassword.ts +2 -4
- package/src/resolvers/mutations/accounts/createUser.ts +2 -2
- package/src/resolvers/mutations/accounts/enrollUser.ts +1 -1
- package/src/resolvers/mutations/accounts/loginWithPassword.ts +3 -4
- package/src/resolvers/mutations/accounts/resetPassword.ts +2 -2
- package/src/resolvers/mutations/accounts/setPassword.ts +2 -2
- 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/filters/updateFilter.ts +3 -1
- package/src/resolvers/mutations/pageView.ts +2 -2
- package/src/resolvers/mutations/products/removeProduct.ts +6 -8
- package/src/resolvers/queries/products/product.ts +1 -1
- package/src/resolvers/queries/products/productCatalogPrices.ts +5 -2
- package/src/resolvers/queries/products/products.ts +1 -1
- package/src/resolvers/type/assortment/assortment-filter-types.ts +11 -6
- package/src/resolvers/type/assortment/assortment-link-types.ts +12 -6
- package/src/resolvers/type/assortment/assortment-path-link-types.ts +0 -11
- package/src/resolvers/type/assortment/assortment-product-types.ts +12 -6
- package/src/resolvers/type/bookmark-types.ts +7 -2
- package/src/resolvers/type/enrollment/enrollment-plan-tyes.ts +6 -2
- package/src/resolvers/type/order/order-item-types.ts +13 -6
- package/src/resolvers/type/product/product-bundle-item-types.ts +4 -2
- package/src/resolvers/type/product/product-review-types.ts +6 -2
- package/src/resolvers/type/product/product-tokenized-types.ts +1 -0
- package/src/resolvers/type/product/product-variation-assignment-types.ts +4 -2
- package/src/resolvers/type/quotation-types.ts +6 -3
- package/src/resolvers/type/user-types.ts +0 -15
- package/src/schema/directives.js +14 -0
- package/src/schema/index.js +2 -1
- package/src/schema/inputTypes.js +0 -15
- package/src/schema/mutation.js +4 -23
- package/src/schema/query.js +28 -10
- package/src/schema/types/assortment.js +9 -10
- package/src/schema/types/color.js +1 -1
- package/src/schema/types/country.js +1 -1
- package/src/schema/types/currency.js +1 -1
- package/src/schema/types/delivery.js +3 -2
- package/src/schema/types/dimensions.js +1 -1
- package/src/schema/types/discount.js +1 -1
- package/src/schema/types/dispatch.js +1 -0
- package/src/schema/types/filter.js +5 -8
- package/src/schema/types/geo-position.js +1 -1
- package/src/schema/types/language.js +1 -1
- package/src/schema/types/media.js +1 -1
- package/src/schema/types/payment.js +3 -3
- package/src/schema/types/price.js +2 -2
- package/src/schema/types/product/bundle-product.js +2 -3
- package/src/schema/types/product/configurable-product.js +7 -7
- package/src/schema/types/product/plan-product.js +4 -3
- package/src/schema/types/product/product.js +11 -11
- package/src/schema/types/product/simple-product.js +5 -4
- package/src/schema/types/product/tokenized-product.js +6 -3
- package/src/schema/types/search.js +3 -8
- package/src/schema/types/shop.js +2 -2
- package/src/schema/types/stock.js +1 -0
- package/src/schema/types/types.js +1 -1
- package/src/schema/types/user.js +1 -3
- package/src/schema/types/warehousing.js +3 -3
- package/tsconfig.json +1 -0
- package/lib/createBulkImportServer.d.ts +0 -2
- package/lib/createBulkImportServer.js +0 -81
- package/lib/createBulkImportServer.js.map +0 -1
- package/lib/createERCMetadataServer.d.ts +0 -2
- package/lib/createERCMetadataServer.js +0 -59
- package/lib/createERCMetadataServer.js.map +0 -1
- package/lib/schema/types/log.js +0 -16
- package/lib/schema/types/log.js.map +0 -1
- package/src/createBulkImportServer.ts +0 -95
- package/src/createERCMetadataServer.ts +0 -78
- package/src/schema/types/log.js +0 -15
|
@@ -4,19 +4,17 @@ import { Context, Root } from '@unchainedshop/types/api';
|
|
|
4
4
|
export default async function changePassword(
|
|
5
5
|
root: Root,
|
|
6
6
|
params: {
|
|
7
|
-
oldPassword?: string;
|
|
8
7
|
oldPlainPassword?: string;
|
|
9
|
-
newPassword?: string;
|
|
10
8
|
newPlainPassword?: string;
|
|
11
9
|
},
|
|
12
10
|
{ modules, userId }: Context,
|
|
13
11
|
) {
|
|
14
12
|
log('mutation changePassword', { userId });
|
|
15
13
|
|
|
16
|
-
if (!params.
|
|
14
|
+
if (!params.newPlainPassword) {
|
|
17
15
|
throw new Error('New password is required');
|
|
18
16
|
}
|
|
19
|
-
if (!params.
|
|
17
|
+
if (!params.oldPlainPassword) {
|
|
20
18
|
throw new Error('Old password is required');
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -8,12 +8,12 @@ export default async function createUser(root: Root, params: UserData, context:
|
|
|
8
8
|
|
|
9
9
|
log('mutation createUser', { email: params.email, username: params.username, userId });
|
|
10
10
|
|
|
11
|
-
if (!params.
|
|
11
|
+
if (!params.plainPassword && !params.webAuthnPublicKeyCredentials) {
|
|
12
12
|
throw new Error('Password or Public Key is required');
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const mappedUser = { ...params };
|
|
16
|
-
if (
|
|
16
|
+
if (mappedUser.plainPassword) {
|
|
17
17
|
mappedUser.password = hashPassword(mappedUser.plainPassword);
|
|
18
18
|
}
|
|
19
19
|
delete mappedUser.plainPassword;
|
|
@@ -10,7 +10,7 @@ export default async function enrollUser(root: Root, params: UserData, context:
|
|
|
10
10
|
|
|
11
11
|
const mappedUserData = params;
|
|
12
12
|
mappedUserData.initialPassword = true;
|
|
13
|
-
if (
|
|
13
|
+
if (mappedUserData.plainPassword) {
|
|
14
14
|
mappedUserData.password = hashPassword(mappedUserData.plainPassword);
|
|
15
15
|
}
|
|
16
16
|
delete mappedUserData.plainPassword;
|
|
@@ -7,24 +7,23 @@ export default async function loginWithPassword(
|
|
|
7
7
|
params: {
|
|
8
8
|
username?: string;
|
|
9
9
|
email?: string;
|
|
10
|
-
password?: string;
|
|
11
10
|
plainPassword?: string;
|
|
12
11
|
totpCode?: string;
|
|
13
12
|
},
|
|
14
13
|
context: Context,
|
|
15
14
|
) {
|
|
16
15
|
const { modules } = context;
|
|
17
|
-
const { username, email,
|
|
16
|
+
const { username, email, plainPassword, totpCode } = params;
|
|
18
17
|
|
|
19
18
|
log('mutation loginWithPassword', { username, email });
|
|
20
19
|
|
|
21
|
-
if (!
|
|
20
|
+
if (!plainPassword) {
|
|
22
21
|
throw new Error('Password is required');
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
const mappedUserLoginParams = {
|
|
26
25
|
user: email ? { email } : { username },
|
|
27
|
-
password:
|
|
26
|
+
password: hashPassword(plainPassword),
|
|
28
27
|
code: totpCode,
|
|
29
28
|
};
|
|
30
29
|
|
|
@@ -3,14 +3,14 @@ import { Context, Root } from '@unchainedshop/types/api';
|
|
|
3
3
|
|
|
4
4
|
export default async function resetPassword(
|
|
5
5
|
root: Root,
|
|
6
|
-
params: {
|
|
6
|
+
params: { newPlainPassword?: string; token: string },
|
|
7
7
|
context: Context,
|
|
8
8
|
) {
|
|
9
9
|
const { modules, userId } = context;
|
|
10
10
|
|
|
11
11
|
log('mutation resetPassword', { userId });
|
|
12
12
|
|
|
13
|
-
if (!params.
|
|
13
|
+
if (!params.newPlainPassword) {
|
|
14
14
|
throw new Error('Password is required');
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -4,7 +4,7 @@ import { UserNotFoundError, InvalidIdError } from '../../../errors';
|
|
|
4
4
|
|
|
5
5
|
export default async function setPassword(
|
|
6
6
|
root: Root,
|
|
7
|
-
params: {
|
|
7
|
+
params: { newPlainPassword: string; userId: string },
|
|
8
8
|
{ modules, userId }: Context,
|
|
9
9
|
) {
|
|
10
10
|
const normalizedUserId = params.userId || userId;
|
|
@@ -12,7 +12,7 @@ export default async function setPassword(
|
|
|
12
12
|
log(`mutation setPassword ${normalizedUserId}`, { userId });
|
|
13
13
|
|
|
14
14
|
if (!normalizedUserId) throw new InvalidIdError({ userId: normalizedUserId });
|
|
15
|
-
if (!params.
|
|
15
|
+
if (!params.newPlainPassword) {
|
|
16
16
|
throw new Error('Password is required');
|
|
17
17
|
}
|
|
18
18
|
if (!(await modules.users.userExists({ userId: normalizedUserId })))
|
|
@@ -14,7 +14,7 @@ export default async function removeAssortment(
|
|
|
14
14
|
const assortment = await modules.assortments.findAssortment({ assortmentId });
|
|
15
15
|
if (!assortment) throw new AssortmentNotFoundError({ assortmentId });
|
|
16
16
|
|
|
17
|
-
await modules.assortments.delete(assortmentId, { skipInvalidation: false }
|
|
17
|
+
await modules.assortments.delete(assortmentId, { skipInvalidation: false });
|
|
18
18
|
|
|
19
19
|
return assortment;
|
|
20
20
|
}
|
|
@@ -18,7 +18,7 @@ export default async function removeAssortmentFilter(
|
|
|
18
18
|
|
|
19
19
|
if (!assortmentFilter) throw new AssortmentFilterNotFoundError({ assortmentFilterId });
|
|
20
20
|
|
|
21
|
-
await modules.assortments.filters.delete(assortmentFilterId
|
|
21
|
+
await modules.assortments.filters.delete(assortmentFilterId);
|
|
22
22
|
|
|
23
23
|
return assortmentFilter;
|
|
24
24
|
}
|
|
@@ -16,7 +16,7 @@ export default async function removeAssortmentLink(
|
|
|
16
16
|
|
|
17
17
|
if (!assortmentLink) throw new AssortmentLinkNotFoundError({ assortmentLinkId });
|
|
18
18
|
|
|
19
|
-
await modules.assortments.links.delete(assortmentLinkId, { skipInvalidation: false }
|
|
19
|
+
await modules.assortments.links.delete(assortmentLinkId, { skipInvalidation: false });
|
|
20
20
|
|
|
21
21
|
return assortmentLink;
|
|
22
22
|
}
|
|
@@ -18,7 +18,7 @@ export default async function removeAssortmentProduct(
|
|
|
18
18
|
});
|
|
19
19
|
if (!assortmentProduct) throw new AssortmentProductNotFoundError({ assortmentProductId });
|
|
20
20
|
|
|
21
|
-
await modules.assortments.products.delete(assortmentProductId, { skipInvalidation: false }
|
|
21
|
+
await modules.assortments.products.delete(assortmentProductId, { skipInvalidation: false });
|
|
22
22
|
|
|
23
23
|
return assortmentProduct;
|
|
24
24
|
}
|
|
@@ -15,7 +15,7 @@ export default async function removeFilter(
|
|
|
15
15
|
const filter = await modules.filters.findFilter({ filterId });
|
|
16
16
|
if (!filter) throw new FilterNotFoundError({ filterId });
|
|
17
17
|
|
|
18
|
-
await modules.assortments.filters.deleteMany({ filterId }
|
|
18
|
+
await modules.assortments.filters.deleteMany({ filterId });
|
|
19
19
|
await modules.filters.delete(filterId, userId);
|
|
20
20
|
|
|
21
21
|
return filter;
|
|
@@ -16,5 +16,7 @@ export default async function updateFilter(
|
|
|
16
16
|
|
|
17
17
|
if (!(await modules.filters.filterExists({ filterId }))) throw new FilterNotFoundError({ filterId });
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
await modules.filters.update(filterId, filter, context, { skipInvalidation: false }, userId);
|
|
20
|
+
|
|
21
|
+
return modules.filters.findFilter({ filterId });
|
|
20
22
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { emit } from '@unchainedshop/events';
|
|
3
3
|
|
|
4
|
-
export default (root, { path, referrer }, { userId }) => {
|
|
4
|
+
export default async (root, { path, referrer }, { userId }) => {
|
|
5
5
|
log(`mutation pageView ${path} ${referrer}`, { userId });
|
|
6
6
|
|
|
7
|
-
emit('PAGE_VIEW', {
|
|
7
|
+
await emit('PAGE_VIEW', {
|
|
8
8
|
path,
|
|
9
9
|
referrer,
|
|
10
10
|
});
|
|
@@ -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
|
}
|
|
@@ -7,7 +7,7 @@ export default async function product(
|
|
|
7
7
|
{ productId, slug }: { productId?: string; slug?: string },
|
|
8
8
|
{ modules, userId }: Context,
|
|
9
9
|
) {
|
|
10
|
-
log(`query product ${productId
|
|
10
|
+
log(`query product ${productId || slug}`, { userId });
|
|
11
11
|
|
|
12
12
|
if (!productId === !slug) throw new InvalidIdError({ productId, slug });
|
|
13
13
|
|
|
@@ -5,13 +5,16 @@ import { InvalidIdError } from '../../../errors';
|
|
|
5
5
|
export default async function productCatalogPrices(
|
|
6
6
|
root: Root,
|
|
7
7
|
{ productId }: { productId: string },
|
|
8
|
-
{ modules, userId }: Context,
|
|
8
|
+
{ modules, loaders, userId }: Context,
|
|
9
9
|
) {
|
|
10
10
|
log(`query productCatalogPrices ${productId}`, { userId });
|
|
11
11
|
|
|
12
12
|
if (!productId) throw new InvalidIdError({ productId });
|
|
13
13
|
|
|
14
|
-
const product = await
|
|
14
|
+
const product = await loaders.productLoader.load({
|
|
15
|
+
productId,
|
|
16
|
+
includeDrafts: true,
|
|
17
|
+
});
|
|
15
18
|
if (!product) return null;
|
|
16
19
|
|
|
17
20
|
return modules.products.prices.catalogPrices(product);
|
|
@@ -12,7 +12,7 @@ export default async function products(
|
|
|
12
12
|
{ modules, userId }: Context,
|
|
13
13
|
) {
|
|
14
14
|
log(
|
|
15
|
-
`query products: ${params.limit} ${params.offset} ${
|
|
15
|
+
`query products: ${params.limit || 0} ${params.offset || 0} ${
|
|
16
16
|
params.includeDrafts ? 'includeDrafts' : ''
|
|
17
17
|
} ${params.slugs?.join(',')}`,
|
|
18
18
|
{ userId },
|
|
@@ -10,13 +10,18 @@ export type AssortmentFilterHelperTypes = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const AssortmentFilter: AssortmentFilterHelperTypes = {
|
|
13
|
-
assortment: (obj, _, {
|
|
14
|
-
|
|
13
|
+
assortment: async (obj, _, { loaders }) => {
|
|
14
|
+
const assortment = await loaders.assortmentLoader.load({
|
|
15
15
|
assortmentId: obj.assortmentId,
|
|
16
|
-
|
|
16
|
+
includeInactive: true,
|
|
17
|
+
});
|
|
18
|
+
return assortment;
|
|
19
|
+
},
|
|
17
20
|
|
|
18
|
-
filter: (obj, _, {
|
|
19
|
-
|
|
21
|
+
filter: async (obj, _, { loaders }) => {
|
|
22
|
+
const filter = await loaders.filterLoader.load({
|
|
20
23
|
filterId: obj.filterId,
|
|
21
|
-
})
|
|
24
|
+
});
|
|
25
|
+
return filter;
|
|
26
|
+
},
|
|
22
27
|
};
|
|
@@ -9,13 +9,19 @@ export type AssortmentLinkHelperTypes = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const AssortmentLink: AssortmentLinkHelperTypes = {
|
|
12
|
-
child: (obj, _, {
|
|
13
|
-
|
|
12
|
+
child: async (obj, _, { loaders }) => {
|
|
13
|
+
const assortment = await loaders.assortmentLoader.load({
|
|
14
14
|
assortmentId: obj.childAssortmentId,
|
|
15
|
-
|
|
15
|
+
includeInactive: true,
|
|
16
|
+
});
|
|
17
|
+
return assortment;
|
|
18
|
+
},
|
|
16
19
|
|
|
17
|
-
parent: (obj, _, {
|
|
18
|
-
|
|
20
|
+
parent: async (obj, _, { loaders }) => {
|
|
21
|
+
const assortment = await loaders.assortmentLoader.load({
|
|
19
22
|
assortmentId: obj.parentAssortmentId,
|
|
20
|
-
|
|
23
|
+
includeInactive: true,
|
|
24
|
+
});
|
|
25
|
+
return assortment;
|
|
26
|
+
},
|
|
21
27
|
};
|
|
@@ -9,9 +9,6 @@ type HelperType<P, T> = (assortmentPathLink: AssortmentPathLinkType, params: P,
|
|
|
9
9
|
|
|
10
10
|
export interface AssortmentPathLinkHelperTypes {
|
|
11
11
|
link: HelperType<never, Promise<AssortmentLinkType>>;
|
|
12
|
-
|
|
13
|
-
assortmentSlug: HelperType<{ forceLocale?: string }, Promise<string>>;
|
|
14
|
-
|
|
15
12
|
assortmentTexts: HelperType<{ forceLocale?: string }, Promise<AssortmentText>>;
|
|
16
13
|
}
|
|
17
14
|
|
|
@@ -23,14 +20,6 @@ export const AssortmentPathLink: AssortmentPathLinkHelperTypes = {
|
|
|
23
20
|
});
|
|
24
21
|
},
|
|
25
22
|
|
|
26
|
-
assortmentSlug: async ({ assortmentId }, params, { loaders, localeContext }) => {
|
|
27
|
-
const text = await loaders.assortmentTextLoader.load({
|
|
28
|
-
assortmentId,
|
|
29
|
-
locale: params.forceLocale || localeContext.normalized,
|
|
30
|
-
});
|
|
31
|
-
return text.slug;
|
|
32
|
-
},
|
|
33
|
-
|
|
34
23
|
assortmentTexts: async ({ assortmentId }, params, { loaders, localeContext }) => {
|
|
35
24
|
const text = await loaders.assortmentTextLoader.load({
|
|
36
25
|
assortmentId,
|
|
@@ -13,13 +13,19 @@ export type AssortmentProductHelperTypes = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const AssortmentProduct: AssortmentProductHelperTypes = {
|
|
16
|
-
assortment: (obj, _, {
|
|
17
|
-
|
|
16
|
+
assortment: async (obj, _, { loaders }) => {
|
|
17
|
+
const assortment = await loaders.assortmentLoader.load({
|
|
18
18
|
assortmentId: obj.assortmentId,
|
|
19
|
-
|
|
19
|
+
includeInactive: true,
|
|
20
|
+
});
|
|
21
|
+
return assortment;
|
|
22
|
+
},
|
|
20
23
|
|
|
21
|
-
product: (obj, _, {
|
|
22
|
-
|
|
24
|
+
product: async (obj, _, { loaders }) => {
|
|
25
|
+
const product = await loaders.productLoader.load({
|
|
23
26
|
productId: obj.productId,
|
|
24
|
-
|
|
27
|
+
includeDrafts: true,
|
|
28
|
+
});
|
|
29
|
+
return product;
|
|
30
|
+
},
|
|
25
31
|
};
|
|
@@ -11,9 +11,14 @@ export interface BookmarkHelperTypes {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const Bookmark: BookmarkHelperTypes = {
|
|
14
|
-
product: async (obj, _, {
|
|
15
|
-
|
|
14
|
+
product: async (obj, _, { loaders }) => {
|
|
15
|
+
const product = await loaders.productLoader.load({
|
|
16
|
+
productId: obj.productId,
|
|
17
|
+
includeDrafts: true,
|
|
18
|
+
});
|
|
19
|
+
return product;
|
|
16
20
|
},
|
|
21
|
+
|
|
17
22
|
user: async (obj, _, { modules }) => {
|
|
18
23
|
return modules.users.findUserById(obj.userId);
|
|
19
24
|
},
|
|
@@ -9,7 +9,11 @@ type EnrollmentPlanHelperTypes = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const EnrollmentPlan: EnrollmentPlanHelperTypes = {
|
|
12
|
-
product: async (plan, _, {
|
|
13
|
-
|
|
12
|
+
product: async (plan, _, { loaders }) => {
|
|
13
|
+
const product = await loaders.productLoader.load({
|
|
14
|
+
productId: plan.productId,
|
|
15
|
+
includeDrafts: true,
|
|
16
|
+
});
|
|
17
|
+
return product;
|
|
14
18
|
},
|
|
15
19
|
};
|
|
@@ -57,7 +57,7 @@ export const OrderItem: OrderItemHelperTypes = {
|
|
|
57
57
|
return [];
|
|
58
58
|
},
|
|
59
59
|
|
|
60
|
-
dispatches: async (obj, _, { modules }) => {
|
|
60
|
+
dispatches: async (obj, _, { modules, loaders }) => {
|
|
61
61
|
const scheduling = obj.scheduling || [];
|
|
62
62
|
const order = await modules.orders.findOrder({ orderId: obj.orderId });
|
|
63
63
|
const { countryCode, userId } = order;
|
|
@@ -68,8 +68,9 @@ export const OrderItem: OrderItemHelperTypes = {
|
|
|
68
68
|
const deliveryProvider = await modules.delivery.findProvider({
|
|
69
69
|
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
70
70
|
});
|
|
71
|
-
const product = await
|
|
71
|
+
const product = await loaders.productLoader.load({
|
|
72
72
|
productId: obj.productId,
|
|
73
|
+
includeDrafts: true,
|
|
73
74
|
});
|
|
74
75
|
|
|
75
76
|
return Promise.all(
|
|
@@ -99,14 +100,20 @@ export const OrderItem: OrderItemHelperTypes = {
|
|
|
99
100
|
return modules.orders.findOrder({ orderId: obj.orderId });
|
|
100
101
|
},
|
|
101
102
|
|
|
102
|
-
originalProduct: async (obj, _, {
|
|
103
|
-
|
|
103
|
+
originalProduct: async (obj, _, { loaders }) => {
|
|
104
|
+
const product = await loaders.productLoader.load({
|
|
104
105
|
productId: obj.originalProductId,
|
|
106
|
+
includeDrafts: true,
|
|
105
107
|
});
|
|
108
|
+
return product;
|
|
106
109
|
},
|
|
107
110
|
|
|
108
|
-
product: async (obj, _, {
|
|
109
|
-
|
|
111
|
+
product: async (obj, _, { loaders }) => {
|
|
112
|
+
const product = await loaders.productLoader.load({
|
|
113
|
+
productId: obj.productId,
|
|
114
|
+
includeDrafts: true,
|
|
115
|
+
});
|
|
116
|
+
return product;
|
|
110
117
|
},
|
|
111
118
|
|
|
112
119
|
quotation: async (obj, _, { modules }) => {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ProductBundleItemHelperTypes } from '@unchainedshop/types/products';
|
|
2
2
|
|
|
3
3
|
export const ProductBundleItem: ProductBundleItemHelperTypes = {
|
|
4
|
-
product: async (productItem, _, {
|
|
5
|
-
|
|
4
|
+
product: async (productItem, _, { loaders }) => {
|
|
5
|
+
const product = await loaders.productLoader.load({
|
|
6
6
|
productId: productItem.productId,
|
|
7
|
+
includeDrafts: true,
|
|
7
8
|
});
|
|
9
|
+
return product;
|
|
8
10
|
},
|
|
9
11
|
};
|
|
@@ -20,8 +20,12 @@ export const ProductReview: ProductReviewHelperTypes = {
|
|
|
20
20
|
return modules.users.findUserById(obj.authorId);
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
product: async (
|
|
24
|
-
|
|
23
|
+
product: async (review, _, { loaders }) => {
|
|
24
|
+
const product = await loaders.productLoader.load({
|
|
25
|
+
productId: review.productId,
|
|
26
|
+
includeDrafts: true,
|
|
27
|
+
});
|
|
28
|
+
return product;
|
|
25
29
|
},
|
|
26
30
|
|
|
27
31
|
ownVotes: async (obj, _, { modules, userId }) => {
|
|
@@ -11,9 +11,11 @@ export const ProductVariationAssignment: ProductVariationAssignmentHelperTypes =
|
|
|
11
11
|
product,
|
|
12
12
|
}));
|
|
13
13
|
},
|
|
14
|
-
product: async ({ assignment }, _, {
|
|
15
|
-
|
|
14
|
+
product: async ({ assignment }, _, { loaders }) => {
|
|
15
|
+
const product = await loaders.productLoader.load({
|
|
16
16
|
productId: assignment.productId,
|
|
17
|
+
includeDrafts: true,
|
|
17
18
|
});
|
|
19
|
+
return product;
|
|
18
20
|
},
|
|
19
21
|
};
|
|
@@ -24,10 +24,13 @@ export const Quotation: QuotationHelperTypes = {
|
|
|
24
24
|
isExpired: (obj, { referenceDate }, { modules }) =>
|
|
25
25
|
modules.quotations.isExpired(obj, { referenceDate }),
|
|
26
26
|
|
|
27
|
-
product: (obj, _, {
|
|
28
|
-
|
|
27
|
+
product: async (obj, _, { loaders }) => {
|
|
28
|
+
const product = await loaders.productLoader.load({
|
|
29
29
|
productId: obj.productId,
|
|
30
|
-
|
|
30
|
+
includeDrafts: true,
|
|
31
|
+
});
|
|
32
|
+
return product;
|
|
33
|
+
},
|
|
31
34
|
|
|
32
35
|
status: (obj, _, { modules }) => modules.quotations.normalizedStatus(obj),
|
|
33
36
|
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
WebAuthnCredentials,
|
|
17
17
|
} from '@unchainedshop/types/user';
|
|
18
18
|
import type { Locale } from 'locale';
|
|
19
|
-
import { log, LogLevel } from '@unchainedshop/logger';
|
|
20
19
|
import { TokenSurrogate } from '@unchainedshop/types/warehousing';
|
|
21
20
|
import { checkAction, checkTypeResolver } from '../../acl';
|
|
22
21
|
import { actions } from '../../roles';
|
|
@@ -29,10 +28,8 @@ export interface UserHelperTypes {
|
|
|
29
28
|
bookmarks: HelperType<any, Array<Bookmark>>;
|
|
30
29
|
cart: HelperType<{ orderNumber?: string }, Order>;
|
|
31
30
|
country: HelperType<{ localeContext: Locale }, Country>;
|
|
32
|
-
email: HelperType<any, string>;
|
|
33
31
|
emails: HelperType<any, Array<string>>;
|
|
34
32
|
enrollments: HelperType<{ sort?: Array<SortOption>; queryString?: string }, Array<Enrollment>>;
|
|
35
|
-
isEmailVerified: HelperType<any, boolean>;
|
|
36
33
|
isGuest: HelperType<any, boolean>;
|
|
37
34
|
isInitialPassword: HelperType<any, boolean>;
|
|
38
35
|
isTwoFactorEnabled: HelperType<any, boolean>;
|
|
@@ -97,18 +94,6 @@ export const User: UserHelperTypes = {
|
|
|
97
94
|
return getPrimaryEmail(user);
|
|
98
95
|
},
|
|
99
96
|
|
|
100
|
-
email: async (user, params, context) => {
|
|
101
|
-
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
102
|
-
return getPrimaryEmail(user)?.address;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
isEmailVerified: async (user, params, context) => {
|
|
106
|
-
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
107
|
-
log('user.isEmailVerified is deprecated, please use user.primaryEmail.verified', {
|
|
108
|
-
level: LogLevel.Warning,
|
|
109
|
-
});
|
|
110
|
-
return !!getPrimaryEmail(user)?.verified;
|
|
111
|
-
},
|
|
112
97
|
isInitialPassword: async (user, params, context) => {
|
|
113
98
|
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
114
99
|
const { password: { initial } = { initial: undefined } } = user.services || {};
|
package/src/schema/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import scalars from './scalars';
|
|
2
|
+
import directives from './directives';
|
|
2
3
|
import types from './types';
|
|
3
4
|
import inputTypes from './inputTypes';
|
|
4
5
|
import query from './query';
|
|
5
6
|
import mutation from './mutation';
|
|
6
7
|
|
|
7
|
-
export default [...scalars, ...types, ...inputTypes, ...query, ...mutation];
|
|
8
|
+
export default [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation];
|
package/src/schema/inputTypes.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
export default [
|
|
2
2
|
/* GraphQL */ `
|
|
3
|
-
"""
|
|
4
|
-
A hashed password
|
|
5
|
-
"""
|
|
6
|
-
input HashedPasswordInput {
|
|
7
|
-
"""
|
|
8
|
-
The hashed password
|
|
9
|
-
"""
|
|
10
|
-
digest: String!
|
|
11
|
-
|
|
12
|
-
"""
|
|
13
|
-
Algorithm used to hash the password
|
|
14
|
-
"""
|
|
15
|
-
algorithm: String!
|
|
16
|
-
}
|
|
17
|
-
|
|
18
3
|
input SortOptionInput {
|
|
19
4
|
key: String!
|
|
20
5
|
value: SortDirection!
|