@wix/auto_sdk_ecom_totals-calculator 1.0.121 → 1.0.123

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.
@@ -1,6 +1,6 @@
1
1
  import { HttpClient, NonNullablePaths, MaybeContext, BuildRESTFunction } from '@wix/sdk-types';
2
2
  import { CalculateTotalsOptions, CalculateTotalsResponse } from './index.typings.js';
3
- export { AdditionalFee, AdditionalFeeSource, AdditionalFeeSourceWithLiterals, Address, AddressLocation, AggregatedTaxBreakdown, ApiV1AdditionalFee, ApplicableLineItems, ApplicationError, AppliedDiscount, AppliedDiscountDiscountSourceOneOf, AutoTaxFallbackCalculationDetails, BalanceType, BalanceTypeWithLiterals, Benefit, BenefitQuotaOneOf, CalculateTotalsOptionsCouponOneOf, CalculateTotalsOptionsGiftCardOneOf, CalculateTotalsRequest, CalculateTotalsRequestCouponOneOf, CalculateTotalsRequestGiftCardOneOf, CalculatedItemModifier, CalculatedLineItem, CalculatedPlatformFee, CalculationErrors, CalculationErrorsShippingCalculationErrorOneOf, Carrier, CarrierError, CarrierErrors, CarrierServiceOption, CarrierShippingOption, CatalogReference, ChargeType, ChargeTypeWithLiterals, Coupon, CoveredLineItem, DataFetchType, DataFetchTypeWithLiterals, DeliveryAllocation, DeliveryLogistics, DeliveryTimeSlot, Details, DetailsKindOneOf, Dimensions, DimensionsUnit, DimensionsUnitWithLiterals, DiscountRule, DiscountRuleName, DiscountType, DiscountTypeWithLiterals, ExistingMembership, ExistingMembershipSelection, ExtendedFields, ExternalReference, FallbackReason, FallbackReasonWithLiterals, FieldViolation, FutureMembershipSelection, GiftCard, GiftCardCalculationError, GiftCardInput, Group, InvalidMembership, ItemCombination, ItemCombinationLineItem, ItemModifier, ItemTaxFullDetails, ItemType, ItemTypeItemTypeDataOneOf, ItemTypePreset, ItemTypePresetWithLiterals, JurisdictionType, JurisdictionTypeWithLiterals, LimitedQuota, LimitedQuotaType, LimitedQuotaTypeWithLiterals, LineItem, LineItemCoverage, LineItemDiscount, LineItemPricesData, ManualCalculationReason, ManualCalculationReasonWithLiterals, Membership, MembershipName, MembershipOptions, MembershipPaymentCredits, MembershipSelection, MerchantDiscount, ModifierGroup, MultiCurrencyPrice, OtherCharge, PaymentOptionType, PaymentOptionTypeWithLiterals, PhysicalProperties, PickupDetails, PickupMethod, PickupMethodWithLiterals, PlatformFee, PlatformFeeChargeType, PlatformFeeChargeTypeWithLiterals, PlatformFeeSummary, PriceSummary, PurchasablePlan, QuotaType, QuotaTypeWithLiterals, RateType, RateTypeWithLiterals, Region, RuleType, RuleTypeWithLiterals, Scope, SelectedCarrierServiceOption, SelectedCarrierServiceOptionOtherCharge, SelectedCarrierServiceOptionPrices, SelectedMembership, SelectedMemberships, SelectedShippingOption, ServiceProperties, ShippingInformation, ShippingOption, ShippingPrice, ShippingRegion, StreetAddress, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionSettings, SystemError, TaxBreakdown, TaxCalculationDetails, TaxCalculationDetailsCalculationDetailsOneOf, TaxDetails, TaxRateBreakdown, TaxSummary, TaxableAddress, TaxableAddressTaxableAddressDataOneOf, TaxableAddressType, TaxableAddressTypeWithLiterals, TotalsCalculationEntity, TranslatableString, V1AdditionalFee, V1Membership, V1TaxDetails, ValidatedExistingMemberships, ValidatedPurchasablePlans, ValidationError, WeightUnit, WeightUnitWithLiterals } from './index.typings.js';
3
+ export { AdditionalFee, AdditionalFeeSource, AdditionalFeeSourceWithLiterals, Address, AddressLocation, AggregatedTaxBreakdown, ApiV1AdditionalFee, ApplicableLineItems, ApplicationError, AppliedDiscount, AppliedDiscountDiscountSourceOneOf, AutoTaxFallbackCalculationDetails, BalanceType, BalanceTypeWithLiterals, Benefit, BenefitQuotaOneOf, CalculateTotalsOptionsCouponOneOf, CalculateTotalsOptionsGiftCardOneOf, CalculateTotalsRequest, CalculateTotalsRequestCouponOneOf, CalculateTotalsRequestGiftCardOneOf, CalculatedItemModifier, CalculatedLineItem, CalculatedPlatformFee, CalculationErrors, CalculationErrorsShippingCalculationErrorOneOf, Carrier, CarrierError, CarrierErrors, CarrierServiceOption, CarrierShippingOption, CatalogReference, ChargeType, ChargeTypeWithLiterals, ConvertAndCalculateTotalsOptions, ConvertAndCalculateTotalsRequest, ConvertAndCalculateTotalsResponse, Coupon, CoveredLineItem, DataFetchType, DataFetchTypeWithLiterals, DeliveryAllocation, DeliveryLogistics, DeliveryTimeSlot, Details, DetailsKindOneOf, Dimensions, DimensionsUnit, DimensionsUnitWithLiterals, DiscountRule, DiscountRuleName, DiscountType, DiscountTypeWithLiterals, ExistingMembership, ExistingMembershipSelection, ExtendedFields, ExternalReference, FallbackReason, FallbackReasonWithLiterals, FieldViolation, FutureMembershipSelection, GiftCard, GiftCardCalculationError, GiftCardInput, Group, InvalidMembership, ItemCombination, ItemCombinationLineItem, ItemModifier, ItemTaxFullDetails, ItemType, ItemTypeItemTypeDataOneOf, ItemTypePreset, ItemTypePresetWithLiterals, JurisdictionType, JurisdictionTypeWithLiterals, LimitedQuota, LimitedQuotaType, LimitedQuotaTypeWithLiterals, LineItem, LineItemCoverage, LineItemDiscount, LineItemPricesData, ManualCalculationReason, ManualCalculationReasonWithLiterals, Membership, MembershipName, MembershipOptions, MembershipPaymentCredits, MembershipSelection, MerchantDiscount, ModifierGroup, MultiCurrencyPrice, OtherCharge, PaymentOptionType, PaymentOptionTypeWithLiterals, PhysicalProperties, PickupDetails, PickupMethod, PickupMethodWithLiterals, PlatformFee, PlatformFeeChargeType, PlatformFeeChargeTypeWithLiterals, PlatformFeeSummary, PriceSummary, PurchasablePlan, QuotaType, QuotaTypeWithLiterals, RateType, RateTypeWithLiterals, Region, RuleType, RuleTypeWithLiterals, Scope, SelectedCarrierServiceOption, SelectedCarrierServiceOptionOtherCharge, SelectedCarrierServiceOptionPrices, SelectedMembership, SelectedMemberships, SelectedShippingOption, ServiceProperties, ShippingInformation, ShippingOption, ShippingPrice, ShippingRegion, StreetAddress, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionSettings, SystemError, TaxBreakdown, TaxCalculationDetails, TaxCalculationDetailsCalculationDetailsOneOf, TaxDetails, TaxRateBreakdown, TaxSummary, TaxableAddress, TaxableAddressTaxableAddressDataOneOf, TaxableAddressType, TaxableAddressTypeWithLiterals, TotalsCalculationEntity, TranslatableString, V1AdditionalFee, V1Membership, V1TaxDetails, ValidatedExistingMemberships, ValidatedPurchasablePlans, ValidationError, WeightUnit, WeightUnitWithLiterals } from './index.typings.js';
4
4
 
