@unchainedshop/api 4.2.2 → 4.3.1
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/express/chatHandler.d.ts.map +1 -1
- package/lib/express/chatHandler.js +1 -3
- package/lib/express/chatHandler.js.map +1 -1
- package/lib/express/index.d.ts.map +1 -1
- package/lib/express/index.js +1 -1
- package/lib/express/index.js.map +1 -1
- package/lib/fastify/chatHandler.d.ts.map +1 -1
- package/lib/fastify/chatHandler.js +1 -3
- package/lib/fastify/chatHandler.js.map +1 -1
- package/lib/fastify/ercMetadataHandler.d.ts.map +1 -1
- package/lib/fastify/ercMetadataHandler.js +7 -4
- package/lib/fastify/ercMetadataHandler.js.map +1 -1
- package/lib/fastify/index.js +1 -1
- package/lib/fastify/index.js.map +1 -1
- package/lib/loaders/index.d.ts +27 -1
- package/lib/loaders/index.d.ts.map +1 -1
- package/lib/loaders/index.js +10 -2
- package/lib/loaders/index.js.map +1 -1
- package/lib/loaders/productBySKULoader.d.ts +10 -0
- package/lib/loaders/productBySKULoader.d.ts.map +1 -0
- package/lib/loaders/productBySKULoader.js +16 -0
- package/lib/loaders/productBySKULoader.js.map +1 -0
- package/lib/loaders/productVariationByKeyLoader.d.ts +12 -0
- package/lib/loaders/productVariationByKeyLoader.d.ts.map +1 -0
- package/lib/loaders/productVariationByKeyLoader.js +14 -0
- package/lib/loaders/productVariationByKeyLoader.js.map +1 -0
- package/lib/loaders/productVariationLoader.d.ts +10 -0
- package/lib/loaders/productVariationLoader.d.ts.map +1 -0
- package/lib/loaders/productVariationLoader.js +13 -0
- package/lib/loaders/productVariationLoader.js.map +1 -0
- package/lib/loaders/productVariationTextLoader.d.ts +14 -0
- package/lib/loaders/productVariationTextLoader.d.ts.map +1 -0
- package/lib/loaders/productVariationTextLoader.js +24 -0
- package/lib/loaders/productVariationTextLoader.js.map +1 -0
- package/lib/loaders/quotationLoader.d.ts +10 -0
- package/lib/loaders/quotationLoader.d.ts.map +1 -0
- package/lib/loaders/quotationLoader.js +13 -0
- package/lib/loaders/quotationLoader.js.map +1 -0
- package/lib/mcp/resources/localization.d.ts.map +1 -1
- package/lib/mcp/resources/localization.js +0 -15
- package/lib/mcp/resources/localization.js.map +1 -1
- package/lib/mongo-store.d.ts +94 -0
- package/lib/mongo-store.d.ts.map +1 -0
- package/lib/mongo-store.js +368 -0
- package/lib/mongo-store.js.map +1 -0
- package/lib/resolvers/type/delivery-provider-interface.d.ts +18 -0
- package/lib/resolvers/type/delivery-provider-interface.d.ts.map +1 -0
- package/lib/resolvers/type/delivery-provider-interface.js +48 -0
- package/lib/resolvers/type/delivery-provider-interface.js.map +1 -0
- package/lib/resolvers/type/delivery-provider-pickup-types.d.ts +20 -0
- package/lib/resolvers/type/delivery-provider-pickup-types.d.ts.map +1 -0
- package/lib/resolvers/type/delivery-provider-pickup-types.js +10 -0
- package/lib/resolvers/type/delivery-provider-pickup-types.js.map +1 -0
- package/lib/resolvers/type/delivery-provider-shipping-types.d.ts +17 -0
- package/lib/resolvers/type/delivery-provider-shipping-types.d.ts.map +1 -0
- package/lib/resolvers/type/delivery-provider-shipping-types.js +5 -0
- package/lib/resolvers/type/delivery-provider-shipping-types.js.map +1 -0
- package/lib/resolvers/type/delivery-provider-types.d.ts +7 -11
- package/lib/resolvers/type/delivery-provider-types.d.ts.map +1 -1
- package/lib/resolvers/type/delivery-provider-types.js +17 -43
- package/lib/resolvers/type/delivery-provider-types.js.map +1 -1
- package/lib/resolvers/type/index.d.ts +40 -11
- package/lib/resolvers/type/index.d.ts.map +1 -1
- package/lib/resolvers/type/index.js +4 -0
- package/lib/resolvers/type/index.js.map +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-item-types.js +2 -3
- package/lib/resolvers/type/order/order-item-types.js.map +1 -1
- package/lib/resolvers/type/price-types.d.ts.map +1 -1
- package/lib/resolvers/type/price-types.js +19 -5
- package/lib/resolvers/type/price-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-vector.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-vector.js +4 -6
- package/lib/resolvers/type/product/product-variation-assignment-vector.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-option-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-variation-option-types.js +2 -3
- package/lib/resolvers/type/product/product-variation-option-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-variation-types.js +2 -3
- package/lib/resolvers/type/product/product-variation-types.js.map +1 -1
- package/lib/schema/types/delivery.d.ts.map +1 -1
- package/lib/schema/types/delivery.js +38 -1
- package/lib/schema/types/delivery.js.map +1 -1
- package/lib/schema/types/order/delivery.d.ts.map +1 -1
- package/lib/schema/types/order/delivery.js +3 -2
- package/lib/schema/types/order/delivery.js.map +1 -1
- package/lib/schema/types/order/pick-up-location.d.ts.map +1 -1
- package/lib/schema/types/order/pick-up-location.js +1 -2
- package/lib/schema/types/order/pick-up-location.js.map +1 -1
- package/package.json +11 -14
- package/src/express/chatHandler.ts +3 -8
- package/src/express/index.ts +3 -2
- package/src/fastify/chatHandler.ts +3 -8
- package/src/fastify/ercMetadataHandler.ts +9 -4
- package/src/fastify/index.ts +1 -1
- package/src/loaders/index.ts +11 -2
- package/src/loaders/productVariationByKeyLoader.ts +20 -0
- package/src/loaders/productVariationLoader.ts +19 -0
- package/src/loaders/productVariationTextLoader.ts +37 -0
- package/src/loaders/quotationLoader.ts +19 -0
- package/src/mcp/resources/localization.ts +0 -15
- package/src/mongo-store.ts +500 -0
- package/src/resolvers/type/delivery-provider-interface.ts +55 -0
- package/src/resolvers/type/delivery-provider-pickup-types.ts +12 -0
- package/src/resolvers/type/delivery-provider-shipping-types.ts +5 -0
- package/src/resolvers/type/delivery-provider-types.ts +22 -68
- package/src/resolvers/type/index.ts +4 -0
- package/src/resolvers/type/order/order-item-types.ts +2 -3
- package/src/resolvers/type/price-types.ts +19 -5
- package/src/resolvers/type/product/product-variation-assignment-vector.ts +4 -6
- package/src/resolvers/type/product/product-variation-option-types.ts +2 -3
- package/src/resolvers/type/product/product-variation-types.ts +2 -3
- package/src/schema/types/delivery.ts +38 -1
- package/src/schema/types/order/delivery.ts +3 -2
- package/src/schema/types/order/pick-up-location.ts +1 -2
- /package/src/loaders/{productLoaderBySKU.ts → productBySKULoader.ts} +0 -0
|
@@ -19,11 +19,25 @@ export const Price = {
|
|
|
19
19
|
},
|
|
20
20
|
amount(obj: PriceType) {
|
|
21
21
|
if (obj.amount) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
/*
|
|
23
|
+
Why toFixed(0) Is Actually Reliable
|
|
24
|
+
For integer rounding specifically:
|
|
25
|
+
|
|
26
|
+
Half-values are exact: Numbers like 0.5, 1.5, 2.5 can be represented exactly in binary floating-point (they're powers of 2), so they round correctly.
|
|
27
|
+
Floating-point errors are tiny: Even with calculation errors, they're usually on the order of 0.0000000001, which won't affect rounding to the nearest integer.
|
|
28
|
+
Integer boundaries are far apart: Unlike toFixed(2) where the difference between 1.004 and 1.005 matters, for toFixed(0) you need errors approaching 0.5 to cause problems.
|
|
29
|
+
|
|
30
|
+
Theoretical Edge Cases
|
|
31
|
+
The only cases where toFixed(0) might fail would be:
|
|
32
|
+
javascript// Extremely contrived calculation that should equal exactly 0.5
|
|
33
|
+
// but might be 0.49999999999999994 (would round to 0 instead of 1)
|
|
34
|
+
|
|
35
|
+
// Very large numbers where precision is lost entirely
|
|
36
|
+
(9007199254740992.5).toFixed(0) // Might have issues past MAX_SAFE_INTEGER
|
|
37
|
+
|
|
38
|
+
// But in practice, these are incredibly rare
|
|
39
|
+
*/
|
|
40
|
+
return Math.round(obj.amount).toFixed(0);
|
|
27
41
|
}
|
|
28
42
|
return 0;
|
|
29
43
|
},
|
|
@@ -17,9 +17,8 @@ export interface ProductVariationAssignmentVectorHelperTypes {
|
|
|
17
17
|
export const ProductVariationAssignmentVector: ProductVariationAssignmentVectorHelperTypes = {
|
|
18
18
|
_id: ({ product, key, value }) => `${product._id}:${key}=${value}`,
|
|
19
19
|
|
|
20
|
-
option: async (obj, _, {
|
|
21
|
-
|
|
22
|
-
const productVariation = await modules.products.variations.findProductVariationByKey({
|
|
20
|
+
option: async (obj, _, { loaders }) => {
|
|
21
|
+
const productVariation = await loaders.productVariationByKeyLoader.load({
|
|
23
22
|
productId: obj.product._id,
|
|
24
23
|
key: obj.key,
|
|
25
24
|
});
|
|
@@ -32,9 +31,8 @@ export const ProductVariationAssignmentVector: ProductVariationAssignmentVectorH
|
|
|
32
31
|
};
|
|
33
32
|
},
|
|
34
33
|
|
|
35
|
-
variation: (obj, _, {
|
|
36
|
-
|
|
37
|
-
return modules.products.variations.findProductVariationByKey({
|
|
34
|
+
variation: (obj, _, { loaders }) => {
|
|
35
|
+
return loaders.productVariationByKeyLoader.load({
|
|
38
36
|
productId: obj?.product?._id,
|
|
39
37
|
key: obj?.key,
|
|
40
38
|
});
|
|
@@ -20,9 +20,8 @@ export const ProductVariationOption: ProductVariationOptionHelperTypes = {
|
|
|
20
20
|
return obj.productVariationOption;
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
texts: async (obj, { forceLocale }, {
|
|
24
|
-
|
|
25
|
-
return modules.products.variations.texts.findLocalizedVariationText({
|
|
23
|
+
texts: async (obj, { forceLocale }, { loaders, locale }) => {
|
|
24
|
+
return loaders.productVariationTextLoader.load({
|
|
26
25
|
productVariationId: obj._id,
|
|
27
26
|
productVariationOptionValue: obj.productVariationOption,
|
|
28
27
|
locale: forceLocale ? new Intl.Locale(forceLocale) : locale,
|
|
@@ -28,9 +28,8 @@ export const ProductVariation: ProductVariationHelperTypes = {
|
|
|
28
28
|
}));
|
|
29
29
|
},
|
|
30
30
|
|
|
31
|
-
texts: async (obj, { forceLocale }, {
|
|
32
|
-
|
|
33
|
-
return modules.products.variations.texts.findLocalizedVariationText({
|
|
31
|
+
texts: async (obj, { forceLocale }, { loaders, locale }) => {
|
|
32
|
+
return loaders.productVariationTextLoader.load({
|
|
34
33
|
productVariationId: obj._id,
|
|
35
34
|
locale: forceLocale ? new Intl.Locale(forceLocale) : locale,
|
|
36
35
|
});
|
|
@@ -25,7 +25,44 @@ export default [
|
|
|
25
25
|
WRONG_CREDENTIALS
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
interface DeliveryProvider {
|
|
29
|
+
_id: ID!
|
|
30
|
+
created: DateTime
|
|
31
|
+
updated: DateTime
|
|
32
|
+
deleted: DateTime
|
|
33
|
+
type: DeliveryProviderType
|
|
34
|
+
interface: DeliveryInterface
|
|
35
|
+
configuration: JSON
|
|
36
|
+
configurationError: DeliveryProviderError
|
|
37
|
+
isActive: Boolean
|
|
38
|
+
simulatedPrice(
|
|
39
|
+
currencyCode: String
|
|
40
|
+
useNetPrice: Boolean = false
|
|
41
|
+
orderId: ID
|
|
42
|
+
context: JSON
|
|
43
|
+
): Price @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type DeliveryProviderPickUp implements DeliveryProvider @cacheControl(maxAge: 60) {
|
|
47
|
+
_id: ID!
|
|
48
|
+
created: DateTime
|
|
49
|
+
updated: DateTime
|
|
50
|
+
deleted: DateTime
|
|
51
|
+
type: DeliveryProviderType
|
|
52
|
+
interface: DeliveryInterface
|
|
53
|
+
configuration: JSON
|
|
54
|
+
configurationError: DeliveryProviderError
|
|
55
|
+
isActive: Boolean
|
|
56
|
+
simulatedPrice(
|
|
57
|
+
currencyCode: String
|
|
58
|
+
useNetPrice: Boolean = false
|
|
59
|
+
orderId: ID
|
|
60
|
+
context: JSON
|
|
61
|
+
): Price @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
62
|
+
pickUpLocations: [PickUpLocation!]!
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type DeliveryProviderShipping implements DeliveryProvider @cacheControl(maxAge: 60) {
|
|
29
66
|
_id: ID!
|
|
30
67
|
created: DateTime
|
|
31
68
|
updated: DateTime
|
|
@@ -33,8 +33,9 @@ export default [
|
|
|
33
33
|
delivered: DateTime
|
|
34
34
|
fee: Price
|
|
35
35
|
discounts: [OrderDeliveryDiscount!]
|
|
36
|
-
pickUpLocations: [
|
|
37
|
-
|
|
36
|
+
pickUpLocations: [PickUpLocation!]!
|
|
37
|
+
@deprecated(reason: "Use DeliveryProvider.pickupLocations instead")
|
|
38
|
+
activePickUpLocation: PickUpLocation
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
type OrderDeliveryShipping implements OrderDelivery {
|
|
File without changes
|