@unchainedshop/api 4.4.0 → 4.6.0
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/README.md +204 -0
- package/lib/api-index.js +3 -0
- package/lib/chat/generateImageHandler.d.ts +7 -1
- package/lib/chat/generateImageHandler.js +4 -5
- package/lib/context.js +2 -13
- package/lib/errors.d.ts +1 -0
- package/lib/errors.js +2 -1
- package/lib/events.js +0 -2
- package/lib/express/chatHandler.js +4 -4
- package/lib/express/createERCMetadataMiddleware.js +1 -1
- package/lib/express/index.js +23 -9
- package/lib/fastify/chatHandler.js +4 -4
- package/lib/fastify/ercMetadataHandler.js +1 -1
- package/lib/fastify/index.js +9 -3
- package/lib/loaders/assortmentMediaTextLoader.js +1 -1
- package/lib/loaders/assortmentMediasLoader.js +1 -1
- package/lib/loaders/assortmentTextLoader.js +1 -1
- package/lib/loaders/countryLoader.js +1 -1
- package/lib/loaders/currencyLoader.js +1 -1
- package/lib/loaders/deliveryProviderLoader.js +1 -1
- package/lib/loaders/fileLoader.js +1 -1
- package/lib/loaders/filterTextLoader.js +1 -1
- package/lib/loaders/languageLoader.js +1 -1
- package/lib/loaders/orderLoader.js +1 -1
- package/lib/loaders/paymentProviderLoader.js +1 -1
- package/lib/loaders/productBySKULoader.js +2 -4
- package/lib/loaders/productLoader.js +1 -3
- package/lib/loaders/productMediaTextLoader.js +1 -1
- package/lib/loaders/productMediasLoader.js +1 -1
- package/lib/loaders/productProxiesLoader.js +2 -10
- package/lib/loaders/productTextLoader.js +1 -1
- package/lib/loaders/productVariationByKeyLoader.js +1 -1
- package/lib/loaders/productVariationLoader.js +1 -1
- package/lib/loaders/productVariationTextLoader.js +1 -1
- package/lib/loaders/quotationLoader.js +1 -1
- package/lib/loaders/userLoader.js +1 -1
- package/lib/loaders/warehousingProviderLoader.js +1 -1
- package/lib/mcp/tools/assortment/handlers/addAssortmentFilter.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/addAssortmentLink.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/addAssortmentMedia.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/addAssortmentProduct.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/createAssortment.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/getAssortment.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/getAssortmentChildren.d.ts +0 -2
- package/lib/mcp/tools/assortment/handlers/getAssortmentFilters.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/getAssortmentLinks.d.ts +0 -2
- package/lib/mcp/tools/assortment/handlers/getAssortmentMedia.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/getAssortmentProducts.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/index.d.ts +0 -2
- package/lib/mcp/tools/assortment/handlers/index.js +0 -2
- package/lib/mcp/tools/assortment/handlers/listAssortments.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/reorderAssortmentLinks.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/searchAssortmentProducts.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/updateAssortment.d.ts +0 -1
- package/lib/mcp/tools/assortment/handlers/updateAssortmentStatus.d.ts +0 -1
- package/lib/mcp/tools/assortment/schemas.d.ts +0 -5
- package/lib/mcp/tools/assortment/schemas.js +0 -4
- package/lib/mcp/tools/order/handlers/confirmOrder.d.ts +1 -1
- package/lib/mcp/tools/order/handlers/deliverOrder.d.ts +1 -1
- package/lib/mcp/tools/order/handlers/getOrder.d.ts +1 -1
- package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +6 -6
- package/lib/mcp/tools/order/handlers/getTopCustomers.js +5 -55
- package/lib/mcp/tools/order/handlers/getTopProducts.d.ts +3 -3
- package/lib/mcp/tools/order/handlers/getTopProducts.js +4 -43
- package/lib/mcp/tools/order/handlers/getUserCart.d.ts +1 -1
- package/lib/mcp/tools/order/handlers/listOrders.d.ts +1 -1
- package/lib/mcp/tools/order/handlers/payOrder.d.ts +1 -1
- package/lib/mcp/tools/order/handlers/rejectOrder.d.ts +1 -1
- package/lib/mcp/tools/provider/handlers/listProviders.js +4 -8
- package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -2
- package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -2
- package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -2
- package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -2
- package/lib/mcp/tools/quotation/handlers/rejectQuotation.js +1 -1
- package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -2
- package/lib/mcp/tools/quotation/index.js +1 -1
- package/lib/mcp/tools/quotation/schemas.d.ts +5 -5
- package/lib/mcp/tools/quotation/schemas.js +3 -3
- package/lib/mcp/tools/system/schemas.d.ts +6 -6
- package/lib/mcp/tools/system/schemas.js +14 -7
- package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/createUser.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/enrollUser.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/getUser.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/getUserOrders.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/getUserQuotations.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/listUsers.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/setUserTags.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +1 -1
- package/lib/mcp/tools/users/handlers/updateUser.d.ts +1 -1
- package/lib/mcp/utils/getNormalizedAssortmentDetails.d.ts +0 -1
- package/lib/mcp/utils/getNormalizedOrderDetails.d.ts +1 -1
- package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -2
- package/lib/mcp/utils/getNormalizedUserDetails.d.ts +1 -1
- package/lib/mongo-store.d.ts +9 -5
- package/lib/mongo-store.js +31 -25
- package/lib/resolvers/mutations/accounts/addWeb3Address.d.ts +2 -2
- package/lib/resolvers/mutations/accounts/addWeb3Address.js +1 -14
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.d.ts +2 -2
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js +2 -6
- package/lib/resolvers/mutations/accounts/createUser.js +3 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts +1 -4
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts +1 -4
- package/lib/resolvers/mutations/accounts/forgotPassword.js +4 -4
- package/lib/resolvers/mutations/accounts/loginAsGuest.js +1 -3
- package/lib/resolvers/mutations/accounts/removeWeb3Address.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/removeWeb3Address.js +3 -7
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.js +1 -5
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.d.ts +2 -2
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js +8 -89
- package/lib/resolvers/mutations/filters/removeFilter.d.ts +2 -2
- package/lib/resolvers/mutations/filters/removeFilter.js +3 -5
- package/lib/resolvers/mutations/index.d.ts +0 -1
- package/lib/resolvers/mutations/index.js +0 -2
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.js +23 -31
- package/lib/resolvers/mutations/orders/removeCartDiscount.d.ts +2 -2
- package/lib/resolvers/mutations/orders/removeCartDiscount.js +9 -14
- package/lib/resolvers/mutations/orders/updateCart.js +2 -8
- package/lib/resolvers/mutations/quotations/rejectQuotation.js +1 -1
- package/lib/resolvers/mutations/users/removeUser.d.ts +1 -1
- package/lib/resolvers/mutations/users/removeUser.js +2 -3
- package/lib/resolvers/mutations/warehousing/exportToken.js +9 -17
- package/lib/resolvers/queries/payment/paymentProvidersCount.d.ts +3 -3
- package/lib/resolvers/queries/payment/paymentProvidersCount.js +1 -1
- package/lib/resolvers/queries/shopInfo.js +4 -36
- package/lib/resolvers/type/delivery-provider-interface.d.ts +1 -7
- package/lib/resolvers/type/delivery-provider-interface.js +10 -20
- package/lib/resolvers/type/delivery-provider-pickup-types.d.ts +1 -7
- package/lib/resolvers/type/delivery-provider-shipping-types.d.ts +1 -7
- package/lib/resolvers/type/delivery-provider-types.d.ts +1 -7
- package/lib/resolvers/type/index.d.ts +33 -54
- package/lib/resolvers/type/media-types.d.ts +1 -1
- package/lib/resolvers/type/media-types.js +7 -5
- package/lib/resolvers/type/order/order-item-types.d.ts +2 -9
- package/lib/resolvers/type/order/order-item-types.js +2 -37
- package/lib/resolvers/type/order/order-statistics-types.d.ts +10 -10
- package/lib/resolvers/type/order/order-statistics-types.js +10 -64
- package/lib/resolvers/type/payment/payment-provider-types.d.ts +1 -7
- package/lib/resolvers/type/payment/payment-provider-types.js +7 -17
- package/lib/resolvers/type/price-types.d.ts +0 -1
- package/lib/resolvers/type/product/product-bundle-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-configurable-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-configurable-types.js +9 -32
- package/lib/resolvers/type/product/product-plan-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-simple-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-types.js +7 -17
- package/lib/resolvers/type/shop-types.js +2 -5
- package/lib/resolvers/type/token-types.d.ts +3 -3
- package/lib/resolvers/type/token-types.js +4 -25
- package/lib/resolvers/type/user-types.js +1 -4
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +10 -1
- package/lib/roles/index.d.ts +2 -1
- package/lib/roles/index.js +7 -1
- package/lib/schema/mutation.js +1 -7
- package/lib/schema/types/assortment.js +0 -1
- package/lib/schema/types/order/order.js +2 -2
- package/lib/schema/types/quotation.js +2 -2
- package/lib/utils/getConfiguredTags.d.ts +1 -0
- package/lib/utils/getConfiguredTags.js +9 -0
- package/package.json +14 -23
- package/lib/mcp/tools/assortment/handlers/setAssortmentBase.d.ts +0 -28
- package/lib/mcp/tools/assortment/handlers/setAssortmentBase.js +0 -11
- package/lib/resolvers/mutations/assortments/setBaseAssortment.d.ts +0 -4
- package/lib/resolvers/mutations/assortments/setBaseAssortment.js +0 -11
|
@@ -2,7 +2,7 @@ import DataLoader from 'dataloader';
|
|
|
2
2
|
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
3
|
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
4
4
|
const productMediaItems = await unchainedAPI.modules.products.media.findProductMedias({
|
|
5
|
-
|
|
5
|
+
productIds,
|
|
6
6
|
});
|
|
7
7
|
const productMediaMap = {};
|
|
8
8
|
for (const productMedia of productMediaItems) {
|
|
@@ -3,16 +3,8 @@ export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
|
3
3
|
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
4
4
|
const productProxies = await unchainedAPI.modules.products.findProducts({
|
|
5
5
|
includeDrafts: true,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
'bundleItems.productId': { $in: productIds },
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
'proxy.assignments.productId': { $in: productIds },
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
},
|
|
6
|
+
bundleItemProductIds: productIds,
|
|
7
|
+
proxyAssignmentProductIds: productIds,
|
|
16
8
|
});
|
|
17
9
|
const productProxyMap = {};
|
|
18
10
|
for (const productProxy of productProxies) {
|
|
@@ -3,7 +3,7 @@ import buildTextMap from "./buildTextMap.js";
|
|
|
3
3
|
import buildLocaleMap from "./buildLocaleMap.js";
|
|
4
4
|
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
5
5
|
const productIds = [...new Set(queries.map((q) => q.productId))].filter(Boolean);
|
|
6
|
-
const texts = await unchainedAPI.modules.products.texts.findTexts({
|
|
6
|
+
const texts = await unchainedAPI.modules.products.texts.findTexts({ productIds }, {
|
|
7
7
|
sort: {
|
|
8
8
|
productId: 1,
|
|
9
9
|
},
|
|
@@ -2,7 +2,7 @@ import DataLoader from 'dataloader';
|
|
|
2
2
|
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
3
|
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
4
4
|
const variations = await unchainedAPI.modules.products.variations.findProductVariations({
|
|
5
|
-
|
|
5
|
+
productIds,
|
|
6
6
|
});
|
|
7
7
|
const variationMap = {};
|
|
8
8
|
for (const variation of variations) {
|
|
@@ -2,7 +2,7 @@ import DataLoader from 'dataloader';
|
|
|
2
2
|
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
3
|
const productVariationIds = [...new Set(queries.map((q) => q.productVariationId).filter(Boolean))];
|
|
4
4
|
const variations = await unchainedAPI.modules.products.variations.findProductVariations({
|
|
5
|
-
|
|
5
|
+
productVariationIds,
|
|
6
6
|
});
|
|
7
7
|
const variationMap = {};
|
|
8
8
|
for (const variation of variations) {
|
|
@@ -4,7 +4,7 @@ import buildLocaleMap from "./buildLocaleMap.js";
|
|
|
4
4
|
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
5
5
|
const productVariationIds = [...new Set(queries.map((q) => q.productVariationId).filter(Boolean))];
|
|
6
6
|
const texts = await unchainedAPI.modules.products.variations.texts.findVariationTexts({
|
|
7
|
-
|
|
7
|
+
productVariationIds,
|
|
8
8
|
}, {
|
|
9
9
|
sort: {
|
|
10
10
|
productVariationId: 1,
|
|
@@ -2,7 +2,7 @@ import DataLoader from 'dataloader';
|
|
|
2
2
|
export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
3
3
|
const quotationIds = [...new Set(queries.map((q) => q.quotationId).filter(Boolean))];
|
|
4
4
|
const quotations = await unchainedAPI.modules.quotations.findQuotations({
|
|
5
|
-
|
|
5
|
+
quotationIds,
|
|
6
6
|
});
|
|
7
7
|
const quotationMap = {};
|
|
8
8
|
for (const quotation of quotations) {
|
|
@@ -4,7 +4,7 @@ export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
|
4
4
|
const users = await unchainedAPI.modules.users.findUsers({
|
|
5
5
|
includeGuests: true,
|
|
6
6
|
includeDeleted: true,
|
|
7
|
-
|
|
7
|
+
userIds,
|
|
8
8
|
});
|
|
9
9
|
const userMap = {};
|
|
10
10
|
for (const user of users) {
|
|
@@ -4,7 +4,7 @@ export default (unchainedAPI) => new DataLoader(async (queries) => {
|
|
|
4
4
|
...new Set(queries.map((q) => q.warehousingProviderId).filter(Boolean)),
|
|
5
5
|
];
|
|
6
6
|
const warehousingProviders = await unchainedAPI.modules.warehousing.findProviders({
|
|
7
|
-
|
|
7
|
+
warehousingProviderIds,
|
|
8
8
|
includeDeleted: true,
|
|
9
9
|
});
|
|
10
10
|
const warehousingProviderMap = {};
|
|
@@ -14,7 +14,6 @@ export default function addAssortmentFilter(context: Context, params: Params<'AD
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function addAssortmentLink(context: Context, params: Params<'ADD_
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function addAssortmentMedia(context: Context, params: Params<'ADD
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function addAssortmentProduct(context: Context, params: Params<'A
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -15,7 +15,6 @@ export default function createAssortment(context: Context, params: Params<'CREAT
|
|
|
15
15
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
16
16
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
17
17
|
isActive: boolean;
|
|
18
|
-
isBase: boolean;
|
|
19
18
|
isRoot: boolean;
|
|
20
19
|
meta?: any;
|
|
21
20
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function getAssortment(context: Context, params: Params<'GET'>):
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function getAssortmentChildren(context: Context, params: Params<'
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -28,7 +27,6 @@ export default function getAssortmentChildren(context: Context, params: Params<'
|
|
|
28
27
|
children: {
|
|
29
28
|
_id: string;
|
|
30
29
|
isActive: boolean;
|
|
31
|
-
isBase: boolean;
|
|
32
30
|
isRoot: boolean;
|
|
33
31
|
meta?: any;
|
|
34
32
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function getAssortmentFilters(context: Context, params: Params<'G
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function getAssortmentLinks(context: Context, params: Params<'GET
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -47,7 +46,6 @@ export default function getAssortmentLinks(context: Context, params: Params<'GET
|
|
|
47
46
|
links?: import("@unchainedshop/core-assortments").AssortmentLink[] | undefined;
|
|
48
47
|
products?: import("@unchainedshop/core-assortments").AssortmentProduct[] | undefined;
|
|
49
48
|
isActive?: boolean | undefined;
|
|
50
|
-
isBase?: boolean | undefined;
|
|
51
49
|
isRoot?: boolean | undefined;
|
|
52
50
|
sequence?: number | undefined;
|
|
53
51
|
slugs?: string[];
|
|
@@ -14,7 +14,6 @@ export default function getAssortmentMedia(context: Context, params: Params<'GET
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function getAssortmentProducts(context: Context, params: Params<'
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -23,7 +23,6 @@ import removeAssortmentLink from './removeAssortmentLink.ts';
|
|
|
23
23
|
import getAssortmentLinks from './getAssortmentLinks.ts';
|
|
24
24
|
import reorderAssortmentLinks from './reorderAssortmentLinks.ts';
|
|
25
25
|
import getAssortmentChildren from './getAssortmentChildren.ts';
|
|
26
|
-
import setAssortmentBase from './setAssortmentBase.ts';
|
|
27
26
|
import searchAssortmentProducts from './searchAssortmentProducts.ts';
|
|
28
27
|
import getAssortmentTexts from './getAssortmentTexts.ts';
|
|
29
28
|
import getAssortmentMediaTexts from './getAssortmentMediaTexts.ts';
|
|
@@ -53,7 +52,6 @@ declare const _default: {
|
|
|
53
52
|
GET_LINKS: typeof getAssortmentLinks;
|
|
54
53
|
REORDER_LINKS: typeof reorderAssortmentLinks;
|
|
55
54
|
GET_CHILDREN: typeof getAssortmentChildren;
|
|
56
|
-
SET_BASE: typeof setAssortmentBase;
|
|
57
55
|
SEARCH_PRODUCTS: typeof searchAssortmentProducts;
|
|
58
56
|
GET_TEXTS: typeof getAssortmentTexts;
|
|
59
57
|
GET_MEDIA_TEXTS: typeof getAssortmentMediaTexts;
|
|
@@ -23,7 +23,6 @@ import removeAssortmentLink from "./removeAssortmentLink.js";
|
|
|
23
23
|
import getAssortmentLinks from "./getAssortmentLinks.js";
|
|
24
24
|
import reorderAssortmentLinks from "./reorderAssortmentLinks.js";
|
|
25
25
|
import getAssortmentChildren from "./getAssortmentChildren.js";
|
|
26
|
-
import setAssortmentBase from "./setAssortmentBase.js";
|
|
27
26
|
import searchAssortmentProducts from "./searchAssortmentProducts.js";
|
|
28
27
|
import getAssortmentTexts from "./getAssortmentTexts.js";
|
|
29
28
|
import getAssortmentMediaTexts from "./getAssortmentMediaTexts.js";
|
|
@@ -53,7 +52,6 @@ export default {
|
|
|
53
52
|
GET_LINKS: getAssortmentLinks,
|
|
54
53
|
REORDER_LINKS: reorderAssortmentLinks,
|
|
55
54
|
GET_CHILDREN: getAssortmentChildren,
|
|
56
|
-
SET_BASE: setAssortmentBase,
|
|
57
55
|
SEARCH_PRODUCTS: searchAssortmentProducts,
|
|
58
56
|
GET_TEXTS: getAssortmentTexts,
|
|
59
57
|
GET_MEDIA_TEXTS: getAssortmentMediaTexts,
|
|
@@ -14,7 +14,6 @@ export default function listAssortments(context: Context, params: Params<'LIST'>
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -23,7 +23,6 @@ export default function reorderAssortmentLinks(context: Context, params: Params<
|
|
|
23
23
|
links?: import("@unchainedshop/core-assortments").AssortmentLink[] | undefined;
|
|
24
24
|
products?: import("@unchainedshop/core-assortments").AssortmentProduct[] | undefined;
|
|
25
25
|
isActive?: boolean | undefined;
|
|
26
|
-
isBase?: boolean | undefined;
|
|
27
26
|
isRoot?: boolean | undefined;
|
|
28
27
|
sequence?: number | undefined;
|
|
29
28
|
slugs?: string[];
|
|
@@ -14,7 +14,6 @@ export default function searchAssortmentProducts(context: Context, params: Param
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function updateAssortment(context: Context, params: Params<'UPDAT
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -14,7 +14,6 @@ export default function updateAssortmentStatus(context: Context, params: Params<
|
|
|
14
14
|
links: import("@unchainedshop/core-assortments").AssortmentLink[];
|
|
15
15
|
products: import("@unchainedshop/core-assortments").AssortmentProduct[];
|
|
16
16
|
isActive: boolean;
|
|
17
|
-
isBase: boolean;
|
|
18
17
|
isRoot: boolean;
|
|
19
18
|
meta?: any;
|
|
20
19
|
sequence: number;
|
|
@@ -165,9 +165,6 @@ export declare const actionValidators: {
|
|
|
165
165
|
assortmentId: z.ZodString;
|
|
166
166
|
includeInactive: z.ZodOptional<z.ZodBoolean>;
|
|
167
167
|
}, z.core.$strip>;
|
|
168
|
-
readonly SET_BASE: z.ZodObject<{
|
|
169
|
-
assortmentId: z.ZodString;
|
|
170
|
-
}, z.core.$strip>;
|
|
171
168
|
readonly SEARCH_PRODUCTS: z.ZodObject<{
|
|
172
169
|
queryString: z.ZodOptional<z.ZodString>;
|
|
173
170
|
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -223,7 +220,6 @@ export declare const AssortmentManagementSchema: {
|
|
|
223
220
|
GET_LINKS: "GET_LINKS";
|
|
224
221
|
REORDER_LINKS: "REORDER_LINKS";
|
|
225
222
|
GET_CHILDREN: "GET_CHILDREN";
|
|
226
|
-
SET_BASE: "SET_BASE";
|
|
227
223
|
SEARCH_PRODUCTS: "SEARCH_PRODUCTS";
|
|
228
224
|
}>;
|
|
229
225
|
assortmentId: z.ZodOptional<z.ZodString>;
|
|
@@ -316,7 +312,6 @@ export declare const AssortmentManagementZodSchema: z.ZodObject<{
|
|
|
316
312
|
GET_LINKS: "GET_LINKS";
|
|
317
313
|
REORDER_LINKS: "REORDER_LINKS";
|
|
318
314
|
GET_CHILDREN: "GET_CHILDREN";
|
|
319
|
-
SET_BASE: "SET_BASE";
|
|
320
315
|
SEARCH_PRODUCTS: "SEARCH_PRODUCTS";
|
|
321
316
|
}>;
|
|
322
317
|
assortmentId: z.ZodOptional<z.ZodString>;
|
|
@@ -154,9 +154,6 @@ export const actionValidators = {
|
|
|
154
154
|
assortmentId: z.string().min(1).describe('Assortment ID (optional for root-level)'),
|
|
155
155
|
includeInactive: z.boolean().optional().describe('Include inactive children'),
|
|
156
156
|
}),
|
|
157
|
-
SET_BASE: z.object({
|
|
158
|
-
assortmentId: z.string().min(1).describe('Assortment ID to set as base'),
|
|
159
|
-
}),
|
|
160
157
|
SEARCH_PRODUCTS: z.object({
|
|
161
158
|
assortmentId: z.string().min(1).describe('Assortment ID'),
|
|
162
159
|
...PaginationSchema,
|
|
@@ -197,7 +194,6 @@ export const AssortmentManagementSchema = {
|
|
|
197
194
|
'GET_LINKS',
|
|
198
195
|
'REORDER_LINKS',
|
|
199
196
|
'GET_CHILDREN',
|
|
200
|
-
'SET_BASE',
|
|
201
197
|
'SEARCH_PRODUCTS',
|
|
202
198
|
'GET_TEXTS',
|
|
203
199
|
'GET_MEDIA_TEXTS',
|
|
@@ -76,7 +76,7 @@ export default function confirmOrder(context: Context, params: Params<'CONFIRM_O
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -76,7 +76,7 @@ export default function deliverOrder(context: Context, params: Params<'DELIVER_O
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -76,7 +76,7 @@ export default function getOrder(context: Context, params: Params<'GET'>): Promi
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -2,14 +2,14 @@ import type { Context } from '../../../../context.ts';
|
|
|
2
2
|
import type { Params } from '../schemas.ts';
|
|
3
3
|
export default function getTopCustomers(context: Context, params: Params<'TOP_CUSTOMERS'>): Promise<{
|
|
4
4
|
customers: {
|
|
5
|
-
userId:
|
|
5
|
+
userId: string;
|
|
6
6
|
user: {
|
|
7
7
|
avatar: import("@unchainedshop/core-files").File;
|
|
8
8
|
meta?: any;
|
|
9
9
|
tags?: string[] | undefined;
|
|
10
10
|
created: Date;
|
|
11
11
|
updated?: Date | undefined;
|
|
12
|
-
deleted?: Date | undefined;
|
|
12
|
+
deleted?: (Date | null) | undefined;
|
|
13
13
|
avatarId?: string | undefined;
|
|
14
14
|
emails: import("@unchainedshop/core-users").Email[];
|
|
15
15
|
guest: boolean;
|
|
@@ -24,10 +24,10 @@ export default function getTopCustomers(context: Context, params: Params<'TOP_CU
|
|
|
24
24
|
username?: string | undefined;
|
|
25
25
|
_id: string;
|
|
26
26
|
} | null;
|
|
27
|
-
currencyCode:
|
|
28
|
-
totalSpent:
|
|
29
|
-
orderCount:
|
|
30
|
-
lastOrderDate:
|
|
27
|
+
currencyCode: string | null;
|
|
28
|
+
totalSpent: number;
|
|
29
|
+
orderCount: number;
|
|
30
|
+
lastOrderDate: Date;
|
|
31
31
|
averageOrderValue: number;
|
|
32
32
|
}[];
|
|
33
33
|
}>;
|
|
@@ -2,11 +2,10 @@ import { OrderStatus } from '@unchainedshop/core-orders';
|
|
|
2
2
|
import { resolveDateRange } from "../../../utils/orderFilters.js";
|
|
3
3
|
export default async function getTopCustomers(context, params) {
|
|
4
4
|
const { modules, loaders } = context;
|
|
5
|
-
const {
|
|
6
|
-
const match = {};
|
|
5
|
+
const { from: dateStart, to: dateEnd, limit = 10 } = params;
|
|
7
6
|
const { startDate, endDate } = resolveDateRange(dateStart, dateEnd);
|
|
8
7
|
const orders = await modules.orders.findOrders({
|
|
9
|
-
status: [OrderStatus.CONFIRMED, OrderStatus.
|
|
8
|
+
status: [OrderStatus.CONFIRMED, OrderStatus.FULFILLED],
|
|
10
9
|
dateRange: { start: startDate.toISOString(), end: endDate.toISOString() },
|
|
11
10
|
}, {
|
|
12
11
|
projection: {
|
|
@@ -14,64 +13,15 @@ export default async function getTopCustomers(context, params) {
|
|
|
14
13
|
},
|
|
15
14
|
});
|
|
16
15
|
const orderIds = orders.map(({ _id }) => _id);
|
|
17
|
-
|
|
18
|
-
match.created = { ...(match.created || {}), $gte: startDate };
|
|
19
|
-
if (endDate)
|
|
20
|
-
match.created = { ...(match.created || {}), $lte: endDate };
|
|
21
|
-
if (customerStatus)
|
|
22
|
-
match.status = customerStatus;
|
|
23
|
-
if (orderIds?.length)
|
|
24
|
-
match._id = { $in: orderIds };
|
|
25
|
-
const topCustomers = await modules.orders.aggregateOrders({
|
|
26
|
-
match,
|
|
27
|
-
project: {
|
|
28
|
-
userId: 1,
|
|
29
|
-
created: 1,
|
|
30
|
-
currencyCode: 1,
|
|
31
|
-
itemAmount: {
|
|
32
|
-
$let: {
|
|
33
|
-
vars: {
|
|
34
|
-
item: {
|
|
35
|
-
$first: {
|
|
36
|
-
$filter: {
|
|
37
|
-
input: '$calculation',
|
|
38
|
-
as: 'c',
|
|
39
|
-
cond: { $eq: ['$$c.category', 'ITEMS'] },
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
in: '$$item.amount',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
group: {
|
|
49
|
-
_id: { userId: '$userId', currencyCode: '$currencyCode' },
|
|
50
|
-
totalSpent: { $sum: '$itemAmount' },
|
|
51
|
-
orderCount: { $sum: 1 },
|
|
52
|
-
lastOrderDate: { $max: '$created' },
|
|
53
|
-
},
|
|
54
|
-
matchAfterGroup: {
|
|
55
|
-
totalSpent: { $gt: 0 },
|
|
56
|
-
},
|
|
57
|
-
addFields: {
|
|
58
|
-
averageOrderValue: {
|
|
59
|
-
$cond: [{ $eq: ['$orderCount', 0] }, 0, { $divide: ['$totalSpent', '$orderCount'] }],
|
|
60
|
-
},
|
|
61
|
-
currencyCode: '$_id.currencyCode',
|
|
62
|
-
_id: '$_id.userId',
|
|
63
|
-
},
|
|
64
|
-
sort: { totalSpent: -1 },
|
|
65
|
-
limit,
|
|
66
|
-
});
|
|
16
|
+
const topCustomers = await modules.orders.statistics.getTopCustomers(orderIds, { limit });
|
|
67
17
|
const normalizedCustomers = await Promise.all(topCustomers.map(async (c) => {
|
|
68
|
-
const user = await modules.users.findUserById(c.
|
|
18
|
+
const user = await modules.users.findUserById(c.userId);
|
|
69
19
|
const avatar = user?.avatarId &&
|
|
70
20
|
(await loaders.fileLoader.load({
|
|
71
21
|
fileId: user?.avatarId,
|
|
72
22
|
}));
|
|
73
23
|
return {
|
|
74
|
-
userId: c.
|
|
24
|
+
userId: c.userId?.toString?.() ?? null,
|
|
75
25
|
user: avatar
|
|
76
26
|
? {
|
|
77
27
|
...user,
|
|
@@ -2,7 +2,7 @@ import type { Context } from '../../../../context.ts';
|
|
|
2
2
|
import type { Params } from '../schemas.ts';
|
|
3
3
|
export default function getTopProducts(context: Context, params: Params<'TOP_PRODUCTS'>): Promise<{
|
|
4
4
|
products: {
|
|
5
|
-
productId:
|
|
5
|
+
productId: string;
|
|
6
6
|
product: {
|
|
7
7
|
texts: import("@unchainedshop/core-products").ProductText;
|
|
8
8
|
media: {
|
|
@@ -34,8 +34,8 @@ export default function getTopProducts(context: Context, params: Params<'TOP_PRO
|
|
|
34
34
|
updated?: Date;
|
|
35
35
|
deleted?: Date | null;
|
|
36
36
|
} | null;
|
|
37
|
-
totalSold:
|
|
38
|
-
totalRevenue:
|
|
37
|
+
totalSold: number;
|
|
38
|
+
totalRevenue: number;
|
|
39
39
|
}[];
|
|
40
40
|
dateRange: {
|
|
41
41
|
start: string | null;
|
|
@@ -4,10 +4,9 @@ import { getNormalizedProductDetails } from "../../../utils/getNormalizedProduct
|
|
|
4
4
|
export default async function getTopProducts(context, params) {
|
|
5
5
|
const { modules } = context;
|
|
6
6
|
const { from, to, limit = 10 } = params;
|
|
7
|
-
const match = {};
|
|
8
7
|
const { startDate, endDate } = resolveDateRange(from, to);
|
|
9
8
|
const orders = await modules.orders.findOrders({
|
|
10
|
-
status: [OrderStatus.CONFIRMED, OrderStatus.
|
|
9
|
+
status: [OrderStatus.CONFIRMED, OrderStatus.FULFILLED],
|
|
11
10
|
dateRange: { start: startDate.toISOString(), end: endDate.toISOString() },
|
|
12
11
|
}, {
|
|
13
12
|
projection: {
|
|
@@ -15,49 +14,11 @@ export default async function getTopProducts(context, params) {
|
|
|
15
14
|
},
|
|
16
15
|
});
|
|
17
16
|
const orderIds = orders.map(({ _id }) => _id);
|
|
18
|
-
|
|
19
|
-
match.created = { ...(match.created || {}), $gte: startDate };
|
|
20
|
-
if (endDate)
|
|
21
|
-
match.created = { ...(match.created || {}), $lte: endDate };
|
|
22
|
-
if (orderIds?.length)
|
|
23
|
-
match.orderId = { $in: orderIds };
|
|
24
|
-
const topProducts = await modules.orders.positions.aggregatePositions({
|
|
25
|
-
match,
|
|
26
|
-
project: {
|
|
27
|
-
productId: 1,
|
|
28
|
-
quantity: 1,
|
|
29
|
-
itemAmount: {
|
|
30
|
-
$let: {
|
|
31
|
-
vars: {
|
|
32
|
-
item: {
|
|
33
|
-
$first: {
|
|
34
|
-
$filter: {
|
|
35
|
-
input: '$calculation',
|
|
36
|
-
as: 'c',
|
|
37
|
-
cond: { $eq: ['$$c.category', 'ITEM'] },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
in: '$$item.amount',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
group: {
|
|
47
|
-
_id: '$productId',
|
|
48
|
-
totalSold: { $sum: '$quantity' },
|
|
49
|
-
totalRevenue: { $sum: '$itemAmount' },
|
|
50
|
-
},
|
|
51
|
-
matchAfterGroup: {
|
|
52
|
-
totalSold: { $gt: 0 },
|
|
53
|
-
},
|
|
54
|
-
sort: { totalSold: -1 },
|
|
55
|
-
limit,
|
|
56
|
-
});
|
|
17
|
+
const topProducts = await modules.orders.positions.getTopProducts(orderIds, { limit });
|
|
57
18
|
const normalizedTopSellingProducts = await Promise.all(topProducts.map(async (p) => {
|
|
58
|
-
const product = await getNormalizedProductDetails(p.
|
|
19
|
+
const product = await getNormalizedProductDetails(p.productId, context);
|
|
59
20
|
return {
|
|
60
|
-
productId: p.
|
|
21
|
+
productId: p.productId?.toString?.() ?? null,
|
|
61
22
|
product,
|
|
62
23
|
totalSold: p.totalSold,
|
|
63
24
|
totalRevenue: p.totalRevenue,
|
|
@@ -76,7 +76,7 @@ export default function getUserCart(context: Context, params: Params<'GET_CART'>
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -76,7 +76,7 @@ export default function listOrders(context: Context, params: Params<'LIST'>): Pr
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -76,7 +76,7 @@ export default function payOrder(context: Context, params: Params<'PAY_ORDER'>):
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -76,7 +76,7 @@ export default function rejectOrder(context: Context, params: Params<'REJECT_ORD
|
|
|
76
76
|
countryCode: string;
|
|
77
77
|
currencyCode: string;
|
|
78
78
|
deliveryId?: string;
|
|
79
|
-
|
|
79
|
+
fulfilled?: Date;
|
|
80
80
|
ordered?: Date;
|
|
81
81
|
orderNumber?: string;
|
|
82
82
|
originEnrollmentId?: string;
|
|
@@ -2,13 +2,9 @@ import { getProviderConfig } from "../utils/getProviderConfig.js";
|
|
|
2
2
|
export default async function listProviders(context, params) {
|
|
3
3
|
const { providerType, typeFilter, queryString } = params;
|
|
4
4
|
const config = getProviderConfig(context, providerType);
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const regex = new RegExp(queryString, 'i');
|
|
10
|
-
selector.$or = [{ _id: regex }, { adapterKey: regex }];
|
|
11
|
-
}
|
|
12
|
-
const providers = await config.module.findProviders(selector);
|
|
5
|
+
const providers = await config.module.findProviders({
|
|
6
|
+
type: typeFilter,
|
|
7
|
+
queryString,
|
|
8
|
+
});
|
|
13
9
|
return { providers };
|
|
14
10
|
}
|