5
5
  declare function calculateTotals$1(httpClient: HttpClient): CalculateTotalsSignature;
6
6
  interface CalculateTotalsSignature {
@@ -40,7 +40,8 @@ __export(index_exports, {
40
40
  SubscriptionFrequency: () => SubscriptionFrequency,
41
41
  TaxableAddressType: () => TaxableAddressType,
42
42
  WeightUnit: () => WeightUnit,
43
- calculateTotals: () => calculateTotals4
43
+ calculateTotals: () => calculateTotals4,
44
+ convertAndCalculateTotals: () => convertAndCalculateTotals4
44
45
  });
45
46
  module.exports = __toCommonJS(index_exports);
46
47
 
@@ -109,6 +110,68 @@ var TRANSFORM_PATHS_3 = [
109
110
  path: "membershipOptions.validatedExistingMemberships.memberships.membership.expirationDate"
110
111
  }
111
112
  ];
113
+ var TRANSFORM_PATHS_4 = [
114
+ { path: "calculationRequest.lineItems.physicalProperties.weight" },
115
+ { path: "calculationRequest.shippingAddress.geocode.latitude" },
116
+ { path: "calculationRequest.shippingAddress.geocode.longitude" },
117
+ { path: "calculationRequest.billingAddress.geocode.latitude" },
118
+ { path: "calculationRequest.billingAddress.geocode.longitude" },
119
+ {
120
+ path: "calculationRequest.shippingOptions.shippingOptions.logistics.pickupDetails.address.geocode.latitude"
121
+ },
122
+ {
123
+ path: "calculationRequest.shippingOptions.shippingOptions.logistics.pickupDetails.address.geocode.longitude"
124
+ },
125
+ { path: "calculationRequest.appliedDiscounts.merchantDiscount.percentage" }
126
+ ];
127
+ var TRANSFORM_PATHS_5 = [
128
+ { path: "calculationRequest.lineItems.serviceProperties.scheduledDate" },
129
+ { path: "calculationRequest.lineItems.serviceProperties.endDate" },
130
+ {
131
+ path: "calculationRequest.shippingOptions.shippingOptions.logistics.deliveryTimeSlot.from"
132
+ },
133
+ {
134
+ path: "calculationRequest.shippingOptions.shippingOptions.logistics.deliveryTimeSlot.to"
135
+ }
136
+ ];
137
+ var TRANSFORM_PATHS_6 = [
138
+ {
139
+ path: "calculationResult.shippingInfo.selectedCarrierServiceOption.logistics.pickupDetails.address.geocode.latitude"
140
+ },
141
+ {
142
+ path: "calculationResult.shippingInfo.selectedCarrierServiceOption.logistics.pickupDetails.address.geocode.longitude"
143
+ },
144
+ {
145
+ path: "calculationResult.shippingInfo.carrierServiceOptions.shippingOptions.logistics.pickupDetails.address.geocode.latitude"
146
+ },
147
+ {
148
+ path: "calculationResult.shippingInfo.carrierServiceOptions.shippingOptions.logistics.pickupDetails.address.geocode.longitude"
149
+ },
150
+ { path: "calculationResult.appliedDiscounts.merchantDiscount.percentage" }
151
+ ];
152
+ var TRANSFORM_PATHS_7 = [
153
+ {
154
+ path: "calculationResult.shippingInfo.selectedCarrierServiceOption.logistics.deliveryTimeSlot.from"
155
+ },
156
+ {
157
+ path: "calculationResult.shippingInfo.selectedCarrierServiceOption.logistics.deliveryTimeSlot.to"
158
+ },
159
+ {
160
+ path: "calculationResult.shippingInfo.carrierServiceOptions.shippingOptions.logistics.deliveryTimeSlot.from"
161
+ },
162
+ {
163
+ path: "calculationResult.shippingInfo.carrierServiceOptions.shippingOptions.logistics.deliveryTimeSlot.to"
164
+ },
165
+ {
166
+ path: "calculationResult.membershipOptions.eligibleMemberships.expirationDate"
167
+ },
168
+ {
169
+ path: "calculationResult.membershipOptions.invalidMemberships.membership.expirationDate"
170
+ },
171
+ {
172
+ path: "calculationResult.membershipOptions.validatedExistingMemberships.memberships.membership.expirationDate"
173
+ }
174
+ ];
112
175
  function resolveComWixEcomTotalsCalculatorV1TotalsCalculatorUrl(opts) {
113
176
  const domainToMappings = {
114
177
  "bo._base_domain_": [
@@ -192,6 +255,47 @@ function calculateTotals(payload) {
192
255
  }
193
256
  return __calculateTotals;
194
257
  }
258
+ function convertAndCalculateTotals(payload) {
259
+ function __convertAndCalculateTotals({ host }) {
260
+ const serializedData = (0, import_transform_paths.transformPaths)(payload, [
261
+ {
262
+ transformFn: import_float.transformSDKFloatToRESTFloat,
263
+ paths: TRANSFORM_PATHS_4
264
+ },
265
+ {
266
+ transformFn: import_timestamp.transformSDKTimestampToRESTTimestamp,
267
+ paths: TRANSFORM_PATHS_5
268
+ }
269
+ ]);
270
+ const metadata = {
271
+ entityFqdn: "wix.ecom.v1.totals_calculation",
272
+ method: "POST",
273
+ methodFqn: "com.wix.ecom.totals_calculator.v1.TotalsCalculator.ConvertAndCalculateTotals",
274
+ packageName: PACKAGE_NAME,
275
+ migrationOptions: {
276
+ optInTransformResponse: true
277
+ },
278
+ url: resolveComWixEcomTotalsCalculatorV1TotalsCalculatorUrl({
279
+ protoPath: "/v1/convert-and-calculate-totals",
280
+ data: serializedData,
281
+ host
282
+ }),
283
+ data: serializedData,
284
+ transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
285
+ {
286
+ transformFn: import_float2.transformRESTFloatToSDKFloat,
287
+ paths: TRANSFORM_PATHS_6
288
+ },
289
+ {
290
+ transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
291
+ paths: TRANSFORM_PATHS_7
292
+ }
293
+ ])
294
+ };
295
+ return metadata;
296
+ }
297
+ return __convertAndCalculateTotals;
298
+ }
195
299
 
