@adobe-commerce/aio-toolkit 1.0.4 → 1.0.5

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/dist/index.mjs CHANGED
@@ -552,28 +552,31 @@ var _CustomLogger = class _CustomLogger {
552
552
  /**
553
553
  * Log debug message if logger is available
554
554
  * @param message - Debug message to log
555
+ * @param args - Additional arguments to pass to logger
555
556
  */
556
- debug(message) {
557
+ debug(message, ...args) {
557
558
  if (this.logger && typeof this.logger.debug === "function") {
558
- this.logger.debug(message);
559
+ this.logger.debug(message, ...args);
559
560
  }
560
561
  }
561
562
  /**
562
563
  * Log info message if logger is available
563
564
  * @param message - Info message to log
565
+ * @param args - Additional arguments to pass to logger
564
566
  */
565
- info(message) {
567
+ info(message, ...args) {
566
568
  if (this.logger && typeof this.logger.info === "function") {
567
- this.logger.info(message);
569
+ this.logger.info(message, ...args);
568
570
  }
569
571
  }
570
572
  /**
571
573
  * Log error message if logger is available
572
574
  * @param message - Error message to log
575
+ * @param args - Additional arguments to pass to logger
573
576
  */
574
- error(message) {
577
+ error(message, ...args) {
575
578
  if (this.logger && typeof this.logger.error === "function") {
576
- this.logger.error(message);
579
+ this.logger.error(message, ...args);
577
580
  }
578
581
  }
579
582
  /**
@@ -4916,26 +4919,22 @@ var AdobeAuth = _AdobeAuth;
4916
4919
  var adobe_auth_default = AdobeAuth;
4917
4920
 
4918
4921
  // src/commerce/adobe-commerce-client/index.ts
4919
- import { Core as Core6 } from "@adobe/aio-sdk";
4920
4922
  import got from "got";
4921
4923
  var _AdobeCommerceClient = class _AdobeCommerceClient {
4922
4924
  /**
4923
4925
  * @param baseUrl
4924
4926
  * @param connection
4925
4927
  * @param logger
4928
+ * @param httpsOptions
4926
4929
  */
4927
- constructor(baseUrl, connection, logger = null) {
4930
+ constructor(baseUrl, connection, logger = null, httpsOptions) {
4928
4931
  if (!baseUrl) {
4929
4932
  throw new Error("Commerce URL must be provided");
4930
4933
  }
4931
4934
  this.baseUrl = baseUrl;
4932
4935
  this.connection = connection;
4933
- if (logger === null) {
4934
- logger = Core6.Logger("adobe-commerce-client", {
4935
- level: "debug"
4936
- });
4937
- }
4938
- this.logger = logger;
4936
+ this.httpsOptions = httpsOptions;
4937
+ this.logger = new custom_logger_default(logger);
4939
4938
  }
4940
4939
  /**
4941
4940
  * @param endpoint
@@ -5022,6 +5021,7 @@ var _AdobeCommerceClient = class _AdobeCommerceClient {
5022
5021
  headers: {
5023
5022
  "Content-Type": "application/json"
5024
5023
  },
5024
+ ...this.httpsOptions && { https: this.httpsOptions },
5025
5025
  hooks: {
5026
5026
  beforeRequest: [
5027
5027
  (options) => this.logger.debug(`Request [${options.method}] ${options.url}`)
@@ -5057,11 +5057,8 @@ __name(_AdobeCommerceClient, "AdobeCommerceClient");
5057
5057
  var AdobeCommerceClient = _AdobeCommerceClient;
5058
5058
  var adobe_commerce_client_default = AdobeCommerceClient;
5059
5059
 
5060
- // src/commerce/adobe-commerce-client/basic-auth-connection/index.ts
5061
- import { Core as Core8 } from "@adobe/aio-sdk";
5062
-
5063
5060
  // src/commerce/adobe-commerce-client/basic-auth-connection/generate-basic-auth-token/index.ts
5064
- import { State as State2, Core as Core7 } from "@adobe/aio-sdk";
5061
+ import { State as State2 } from "@adobe/aio-sdk";
5065
5062
  var _GenerateBasicAuthToken = class _GenerateBasicAuthToken {
5066
5063
  /**
5067
5064
  * @param baseUrl
@@ -5074,12 +5071,7 @@ var _GenerateBasicAuthToken = class _GenerateBasicAuthToken {
5074
5071
  this.username = username;
5075
5072
  this.password = password;
5076
5073
  this.key = "adobe_commerce_basic_auth_token";
5077
- if (logger === null) {
5078
- logger = Core7.Logger("adobe-commerce-client", {
5079
- level: "debug"
5080
- });
5081
- }
5082
- this.logger = logger;
5074
+ this.logger = new custom_logger_default(logger);
5083
5075
  }
5084
5076
  /**
5085
5077
  * @return string | null
@@ -5241,12 +5233,7 @@ var _BasicAuthConnection = class _BasicAuthConnection {
5241
5233
  this.baseUrl = baseUrl;
5242
5234
  this.username = username;
5243
5235
  this.password = password;
5244
- if (logger === null) {
5245
- logger = Core8.Logger("adobe-commerce-client", {
5246
- level: "debug"
5247
- });
5248
- }
5249
- this.logger = logger;
5236
+ this.logger = new custom_logger_default(logger);
5250
5237
  }
5251
5238
  /**
5252
5239
  * @param commerceGot
@@ -5257,7 +5244,7 @@ var _BasicAuthConnection = class _BasicAuthConnection {
5257
5244
  this.baseUrl,
5258
5245
  this.username,
5259
5246
  this.password,
5260
- this.logger
5247
+ this.logger.getLogger()
5261
5248
  );
5262
5249
  const token = await generateToken.execute();
5263
5250
  return commerceGot.extend({
@@ -5272,7 +5259,6 @@ var BasicAuthConnection = _BasicAuthConnection;
5272
5259
  var basic_auth_connection_default = BasicAuthConnection;
5273
5260
 
5274
5261
  // src/commerce/adobe-commerce-client/oauth1a-connection/index.ts
5275
- import { Core as Core9 } from "@adobe/aio-sdk";
5276
5262
  import Oauth1a from "oauth-1.0a";
5277
5263
  import * as crypto3 from "crypto";
5278
5264
  var _Oauth1aConnection = class _Oauth1aConnection {
@@ -5288,12 +5274,7 @@ var _Oauth1aConnection = class _Oauth1aConnection {
5288
5274
  this.consumerSecret = consumerSecret;
5289
5275
  this.accessToken = accessToken;
5290
5276
  this.accessTokenSecret = accessTokenSecret;
5291
- if (logger === null) {
5292
- logger = Core9.Logger("adobe-commerce-client", {
5293
- level: "debug"
5294
- });
5295
- }
5296
- this.logger = logger;
5277
+ this.logger = new custom_logger_default(logger);
5297
5278
  }
5298
5279
  /**
5299
5280
  * @param commerceGot
@@ -5764,6 +5745,7 @@ var _ShippingCarrier = class _ShippingCarrier {
5764
5745
  }
5765
5746
  /**
5766
5747
  * Sets the carrier data from a ShippingCarrierData object
5748
+ * Note: The code property cannot be changed once set in the constructor
5767
5749
  *
5768
5750
  * @param carrierData - Carrier data object
5769
5751
  * @returns The builder instance for method chaining
@@ -5783,8 +5765,11 @@ var _ShippingCarrier = class _ShippingCarrier {
5783
5765
  * ```
5784
5766
  */
5785
5767
  setData(carrierData) {
5786
- this.validateCarrierCode(carrierData.code);
5787
- this.carrierData = { ...carrierData };
5768
+ const originalCode = this.carrierData.code;
5769
+ if (carrierData.code !== void 0) {
5770
+ this.validateCarrierCode(carrierData.code);
5771
+ }
5772
+ this.carrierData = { ...carrierData, code: originalCode };
5788
5773
  return this;
5789
5774
  }
5790
5775
  /**
@@ -5829,37 +5814,6 @@ var _ShippingCarrier = class _ShippingCarrier {
5829
5814
  this.removedMethods.push(method);
5830
5815
  return this;
5831
5816
  }
5832
- /**
5833
- * Resets the carrier and re-initializes it with new code and optional callback
5834
- *
5835
- * @param code - Carrier code
5836
- * @param callback - Optional callback function to configure the carrier
5837
- * @returns The builder instance for method chaining
5838
- *
5839
- * @example
5840
- * ```typescript
5841
- * carrier.reset('ups', (carrier) => {
5842
- * carrier.addMethod('ground', (method) => {
5843
- * method.setMethodTitle('UPS Ground').setPrice(12.99).setCost(8.00);
5844
- * });
5845
- * });
5846
- * ```
5847
- */
5848
- reset(code, callback) {
5849
- this.validateCarrierCode(code);
5850
- this.carrierData = {
5851
- code,
5852
- active: true,
5853
- tracking_available: true,
5854
- shipping_labels_available: true
5855
- };
5856
- this.addedMethods = [];
5857
- this.removedMethods = [];
5858
- if (callback) {
5859
- callback(this);
5860
- }
5861
- return this;
5862
- }
5863
5817
  /**
5864
5818
  * Gets and returns the shipping carrier data as a JSON object
5865
5819
  *
@@ -5884,6 +5838,34 @@ var _ShippingCarrier = class _ShippingCarrier {
5884
5838
  getData() {
5885
5839
  return this.carrierData;
5886
5840
  }
5841
+ /**
5842
+ * Gets the list of methods that have been added to the carrier
5843
+ *
5844
+ * @returns Array of added shipping carrier methods
5845
+ *
5846
+ * @example
5847
+ * ```typescript
5848
+ * const addedMethods = carrier.getAddedMethods();
5849
+ * // Returns: [{ carrier_code: 'fedex', method: 'standard', ... }, ...]
5850
+ * ```
5851
+ */
5852
+ getAddedMethods() {
5853
+ return this.addedMethods;
5854
+ }
5855
+ /**
5856
+ * Gets the list of method codes that have been marked for removal
5857
+ *
5858
+ * @returns Array of method codes to be removed
5859
+ *
5860
+ * @example
5861
+ * ```typescript
5862
+ * const removedMethods = carrier.getRemovedMethods();
5863
+ * // Returns: ['overnight', 'express']
5864
+ * ```
5865
+ */
5866
+ getRemovedMethods() {
5867
+ return this.removedMethods;
5868
+ }
5887
5869
  };
5888
5870
  __name(_ShippingCarrier, "ShippingCarrier");
5889
5871
  var ShippingCarrier = _ShippingCarrier;