@unchainedshop/api 4.4.0 → 4.5.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/lib/api-index.js +3 -0
- 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/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/order/handlers/getTopCustomers.d.ts +5 -5
- package/lib/mcp/tools/order/handlers/getTopCustomers.js +4 -54
- package/lib/mcp/tools/order/handlers/getTopProducts.d.ts +3 -3
- package/lib/mcp/tools/order/handlers/getTopProducts.js +3 -42
- package/lib/mcp/tools/provider/handlers/listProviders.js +4 -8
- 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/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/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/users/removeUser.js +1 -1
- 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/utils/getConfiguredTags.d.ts +1 -0
- package/lib/utils/getConfiguredTags.js +9 -0
- package/package.json +7 -17
|
@@ -96,7 +96,7 @@ declare const types: {
|
|
|
96
96
|
limit: number;
|
|
97
97
|
offset: number;
|
|
98
98
|
includeInactive: boolean;
|
|
99
|
-
}, {
|
|
99
|
+
}, { services }: import("../../context.ts").Context): Promise<(typeof product)[]>;
|
|
100
100
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
101
101
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
102
102
|
forceLocale?: string;
|
|
@@ -156,7 +156,7 @@ declare const types: {
|
|
|
156
156
|
limit: number;
|
|
157
157
|
offset: number;
|
|
158
158
|
includeInactive: boolean;
|
|
159
|
-
}, {
|
|
159
|
+
}, { services }: import("../../context.ts").Context): Promise<(typeof product)[]>;
|
|
160
160
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
161
161
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
162
162
|
forceLocale?: string;
|
|
@@ -174,13 +174,7 @@ declare const types: {
|
|
|
174
174
|
label: string;
|
|
175
175
|
version: string;
|
|
176
176
|
} | null;
|
|
177
|
-
simulatedPrice(deliveryProvider: any, args: any,
|
|
178
|
-
amount: number;
|
|
179
|
-
currencyCode: string;
|
|
180
|
-
countryCode: string;
|
|
181
|
-
isTaxable: boolean;
|
|
182
|
-
isNetPrice: any;
|
|
183
|
-
} | null>;
|
|
177
|
+
simulatedPrice(deliveryProvider: any, args: any, requestContext: import("../../context.ts").Context): Promise<import("@unchainedshop/core/lib/services/simulateDeliveryPricing.js").SimulatedDeliveryPrice | null>;
|
|
184
178
|
__resolveType: (provider: import("@unchainedshop/core-delivery").DeliveryProvider) => Promise<"DeliveryProviderPickUp" | "DeliveryProviderShipping">;
|
|
185
179
|
};
|
|
186
180
|
DeliveryProviderPickUp: {
|
|
@@ -192,13 +186,7 @@ declare const types: {
|
|
|
192
186
|
label: string;
|
|
193
187
|
version: string;
|
|
194
188
|
} | null;
|
|
195
|
-
simulatedPrice(deliveryProvider: any, args: any,
|
|
196
|
-
amount: number;
|
|
197
|
-
currencyCode: string;
|
|
198
|
-
countryCode: string;
|
|
199
|
-
isTaxable: boolean;
|
|
200
|
-
isNetPrice: any;
|
|
201
|
-
} | null>;
|
|
189
|
+
simulatedPrice(deliveryProvider: any, args: any, requestContext: import("../../context.ts").Context): Promise<import("@unchainedshop/core/lib/services/simulateDeliveryPricing.js").SimulatedDeliveryPrice | null>;
|
|
202
190
|
};
|
|
203
191
|
DeliveryProviderShipping: {
|
|
204
192
|
isActive(deliveryProvider: any, _: any, context: import("../../context.ts").Context): Promise<boolean>;
|
|
@@ -208,13 +196,7 @@ declare const types: {
|
|
|
208
196
|
label: string;
|
|
209
197
|
version: string;
|
|
210
198
|
} | null;
|
|
211
|
-
simulatedPrice(deliveryProvider: any, args: any,
|
|
212
|
-
amount: number;
|
|
213
|
-
currencyCode: string;
|
|
214
|
-
countryCode: string;
|
|
215
|
-
isTaxable: boolean;
|
|
216
|
-
isNetPrice: any;
|
|
217
|
-
} | null>;
|
|
199
|
+
simulatedPrice(deliveryProvider: any, args: any, requestContext: import("../../context.ts").Context): Promise<import("@unchainedshop/core/lib/services/simulateDeliveryPricing.js").SimulatedDeliveryPrice | null>;
|
|
218
200
|
};
|
|
219
201
|
Dimensions: {
|
|
220
202
|
weight({ weightInGram }: {
|
|
@@ -414,13 +396,7 @@ declare const types: {
|
|
|
414
396
|
};
|
|
415
397
|
OrderItem: {
|
|
416
398
|
discounts(orderPosition: import("@unchainedshop/core-orders").OrderPosition, _: any, context: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderPositionDiscount[]>;
|
|
417
|
-
dispatches(orderPosition: import("@unchainedshop/core-orders").OrderPosition, _: never, {
|
|
418
|
-
_id: string;
|
|
419
|
-
deliveryProvider: import("@unchainedshop/core-delivery").DeliveryProvider;
|
|
420
|
-
warehousingProvider: import("@unchainedshop/core-warehousing").WarehousingProvider;
|
|
421
|
-
shipping: Date;
|
|
422
|
-
earliestDelivery: Date;
|
|
423
|
-
}[] | null>;
|
|
399
|
+
dispatches(orderPosition: import("@unchainedshop/core-orders").OrderPosition, _: never, { services }: import("../../context.ts").Context): Promise<import("@unchainedshop/core/lib/services/resolveOrderItemDispatches.js").OrderItemDispatch[] | null>;
|
|
424
400
|
order(orderPosition: import("@unchainedshop/core-orders").OrderPosition, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").Order>;
|
|
425
401
|
originalProduct(orderPosition: import("@unchainedshop/core-orders").OrderPosition, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-products").Product>;
|
|
426
402
|
product(orderPosition: import("@unchainedshop/core-orders").OrderPosition, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-products").Product>;
|
|
@@ -506,13 +482,7 @@ declare const types: {
|
|
|
506
482
|
orderId: any;
|
|
507
483
|
useNetPrice: any;
|
|
508
484
|
context: any;
|
|
509
|
-
}, requestContext: import("../../context.ts").Context): Promise<
|
|
510
|
-
amount: number;
|
|
511
|
-
currencyCode: string;
|
|
512
|
-
countryCode: string;
|
|
513
|
-
isTaxable: boolean;
|
|
514
|
-
isNetPrice: any;
|
|
515
|
-
} | null>;
|
|
485
|
+
}, requestContext: import("../../context.ts").Context): Promise<import("@unchainedshop/core/lib/services/simulatePaymentPricing.js").SimulatedPaymentPrice | null>;
|
|
516
486
|
};
|
|
517
487
|
PlanProduct: {
|
|
518
488
|
catalogPrice(product: import("@unchainedshop/core-products").Product, { quantity, currencyCode: forcedCurrencyCode }: {
|
|
@@ -561,7 +531,7 @@ declare const types: {
|
|
|
561
531
|
limit: number;
|
|
562
532
|
offset: number;
|
|
563
533
|
includeInactive: boolean;
|
|
564
|
-
}, {
|
|
534
|
+
}, { services }: import("../../context.ts").Context): Promise<(typeof product)[]>;
|
|
565
535
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
566
536
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
567
537
|
forceLocale?: string;
|
|
@@ -600,7 +570,7 @@ declare const types: {
|
|
|
600
570
|
limit: number;
|
|
601
571
|
offset: number;
|
|
602
572
|
includeInactive: boolean;
|
|
603
|
-
}, {
|
|
573
|
+
}, { services }: import("../../context.ts").Context): Promise<(typeof product)[]>;
|
|
604
574
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
605
575
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
606
576
|
forceLocale?: string;
|
|
@@ -732,7 +702,7 @@ declare const types: {
|
|
|
732
702
|
limit: number;
|
|
733
703
|
offset: number;
|
|
734
704
|
includeInactive: boolean;
|
|
735
|
-
}, {
|
|
705
|
+
}, { services }: import("../../context.ts").Context): Promise<(typeof product)[]>;
|
|
736
706
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
737
707
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
738
708
|
forceLocale?: string;
|
|
@@ -797,7 +767,7 @@ declare const types: {
|
|
|
797
767
|
limit: number;
|
|
798
768
|
offset: number;
|
|
799
769
|
includeInactive: boolean;
|
|
800
|
-
}, {
|
|
770
|
+
}, { services }: import("../../context.ts").Context): Promise<(typeof product)[]>;
|
|
801
771
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
802
772
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
803
773
|
forceLocale?: string;
|
|
@@ -806,11 +776,11 @@ declare const types: {
|
|
|
806
776
|
Token: {
|
|
807
777
|
product: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { loaders }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-products").Product>;
|
|
808
778
|
user: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { loaders }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-users").User | null>;
|
|
809
|
-
status: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, {
|
|
779
|
+
status: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { services }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-warehousing").TokenStatus>;
|
|
810
780
|
ercMetadata: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, { forceLocale }: {
|
|
811
781
|
forceLocale: string;
|
|
812
782
|
}, context: import("../../context.ts").Context) => Promise<any>;
|
|
813
|
-
isInvalidateable: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, _params: never,
|
|
783
|
+
isInvalidateable: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, _params: never, { services }: import("../../context.ts").Context) => Promise<boolean>;
|
|
814
784
|
accessKey: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, requestContext: import("../../context.ts").Context) => Promise<string | null>;
|
|
815
785
|
};
|
|
816
786
|
User: import("./user-types.ts").UserHelperTypes;
|
|
@@ -838,7 +808,16 @@ declare const types: {
|
|
|
838
808
|
aaguid: string;
|
|
839
809
|
counter: number;
|
|
840
810
|
mdsMetadata: any;
|
|
841
|
-
}, _: never, { modules }: import("../../context.ts").Context): Promise<
|
|
811
|
+
}, _: never, { modules }: import("../../context.ts").Context): Promise<{
|
|
812
|
+
[key: string]: unknown;
|
|
813
|
+
description?: string;
|
|
814
|
+
icon?: string;
|
|
815
|
+
authenticatorGetInfo?: {
|
|
816
|
+
versions?: string[];
|
|
817
|
+
extensions?: string[];
|
|
818
|
+
options?: Record<string, boolean>;
|
|
819
|
+
};
|
|
820
|
+
} | null>;
|
|
842
821
|
};
|
|
843
822
|
WarehousingProvider: import("./warehousing-provider-types.ts").WarehousingProviderHelperTypes;
|
|
844
823
|
Work: import("./work-types.ts").WorkHelperTypes;
|
|
@@ -857,34 +836,34 @@ declare const types: {
|
|
|
857
836
|
OrderStatistics: {
|
|
858
837
|
newCount: ({ dateRange }: {
|
|
859
838
|
dateRange: any;
|
|
860
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
839
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<number>;
|
|
861
840
|
checkoutCount: ({ dateRange }: {
|
|
862
841
|
dateRange: any;
|
|
863
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
842
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<number>;
|
|
864
843
|
rejectCount: ({ dateRange }: {
|
|
865
844
|
dateRange: any;
|
|
866
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
845
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<number>;
|
|
867
846
|
confirmCount: ({ dateRange }: {
|
|
868
847
|
dateRange: any;
|
|
869
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
848
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<number>;
|
|
870
849
|
fulfillCount: ({ dateRange }: {
|
|
871
850
|
dateRange: any;
|
|
872
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
851
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<number>;
|
|
873
852
|
newRecords: ({ dateRange }: {
|
|
874
853
|
dateRange: any;
|
|
875
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
854
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
876
855
|
checkoutRecords: ({ dateRange }: {
|
|
877
856
|
dateRange: any;
|
|
878
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
857
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
879
858
|
rejectRecords: ({ dateRange }: {
|
|
880
859
|
dateRange: any;
|
|
881
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
860
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
882
861
|
confirmRecords: ({ dateRange }: {
|
|
883
862
|
dateRange: any;
|
|
884
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
863
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
885
864
|
fulfilledRecords: ({ dateRange }: {
|
|
886
865
|
dateRange: any;
|
|
887
|
-
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<
|
|
866
|
+
}, _p: any, { modules }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
888
867
|
};
|
|
889
868
|
};
|
|
890
869
|
export default types;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { File as FileType } from '@unchainedshop/core-files';
|
|
2
2
|
import type { Context } from '../../context.ts';
|
|
3
3
|
export interface MediaHelperTypes {
|
|
4
4
|
url: (language: FileType, params: Record<string, any>, context: Context) => Promise<string | null>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
2
1
|
import { checkAction } from "../../acl.js";
|
|
3
2
|
import { actions } from "../../roles/index.js";
|
|
4
3
|
import { createLogger } from '@unchainedshop/logger';
|
|
5
4
|
const logger = createLogger('unchained:api');
|
|
6
5
|
export const Media = {
|
|
7
6
|
url: async (file, params, context) => {
|
|
8
|
-
const {
|
|
7
|
+
const { services } = context;
|
|
9
8
|
try {
|
|
10
9
|
await checkAction(context, actions.downloadFile, [file, params]);
|
|
11
10
|
if (!file)
|
|
12
11
|
return null;
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
const url = await services.files.createFileDownloadURL({
|
|
13
|
+
file,
|
|
14
|
+
expires: params?.expires,
|
|
15
|
+
params,
|
|
16
|
+
});
|
|
15
17
|
if (!url)
|
|
16
18
|
throw new Error('Could not create download URL');
|
|
17
|
-
return
|
|
19
|
+
return url;
|
|
18
20
|
}
|
|
19
21
|
catch (e) {
|
|
20
22
|
logger.error(e);
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import type { Context } from '../../../context.ts';
|
|
2
|
-
import type { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
3
2
|
import type { Order } from '@unchainedshop/core-orders';
|
|
4
3
|
import type { OrderPosition, OrderPositionDiscount } from '@unchainedshop/core-orders';
|
|
5
4
|
import type { Product } from '@unchainedshop/core-products';
|
|
6
5
|
import type { Quotation } from '@unchainedshop/core-quotations';
|
|
7
|
-
import type { TokenSurrogate
|
|
6
|
+
import type { TokenSurrogate } from '@unchainedshop/core-warehousing';
|
|
8
7
|
import type { Price } from '@unchainedshop/utils';
|
|
9
8
|
export declare const OrderItem: {
|
|
10
9
|
discounts(orderPosition: OrderPosition, _: any, context: Context): Promise<OrderPositionDiscount[]>;
|
|
11
|
-
dispatches(orderPosition: OrderPosition, _: never, {
|
|
12
|
-
_id: string;
|
|
13
|
-
deliveryProvider: DeliveryProvider;
|
|
14
|
-
warehousingProvider: WarehousingProvider;
|
|
15
|
-
shipping: Date;
|
|
16
|
-
earliestDelivery: Date;
|
|
17
|
-
}[] | null>;
|
|
10
|
+
dispatches(orderPosition: OrderPosition, _: never, { services }: Context): Promise<import("@unchainedshop/core/lib/services/resolveOrderItemDispatches.js").OrderItemDispatch[] | null>;
|
|
18
11
|
order(orderPosition: OrderPosition, _: any, { loaders }: Context): Promise<Order>;
|
|
19
12
|
originalProduct(orderPosition: OrderPosition, _: any, { loaders }: Context): Promise<Product>;
|
|
20
13
|
product(orderPosition: OrderPosition, _: any, { loaders }: Context): Promise<Product>;
|
|
@@ -20,43 +20,8 @@ export const OrderItem = {
|
|
|
20
20
|
}
|
|
21
21
|
return [];
|
|
22
22
|
},
|
|
23
|
-
async dispatches(orderPosition, _, {
|
|
24
|
-
|
|
25
|
-
const order = await loaders.orderLoader.load({
|
|
26
|
-
orderId: orderPosition.orderId,
|
|
27
|
-
});
|
|
28
|
-
const { countryCode, userId } = order;
|
|
29
|
-
const orderDelivery = order.deliveryId &&
|
|
30
|
-
(await modules.orders.deliveries.findDelivery({
|
|
31
|
-
orderDeliveryId: order.deliveryId,
|
|
32
|
-
}));
|
|
33
|
-
if (!orderDelivery)
|
|
34
|
-
return null;
|
|
35
|
-
const deliveryProvider = await loaders.deliveryProviderLoader.load({
|
|
36
|
-
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
37
|
-
});
|
|
38
|
-
const product = await loaders.productLoader.load({
|
|
39
|
-
productId: orderPosition.productId,
|
|
40
|
-
});
|
|
41
|
-
if (!deliveryProvider || !product)
|
|
42
|
-
return null;
|
|
43
|
-
return Promise.all(scheduling.map(async (schedule) => {
|
|
44
|
-
const warehousingProvider = await loaders.warehousingProviderLoader.load({
|
|
45
|
-
warehousingProviderId: schedule.warehousingProviderId,
|
|
46
|
-
});
|
|
47
|
-
const context = {
|
|
48
|
-
warehousingProvider,
|
|
49
|
-
deliveryProvider,
|
|
50
|
-
product,
|
|
51
|
-
quantity: orderPosition.quantity,
|
|
52
|
-
countryCode,
|
|
53
|
-
userId,
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
...context,
|
|
57
|
-
...schedule,
|
|
58
|
-
};
|
|
59
|
-
}));
|
|
23
|
+
async dispatches(orderPosition, _, { services }) {
|
|
24
|
+
return services.orders.resolveOrderItemDispatches({ orderPosition });
|
|
60
25
|
},
|
|
61
26
|
async order(orderPosition, _, { loaders }) {
|
|
62
27
|
return loaders.orderLoader.load({
|
|
@@ -2,32 +2,32 @@ import type { Context } from '../../../context.ts';
|
|
|
2
2
|
export declare const OrderStatistics: {
|
|
3
3
|
newCount: ({ dateRange }: {
|
|
4
4
|
dateRange: any;
|
|
5
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
5
|
+
}, _p: any, { modules }: Context) => Promise<number>;
|
|
6
6
|
checkoutCount: ({ dateRange }: {
|
|
7
7
|
dateRange: any;
|
|
8
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
8
|
+
}, _p: any, { modules }: Context) => Promise<number>;
|
|
9
9
|
rejectCount: ({ dateRange }: {
|
|
10
10
|
dateRange: any;
|
|
11
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
11
|
+
}, _p: any, { modules }: Context) => Promise<number>;
|
|
12
12
|
confirmCount: ({ dateRange }: {
|
|
13
13
|
dateRange: any;
|
|
14
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
14
|
+
}, _p: any, { modules }: Context) => Promise<number>;
|
|
15
15
|
fulfillCount: ({ dateRange }: {
|
|
16
16
|
dateRange: any;
|
|
17
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
17
|
+
}, _p: any, { modules }: Context) => Promise<number>;
|
|
18
18
|
newRecords: ({ dateRange }: {
|
|
19
19
|
dateRange: any;
|
|
20
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
20
|
+
}, _p: any, { modules }: Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
21
21
|
checkoutRecords: ({ dateRange }: {
|
|
22
22
|
dateRange: any;
|
|
23
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
23
|
+
}, _p: any, { modules }: Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
24
24
|
rejectRecords: ({ dateRange }: {
|
|
25
25
|
dateRange: any;
|
|
26
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
26
|
+
}, _p: any, { modules }: Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
27
27
|
confirmRecords: ({ dateRange }: {
|
|
28
28
|
dateRange: any;
|
|
29
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
29
|
+
}, _p: any, { modules }: Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
30
30
|
fulfilledRecords: ({ dateRange }: {
|
|
31
31
|
dateRange: any;
|
|
32
|
-
}, _p: any, { modules }: Context) => Promise<
|
|
32
|
+
}, _p: any, { modules }: Context) => Promise<import("@unchainedshop/core-orders").OrderStatisticsRecord[]>;
|
|
33
33
|
};
|
|
@@ -1,66 +1,12 @@
|
|
|
1
|
-
function buildDateMatch(dateField, dateRange) {
|
|
2
|
-
if (!dateRange?.start && !dateRange?.end)
|
|
3
|
-
return { [dateField]: { $exists: true } };
|
|
4
|
-
const rangeMatch = {};
|
|
5
|
-
if (dateRange?.start)
|
|
6
|
-
rangeMatch.$gte = new Date(dateRange.start);
|
|
7
|
-
if (dateRange?.end)
|
|
8
|
-
rangeMatch.$lte = new Date(dateRange.end);
|
|
9
|
-
return { [dateField]: rangeMatch };
|
|
10
|
-
}
|
|
11
|
-
async function aggregateOrders(modules, dateField, dateRange, options) {
|
|
12
|
-
const match = buildDateMatch(dateField, dateRange);
|
|
13
|
-
const pipeline = [{ $match: match }];
|
|
14
|
-
if (options?.includeCarts) {
|
|
15
|
-
match.status = null;
|
|
16
|
-
match.orderNumber = null;
|
|
17
|
-
}
|
|
18
|
-
if (options?.includeAmount) {
|
|
19
|
-
pipeline.push({
|
|
20
|
-
$addFields: {
|
|
21
|
-
orderTotal: {
|
|
22
|
-
$reduce: {
|
|
23
|
-
input: { $ifNull: ['$calculation', []] },
|
|
24
|
-
initialValue: 0,
|
|
25
|
-
in: { $add: ['$$value', { $ifNull: ['$$this.amount', 0] }] },
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
pipeline.push({
|
|
31
|
-
$group: {
|
|
32
|
-
_id: {
|
|
33
|
-
date: { $dateToString: { format: '%Y-%m-%d', date: `$${dateField}` } },
|
|
34
|
-
currency: '$currencyCode',
|
|
35
|
-
},
|
|
36
|
-
totalAmount: { $sum: '$orderTotal' },
|
|
37
|
-
count: { $sum: 1 },
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
pipeline.push({
|
|
41
|
-
$project: {
|
|
42
|
-
_id: 0,
|
|
43
|
-
date: '$_id.date',
|
|
44
|
-
total: { amount: '$totalAmount', currencyCode: '$_id.currency' },
|
|
45
|
-
count: 1,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
pipeline.push({ $sort: { date: 1 } });
|
|
49
|
-
return modules.orders.aggregateOrders({ pipeline });
|
|
50
|
-
}
|
|
51
|
-
pipeline.push({ $count: 'count' });
|
|
52
|
-
const result = await modules.orders.aggregateOrders({ pipeline });
|
|
53
|
-
return result[0]?.count ?? 0;
|
|
54
|
-
}
|
|
55
1
|
export const OrderStatistics = {
|
|
56
|
-
newCount: async ({ dateRange }, _p, { modules }) =>
|
|
57
|
-
checkoutCount: async ({ dateRange }, _p, { modules }) =>
|
|
58
|
-
rejectCount: async ({ dateRange }, _p, { modules }) =>
|
|
59
|
-
confirmCount: async ({ dateRange }, _p, { modules }) =>
|
|
60
|
-
fulfillCount: async ({ dateRange }, _p, { modules }) =>
|
|
61
|
-
newRecords: async ({ dateRange }, _p, { modules }) =>
|
|
62
|
-
checkoutRecords: async ({ dateRange }, _p, { modules }) =>
|
|
63
|
-
rejectRecords: async ({ dateRange }, _p, { modules }) =>
|
|
64
|
-
confirmRecords: async ({ dateRange }, _p, { modules }) =>
|
|
65
|
-
fulfilledRecords: async ({ dateRange }, _p, { modules }) =>
|
|
2
|
+
newCount: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.countByDateField('created', dateRange, { includeCarts: true }),
|
|
3
|
+
checkoutCount: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.countByDateField('ordered', dateRange),
|
|
4
|
+
rejectCount: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.countByDateField('rejected', dateRange),
|
|
5
|
+
confirmCount: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.countByDateField('confirmed', dateRange),
|
|
6
|
+
fulfillCount: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.countByDateField('fullfilled', dateRange),
|
|
7
|
+
newRecords: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.aggregateByDateField('created', dateRange, { includeCarts: true }),
|
|
8
|
+
checkoutRecords: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.aggregateByDateField('ordered', dateRange),
|
|
9
|
+
rejectRecords: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.aggregateByDateField('rejected', dateRange),
|
|
10
|
+
confirmRecords: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.aggregateByDateField('confirmed', dateRange),
|
|
11
|
+
fulfilledRecords: async ({ dateRange }, _p, { modules }) => modules.orders.statistics.aggregateByDateField('fullfilled', dateRange),
|
|
66
12
|
};
|
|
@@ -13,11 +13,5 @@ export declare const PaymentProvider: {
|
|
|
13
13
|
orderId: any;
|
|
14
14
|
useNetPrice: any;
|
|
15
15
|
context: any;
|
|
16
|
-
}, requestContext: Context): Promise<
|
|
17
|
-
amount: number;
|
|
18
|
-
currencyCode: string;
|
|
19
|
-
countryCode: string;
|
|
20
|
-
isTaxable: boolean;
|
|
21
|
-
isNetPrice: any;
|
|
22
|
-
} | null>;
|
|
16
|
+
}, requestContext: Context): Promise<import("@unchainedshop/core/lib/services/simulatePaymentPricing.js").SimulatedPaymentPrice | null>;
|
|
23
17
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaymentDirector
|
|
1
|
+
import { PaymentDirector } from '@unchainedshop/core';
|
|
2
2
|
export const PaymentProvider = {
|
|
3
3
|
interface(provider) {
|
|
4
4
|
const Adapter = PaymentDirector.getAdapter(provider.adapterKey);
|
|
@@ -19,28 +19,18 @@ export const PaymentProvider = {
|
|
|
19
19
|
return adapter.isActive();
|
|
20
20
|
},
|
|
21
21
|
async simulatedPrice(paymentProvider, { currencyCode: forcedCurrencyCode, orderId, useNetPrice, context: providerContext }, requestContext) {
|
|
22
|
-
const { loaders, countryCode, user } = requestContext;
|
|
23
|
-
|
|
22
|
+
const { loaders, services, countryCode, user } = requestContext;
|
|
23
|
+
if (!user)
|
|
24
|
+
return null;
|
|
25
|
+
const order = orderId ? await loaders.orderLoader.load({ orderId }) : undefined;
|
|
24
26
|
const currencyCode = forcedCurrencyCode || order?.currencyCode || requestContext.currencyCode;
|
|
25
|
-
|
|
27
|
+
return services.payment.simulatePaymentPricing({
|
|
26
28
|
countryCode,
|
|
27
29
|
currencyCode,
|
|
28
30
|
provider: paymentProvider,
|
|
29
31
|
order,
|
|
30
32
|
providerContext,
|
|
31
33
|
user,
|
|
32
|
-
};
|
|
33
|
-
const calculated = await PaymentPricingDirector.rebuildCalculation(pricingContext, requestContext);
|
|
34
|
-
if (!calculated || !calculated.length)
|
|
35
|
-
return null;
|
|
36
|
-
const pricing = PaymentPricingDirector.calculationSheet(pricingContext, calculated);
|
|
37
|
-
const orderPrice = pricing.total({ useNetPrice });
|
|
38
|
-
return {
|
|
39
|
-
amount: orderPrice.amount,
|
|
40
|
-
currencyCode: orderPrice.currencyCode,
|
|
41
|
-
countryCode,
|
|
42
|
-
isTaxable: pricing.taxSum() > 0,
|
|
43
|
-
isNetPrice: useNetPrice,
|
|
44
|
-
};
|
|
34
|
+
}, { useNetPrice });
|
|
45
35
|
},
|
|
46
36
|
};
|
|
@@ -47,7 +47,7 @@ export declare const BundleProduct: {
|
|
|
47
47
|
limit: number;
|
|
48
48
|
offset: number;
|
|
49
49
|
includeInactive: boolean;
|
|
50
|
-
}, {
|
|
50
|
+
}, { services }: import("../../../context.ts").Context): Promise<(typeof product)[]>;
|
|
51
51
|
status(product: import("@unchainedshop/core-products").Product, _: any, { modules }: import("../../../context.ts").Context): import("@unchainedshop/core-products").ProductStatus;
|
|
52
52
|
texts(product: import("@unchainedshop/core-products").Product, { forceLocale, }: {
|
|
53
53
|
forceLocale?: string;
|
|
@@ -54,7 +54,7 @@ export declare const ConfigurableProduct: {
|
|
|
54
54
|
limit: number;
|
|
55
55
|
offset: number;
|
|
56
56
|
includeInactive: boolean;
|
|
57
|
-
}, {
|
|
57
|
+
}, { services }: Context): Promise<(typeof product)[]>;
|
|
58
58
|
status(product: ProductType, _: any, { modules }: Context): import("@unchainedshop/core-products").ProductStatus;
|
|
59
59
|
texts(product: ProductType, { forceLocale, }: {
|
|
60
60
|
forceLocale?: string;
|
|
@@ -27,40 +27,17 @@ export const ConfigurableProduct = {
|
|
|
27
27
|
});
|
|
28
28
|
},
|
|
29
29
|
async simulatedPriceRange(product, { currencyCode: forcedCurrencyCode, quantity, useNetPrice, vectors, includeInactive, }, requestContext) {
|
|
30
|
-
const { countryCode,
|
|
30
|
+
const { countryCode, services } = requestContext;
|
|
31
31
|
const currencyCode = forcedCurrencyCode || requestContext.currencyCode;
|
|
32
|
-
|
|
32
|
+
return services.products.simulateConfigurablePriceRange({
|
|
33
|
+
product,
|
|
34
|
+
currencyCode,
|
|
35
|
+
countryCode,
|
|
36
|
+
quantity,
|
|
37
|
+
useNetPrice,
|
|
38
|
+
vectors,
|
|
33
39
|
includeInactive,
|
|
40
|
+
user: requestContext.user,
|
|
34
41
|
});
|
|
35
|
-
const filteredPrices = (await Promise.all(products.map(async (proxyProduct) => {
|
|
36
|
-
const pricingContext = {
|
|
37
|
-
product: proxyProduct,
|
|
38
|
-
user: requestContext.user,
|
|
39
|
-
countryCode,
|
|
40
|
-
discounts: [],
|
|
41
|
-
currencyCode,
|
|
42
|
-
quantity: quantity || 1,
|
|
43
|
-
};
|
|
44
|
-
const pricing = await services.products.simulateProductPricing(pricingContext);
|
|
45
|
-
if (!pricing)
|
|
46
|
-
return null;
|
|
47
|
-
const unitPrice = pricing.unitPrice({ useNetPrice });
|
|
48
|
-
return {
|
|
49
|
-
...unitPrice,
|
|
50
|
-
isNetPrice: useNetPrice,
|
|
51
|
-
isTaxable: pricing.taxSum() > 0,
|
|
52
|
-
currencyCode: pricing.currencyCode,
|
|
53
|
-
};
|
|
54
|
-
}))).filter(Boolean);
|
|
55
|
-
if (!filteredPrices.length)
|
|
56
|
-
return null;
|
|
57
|
-
const { minPrice, maxPrice } = modules.products.prices.priceRange({
|
|
58
|
-
productId: product._id,
|
|
59
|
-
prices: filteredPrices,
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
minPrice,
|
|
63
|
-
maxPrice,
|
|
64
|
-
};
|
|
65
42
|
},
|
|
66
43
|
};
|
|
@@ -47,7 +47,7 @@ export declare const PlanProduct: {
|
|
|
47
47
|
limit: number;
|
|
48
48
|
offset: number;
|
|
49
49
|
includeInactive: boolean;
|
|
50
|
-
}, {
|
|
50
|
+
}, { services }: Context): Promise<(typeof product)[]>;
|
|
51
51
|
status(product: ProductType, _: any, { modules }: Context): import("@unchainedshop/core-products").ProductStatus;
|
|
52
52
|
texts(product: ProductType, { forceLocale, }: {
|
|
53
53
|
forceLocale?: string;
|
|
@@ -77,7 +77,7 @@ export declare const SimpleProduct: {
|
|
|
77
77
|
limit: number;
|
|
78
78
|
offset: number;
|
|
79
79
|
includeInactive: boolean;
|
|
80
|
-
}, {
|
|
80
|
+
}, { services }: Context): Promise<(typeof product)[]>;
|
|
81
81
|
status(product: Product, _: any, { modules }: Context): import("@unchainedshop/core-products").ProductStatus;
|
|
82
82
|
texts(product: Product, { forceLocale, }: {
|
|
83
83
|
forceLocale?: string;
|
|
@@ -61,7 +61,7 @@ export declare const TokenizedProduct: {
|
|
|
61
61
|
limit: number;
|
|
62
62
|
offset: number;
|
|
63
63
|
includeInactive: boolean;
|
|
64
|
-
}, {
|
|
64
|
+
}, { services }: Context): Promise<(typeof product)[]>;
|
|
65
65
|
status(product: Product, _: any, { modules }: Context): import("@unchainedshop/core-products").ProductStatus;
|
|
66
66
|
texts(product: Product, { forceLocale, }: {
|
|
67
67
|
forceLocale?: string;
|
|
@@ -31,7 +31,7 @@ export declare const Product: {
|
|
|
31
31
|
limit: number;
|
|
32
32
|
offset: number;
|
|
33
33
|
includeInactive: boolean;
|
|
34
|
-
}, {
|
|
34
|
+
}, { services }: Context): Promise<(typeof product)[]>;
|
|
35
35
|
status(product: IProduct, _: any, { modules }: Context): ProductStatus;
|
|
36
36
|
texts(product: IProduct, { forceLocale, }: {
|
|
37
37
|
forceLocale?: string;
|
|
@@ -50,23 +50,13 @@ export const Product = {
|
|
|
50
50
|
async reviewsCount(product, params, { modules }) {
|
|
51
51
|
return modules.products.reviews.count({ ...params, productId: product._id });
|
|
52
52
|
},
|
|
53
|
-
async siblings(product, params, {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
:
|
|
59
|
-
|
|
60
|
-
return [];
|
|
61
|
-
const productIds = await modules.assortments.products.findSiblings({
|
|
62
|
-
productId,
|
|
63
|
-
assortmentIds,
|
|
64
|
-
});
|
|
65
|
-
return modules.products.findProducts({
|
|
66
|
-
productIds,
|
|
67
|
-
includeDrafts: includeInactive,
|
|
68
|
-
limit,
|
|
69
|
-
offset,
|
|
53
|
+
async siblings(product, params, { services }) {
|
|
54
|
+
return services.products.findProductSiblings({
|
|
55
|
+
product,
|
|
56
|
+
assortmentId: params.assortmentId,
|
|
57
|
+
limit: params.limit,
|
|
58
|
+
offset: params.offset,
|
|
59
|
+
includeInactive: params.includeInactive,
|
|
70
60
|
});
|
|
71
61
|
},
|
|
72
62
|
status(product, _, { modules }) {
|