196
300
  // src/ecom-v1-totals-calculation-totals-calculator.universal.ts
197
301
  var import_address = require("@wix/sdk-runtime/transformations/address");
@@ -210,6 +314,21 @@ var TRANSFORM_PATHS_12 = [
210
314
  path: "shippingInfo.carrierServiceOptions.shippingOptions.logistics.pickupDetails.address"
211
315
  }
212
316
  ];
317
+ var TRANSFORM_PATHS_22 = [
318
+ { path: "calculationRequest.shippingAddress" },
319
+ { path: "calculationRequest.billingAddress" },
320
+ {
321
+ path: "calculationRequest.shippingOptions.shippingOptions.logistics.pickupDetails.address"
322
+ }
323
+ ];
324
+ var TRANSFORM_PATHS_32 = [
325
+ {
326
+ path: "calculationResult.shippingInfo.selectedCarrierServiceOption.logistics.pickupDetails.address"
327
+ },
328
+ {
329
+ path: "calculationResult.shippingInfo.carrierServiceOptions.shippingOptions.logistics.pickupDetails.address"
330
+ }
331
+ ];
213
332
  var DimensionsUnit = /* @__PURE__ */ ((DimensionsUnit2) => {
214
333
  DimensionsUnit2["UNKNOWN_DIMENSIONS_UNIT"] = "UNKNOWN_DIMENSIONS_UNIT";
215
334
  DimensionsUnit2["MM"] = "MM";
@@ -385,6 +504,7 @@ async function calculateTotals2(options) {
385
504
  applyItemDiscountsToPrices: options?.applyItemDiscountsToPrices,
386
505
  giftCards: options?.giftCards,
387
506
  membershipSelection: options?.membershipSelection,
507
+ amountCurrency: options?.amountCurrency,
388
508
  sitePaymentMethodTypeId: options?.sitePaymentMethodTypeId
389
509
  }),
390
510
  [
@@ -435,6 +555,7 @@ async function calculateTotals2(options) {
435
555
  applyItemDiscountsToPrices: "$[0].applyItemDiscountsToPrices",
436
556
  giftCards: "$[0].giftCards",
437
557
  membershipSelection: "$[0].membershipSelection",
558
+ amountCurrency: "$[0].amountCurrency",
438
559
  sitePaymentMethodTypeId: "$[0].sitePaymentMethodTypeId"
439
560
  },
440
561
  singleArgumentUnchanged: false
@@ -445,6 +566,50 @@ async function calculateTotals2(options) {
445
566
  throw transformedError;
446
567
  }
447
568
  }
569
+ async function convertAndCalculateTotals2(calculationRequest, options) {
570
+ const { httpClient, sideEffects } = arguments[2];
571
+ const payload = (0, import_transform_paths2.transformPaths)(
572
+ (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
573
+ calculationRequest,
574
+ targetCurrency: options?.targetCurrency
575
+ }),
576
+ [
577
+ {
578
+ transformFn: import_address.transformSDKAddressToRESTAddress,
579
+ paths: TRANSFORM_PATHS_22
580
+ }
581
+ ]
582
+ );
583
+ const reqOpts = convertAndCalculateTotals(payload);
584
+ sideEffects?.onSiteCall?.();
585
+ try {
586
+ const result = await httpClient.request(reqOpts);
587
+ sideEffects?.onSuccess?.(result);
588
+ return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(
589
+ (0, import_transform_paths2.transformPaths)(result.data, [
590
+ {
591
+ transformFn: import_address2.transformRESTAddressToSDKAddress,
592
+ paths: TRANSFORM_PATHS_32
593
+ }
594
+ ])
595
+ );
596
+ } catch (err) {
597
+ const transformedError = (0, import_transform_error.transformError)(
598
+ err,
599
+ {
600
+ spreadPathsToArguments: {},
601
+ explicitPathsToArguments: {
602
+ calculationRequest: "$[0]",
603
+ targetCurrency: "$[1].targetCurrency"
604
+ },
605
+ singleArgumentUnchanged: false
606
+ },
607
+ ["calculationRequest", "options"]
608
+ );
609
+ sideEffects?.onError?.(err);
610
+ throw transformedError;
611
+ }
612
+ }
448
613
 
449
614
  // src/ecom-v1-totals-calculation-totals-calculator.public.ts
450
615
  function calculateTotals3(httpClient) {
@@ -454,10 +619,19 @@ function calculateTotals3(httpClient) {
454
619
  { httpClient }
455
620
  );
456
621
  }
622
+ function convertAndCalculateTotals3(httpClient) {
623
+ return (calculationRequest, options) => convertAndCalculateTotals2(
624
+ calculationRequest,
625
+ options,
626
+ // @ts-ignore
627
+ { httpClient }
628
+ );
629
+ }
457
630
 
458
631
  // src/ecom-v1-totals-calculation-totals-calculator.context.ts
459
632
  var import_rest_modules2 = require("@wix/sdk-runtime/rest-modules");
460
633
  var calculateTotals4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(calculateTotals3);
634
+ var convertAndCalculateTotals4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(convertAndCalculateTotals3);
461
635
  // Annotate the CommonJS export names for ESM import in node:
462
636
  0 && (module.exports = {
463
637
  AdditionalFeeSource,
@@ -480,6 +654,7 @@ var calculateTotals4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule
480
654
  SubscriptionFrequency,
481
655
  TaxableAddressType,
482
656
  WeightUnit,
483
- calculateTotals
657
+ calculateTotals,
658
+ convertAndCalculateTotals
484
659
  });
485
660
  //# sourceMappingURL=index.js.map