@adobe-commerce/aio-toolkit 1.0.3 → 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/CHANGELOG.md +110 -0
- package/README.md +215 -4
- package/dist/index.d.mts +141 -3
- package/dist/index.d.ts +141 -3
- package/dist/index.js +751 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +738 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,7 +60,14 @@ __export(index_exports, {
|
|
|
60
60
|
RestClient: () => rest_client_default,
|
|
61
61
|
RuntimeAction: () => runtime_action_default,
|
|
62
62
|
RuntimeActionResponse: () => response_default,
|
|
63
|
-
|
|
63
|
+
ShippingCarrier: () => shipping_carrier_default,
|
|
64
|
+
ShippingCarrierMethod: () => method_default,
|
|
65
|
+
ShippingCarrierResponse: () => response_default3,
|
|
66
|
+
SignatureVerification: () => SignatureVerification,
|
|
67
|
+
Validator: () => validator_default,
|
|
68
|
+
WebhookAction: () => webhook_action_default,
|
|
69
|
+
WebhookActionOperation: () => WebhookActionOperation,
|
|
70
|
+
WebhookActionResponse: () => response_default2
|
|
64
71
|
});
|
|
65
72
|
module.exports = __toCommonJS(index_exports);
|
|
66
73
|
|
|
@@ -459,15 +466,34 @@ var _FileRepository = class _FileRepository {
|
|
|
459
466
|
async list() {
|
|
460
467
|
const filesLib = await this.getFiles();
|
|
461
468
|
const results = [];
|
|
462
|
-
const existingFiles = await
|
|
469
|
+
const existingFiles = await this.metadata();
|
|
463
470
|
if (existingFiles.length) {
|
|
464
|
-
for (const
|
|
465
|
-
const buffer = await filesLib.read(`${name}`);
|
|
466
|
-
|
|
471
|
+
for (const file of existingFiles) {
|
|
472
|
+
const buffer = await filesLib.read(`${file.name}`);
|
|
473
|
+
const data = JSON.parse(buffer.toString());
|
|
474
|
+
results.push({
|
|
475
|
+
...data,
|
|
476
|
+
createdAt: file.creationTime.toISOString(),
|
|
477
|
+
updatedAt: file.lastModified.toISOString()
|
|
478
|
+
});
|
|
467
479
|
}
|
|
468
480
|
}
|
|
469
481
|
return results;
|
|
470
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Lists file metadata without reading file contents
|
|
485
|
+
* Provides a lightweight alternative to list() for performance-critical operations
|
|
486
|
+
* @param id - Optional ID of a specific file to get metadata for
|
|
487
|
+
* @returns Promise<FileMetadata | FileMetadata[]> Single file metadata if id provided, array of all files otherwise
|
|
488
|
+
*/
|
|
489
|
+
async metadata(id) {
|
|
490
|
+
const filesLib = await this.getFiles();
|
|
491
|
+
if (id) {
|
|
492
|
+
const filepath = `${this.filepath}/${id}.json`;
|
|
493
|
+
return await filesLib.getProperties(filepath);
|
|
494
|
+
}
|
|
495
|
+
return await filesLib.list(`${this.filepath}/`);
|
|
496
|
+
}
|
|
471
497
|
/**
|
|
472
498
|
* Loads a specific file by ID
|
|
473
499
|
* @param id - The ID of the file to load
|
|
@@ -479,7 +505,13 @@ var _FileRepository = class _FileRepository {
|
|
|
479
505
|
const existingFile = await filesLib.list(filepath);
|
|
480
506
|
if (existingFile.length) {
|
|
481
507
|
const buffer = await filesLib.read(filepath);
|
|
482
|
-
|
|
508
|
+
const data = JSON.parse(buffer.toString());
|
|
509
|
+
const fileProps = await filesLib.getProperties(filepath);
|
|
510
|
+
return {
|
|
511
|
+
...data,
|
|
512
|
+
createdAt: fileProps.creationTime.toISOString(),
|
|
513
|
+
updatedAt: fileProps.lastModified.toISOString()
|
|
514
|
+
};
|
|
483
515
|
}
|
|
484
516
|
return {};
|
|
485
517
|
}
|
|
@@ -487,9 +519,12 @@ var _FileRepository = class _FileRepository {
|
|
|
487
519
|
* Saves a file record to the repository
|
|
488
520
|
* @param payload - The data to save
|
|
489
521
|
* @param id - Optional ID for the file (sanitized to alphanumeric + underscore, takes precedence over payload.id)
|
|
522
|
+
* @param overwrite - Optional flag to control file write behavior:
|
|
523
|
+
* - true: Replace file entirely with payload (no merge)
|
|
524
|
+
* - false (default): Merge payload with existing file content
|
|
490
525
|
* @returns Promise<string | null> The filename on success, null on failure
|
|
491
526
|
*/
|
|
492
|
-
async save(payload = {}, id) {
|
|
527
|
+
async save(payload = {}, id, overwrite = false) {
|
|
493
528
|
try {
|
|
494
529
|
const filesLib = await this.getFiles();
|
|
495
530
|
let fileId;
|
|
@@ -503,23 +538,26 @@ var _FileRepository = class _FileRepository {
|
|
|
503
538
|
const filepath = `${this.filepath}/${fileId}.json`;
|
|
504
539
|
const existingFile = await filesLib.list(filepath);
|
|
505
540
|
if (existingFile.length) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
541
|
+
if (overwrite) {
|
|
542
|
+
console.log(`Overwriting existing file: ${filepath}`);
|
|
543
|
+
payload = {
|
|
544
|
+
id: fileId,
|
|
545
|
+
...payload
|
|
546
|
+
};
|
|
547
|
+
} else {
|
|
548
|
+
const buffer = await filesLib.read(filepath);
|
|
549
|
+
const existingData = JSON.parse(buffer.toString());
|
|
550
|
+
payload = { ...existingData, ...payload };
|
|
551
|
+
}
|
|
513
552
|
await filesLib.delete(filepath);
|
|
514
553
|
} else {
|
|
515
554
|
payload = {
|
|
516
|
-
...payload,
|
|
517
555
|
id: fileId,
|
|
518
|
-
|
|
519
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
556
|
+
...payload
|
|
520
557
|
};
|
|
521
558
|
}
|
|
522
|
-
|
|
559
|
+
const { createdAt, updatedAt, ...payloadWithoutTimestamps } = payload;
|
|
560
|
+
await filesLib.write(filepath, JSON.stringify(payloadWithoutTimestamps));
|
|
523
561
|
return fileId;
|
|
524
562
|
} catch (error) {
|
|
525
563
|
console.error("Error saving file:", error);
|
|
@@ -584,28 +622,31 @@ var _CustomLogger = class _CustomLogger {
|
|
|
584
622
|
/**
|
|
585
623
|
* Log debug message if logger is available
|
|
586
624
|
* @param message - Debug message to log
|
|
625
|
+
* @param args - Additional arguments to pass to logger
|
|
587
626
|
*/
|
|
588
|
-
debug(message) {
|
|
627
|
+
debug(message, ...args) {
|
|
589
628
|
if (this.logger && typeof this.logger.debug === "function") {
|
|
590
|
-
this.logger.debug(message);
|
|
629
|
+
this.logger.debug(message, ...args);
|
|
591
630
|
}
|
|
592
631
|
}
|
|
593
632
|
/**
|
|
594
633
|
* Log info message if logger is available
|
|
595
634
|
* @param message - Info message to log
|
|
635
|
+
* @param args - Additional arguments to pass to logger
|
|
596
636
|
*/
|
|
597
|
-
info(message) {
|
|
637
|
+
info(message, ...args) {
|
|
598
638
|
if (this.logger && typeof this.logger.info === "function") {
|
|
599
|
-
this.logger.info(message);
|
|
639
|
+
this.logger.info(message, ...args);
|
|
600
640
|
}
|
|
601
641
|
}
|
|
602
642
|
/**
|
|
603
643
|
* Log error message if logger is available
|
|
604
644
|
* @param message - Error message to log
|
|
645
|
+
* @param args - Additional arguments to pass to logger
|
|
605
646
|
*/
|
|
606
|
-
error(message) {
|
|
647
|
+
error(message, ...args) {
|
|
607
648
|
if (this.logger && typeof this.logger.error === "function") {
|
|
608
|
-
this.logger.error(message);
|
|
649
|
+
this.logger.error(message, ...args);
|
|
609
650
|
}
|
|
610
651
|
}
|
|
611
652
|
/**
|
|
@@ -705,6 +746,281 @@ __name(_PublishEvent, "PublishEvent");
|
|
|
705
746
|
var PublishEvent = _PublishEvent;
|
|
706
747
|
var publish_event_default = PublishEvent;
|
|
707
748
|
|
|
749
|
+
// src/framework/webhook-action/response/types.ts
|
|
750
|
+
var WebhookActionOperation = /* @__PURE__ */ ((WebhookActionOperation2) => {
|
|
751
|
+
WebhookActionOperation2["SUCCESS"] = "success";
|
|
752
|
+
WebhookActionOperation2["EXCEPTION"] = "exception";
|
|
753
|
+
WebhookActionOperation2["ADD"] = "add";
|
|
754
|
+
WebhookActionOperation2["REPLACE"] = "replace";
|
|
755
|
+
WebhookActionOperation2["REMOVE"] = "remove";
|
|
756
|
+
return WebhookActionOperation2;
|
|
757
|
+
})(WebhookActionOperation || {});
|
|
758
|
+
|
|
759
|
+
// src/framework/webhook-action/response/index.ts
|
|
760
|
+
var _WebhookActionResponse = class _WebhookActionResponse {
|
|
761
|
+
/**
|
|
762
|
+
* Creates a success response indicating the webhook was processed successfully.
|
|
763
|
+
*
|
|
764
|
+
* Use this method when the webhook has been processed without errors and
|
|
765
|
+
* no modifications to the payload are needed.
|
|
766
|
+
*
|
|
767
|
+
* @returns A success response object
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```typescript
|
|
771
|
+
* const handler = WebhookAction.execute('process-order', [], [], async (params) => {
|
|
772
|
+
* // Process the order...
|
|
773
|
+
* await processOrder(params.order);
|
|
774
|
+
*
|
|
775
|
+
* // Return success
|
|
776
|
+
* return {
|
|
777
|
+
* statusCode: 200,
|
|
778
|
+
* body: WebhookActionResponse.success()
|
|
779
|
+
* };
|
|
780
|
+
* });
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
static success() {
|
|
784
|
+
return {
|
|
785
|
+
op: "success" /* SUCCESS */
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Creates an exception response to report an error during webhook processing.
|
|
790
|
+
*
|
|
791
|
+
* Use this method to notify Adobe Commerce that an error occurred while
|
|
792
|
+
* processing the webhook. This helps with debugging and error tracking.
|
|
793
|
+
*
|
|
794
|
+
* @param message - Optional error message describing what went wrong
|
|
795
|
+
* @param exceptionClass - Optional exception class name for categorization (e.g., 'Magento\\Framework\\Exception\\LocalizedException')
|
|
796
|
+
* @returns An exception response object
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* ```typescript
|
|
800
|
+
* const handler = WebhookAction.execute('validate-product', [], [], async (params) => {
|
|
801
|
+
* const product = await findProduct(params.sku);
|
|
802
|
+
*
|
|
803
|
+
* if (!product) {
|
|
804
|
+
* return {
|
|
805
|
+
* statusCode: 404,
|
|
806
|
+
* body: WebhookActionResponse.exception(
|
|
807
|
+
* `Product with SKU ${params.sku} not found`,
|
|
808
|
+
* 'Magento\\Framework\\Exception\\NoSuchEntityException'
|
|
809
|
+
* )
|
|
810
|
+
* };
|
|
811
|
+
* }
|
|
812
|
+
*
|
|
813
|
+
* return { statusCode: 200, body: WebhookActionResponse.success() };
|
|
814
|
+
* });
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
static exception(message, exceptionClass) {
|
|
818
|
+
const response = {
|
|
819
|
+
op: "exception" /* EXCEPTION */
|
|
820
|
+
};
|
|
821
|
+
if (message !== void 0) {
|
|
822
|
+
response.message = message;
|
|
823
|
+
}
|
|
824
|
+
if (exceptionClass !== void 0) {
|
|
825
|
+
response.class = exceptionClass;
|
|
826
|
+
}
|
|
827
|
+
return response;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Creates a response to add new data to the webhook payload.
|
|
831
|
+
*
|
|
832
|
+
* Use this method to inject additional data into the webhook payload that
|
|
833
|
+
* will be processed by Adobe Commerce. The data is added at the specified
|
|
834
|
+
* path using dot notation.
|
|
835
|
+
*
|
|
836
|
+
* @param path - Dot-notation path where the value should be added (e.g., 'order.items', 'customer.addresses')
|
|
837
|
+
* @param value - The value to add at the specified path
|
|
838
|
+
* @param instance - Optional instance identifier for tracking or reference purposes
|
|
839
|
+
* @returns An add response object
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```typescript
|
|
843
|
+
* const handler = WebhookAction.execute('enrich-order', [], [], async (params) => {
|
|
844
|
+
* // Add loyalty points to the order
|
|
845
|
+
* return {
|
|
846
|
+
* statusCode: 200,
|
|
847
|
+
* body: WebhookActionResponse.add(
|
|
848
|
+
* 'order.loyalty',
|
|
849
|
+
* { points: 150, tier: 'gold' },
|
|
850
|
+
* params.order.id
|
|
851
|
+
* )
|
|
852
|
+
* };
|
|
853
|
+
* });
|
|
854
|
+
* ```
|
|
855
|
+
*/
|
|
856
|
+
static add(path, value, instance) {
|
|
857
|
+
const response = {
|
|
858
|
+
op: "add" /* ADD */,
|
|
859
|
+
path,
|
|
860
|
+
value
|
|
861
|
+
};
|
|
862
|
+
if (instance !== void 0) {
|
|
863
|
+
response.instance = instance;
|
|
864
|
+
}
|
|
865
|
+
return response;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Creates a response to replace existing data in the webhook payload.
|
|
869
|
+
*
|
|
870
|
+
* Use this method to modify existing fields in the webhook payload.
|
|
871
|
+
* The existing value at the specified path will be replaced with the new value.
|
|
872
|
+
*
|
|
873
|
+
* @param path - Dot-notation path to the field that should be replaced (e.g., 'product.price', 'order.status')
|
|
874
|
+
* @param value - The new value to replace the existing value
|
|
875
|
+
* @param instance - Optional instance identifier for tracking or reference purposes
|
|
876
|
+
* @returns A replace response object
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* ```typescript
|
|
880
|
+
* const handler = WebhookAction.execute('adjust-price', [], [], async (params) => {
|
|
881
|
+
* // Apply dynamic pricing
|
|
882
|
+
* const newPrice = await calculateDiscountedPrice(params.product.price);
|
|
883
|
+
*
|
|
884
|
+
* return {
|
|
885
|
+
* statusCode: 200,
|
|
886
|
+
* body: WebhookActionResponse.replace(
|
|
887
|
+
* 'product.price',
|
|
888
|
+
* newPrice,
|
|
889
|
+
* params.product.id
|
|
890
|
+
* )
|
|
891
|
+
* };
|
|
892
|
+
* });
|
|
893
|
+
* ```
|
|
894
|
+
*/
|
|
895
|
+
static replace(path, value, instance) {
|
|
896
|
+
const response = {
|
|
897
|
+
op: "replace" /* REPLACE */,
|
|
898
|
+
path,
|
|
899
|
+
value
|
|
900
|
+
};
|
|
901
|
+
if (instance !== void 0) {
|
|
902
|
+
response.instance = instance;
|
|
903
|
+
}
|
|
904
|
+
return response;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Creates a response to remove data from the webhook payload.
|
|
908
|
+
*
|
|
909
|
+
* Use this method to remove fields from the webhook payload before it's
|
|
910
|
+
* processed by Adobe Commerce. This is useful for filtering sensitive data
|
|
911
|
+
* or removing unnecessary information.
|
|
912
|
+
*
|
|
913
|
+
* @param path - Dot-notation path to the field that should be removed (e.g., 'items.0', 'customer.internal_notes')
|
|
914
|
+
* @returns A remove response object
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* ```typescript
|
|
918
|
+
* const handler = WebhookAction.execute('sanitize-customer', [], [], async (params) => {
|
|
919
|
+
* // Remove internal notes before processing
|
|
920
|
+
* return {
|
|
921
|
+
* statusCode: 200,
|
|
922
|
+
* body: WebhookActionResponse.remove('customer.internal_notes')
|
|
923
|
+
* };
|
|
924
|
+
* });
|
|
925
|
+
* ```
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* ```typescript
|
|
929
|
+
* // Remove an item from an array
|
|
930
|
+
* return {
|
|
931
|
+
* statusCode: 200,
|
|
932
|
+
* body: WebhookActionResponse.remove('order.items.2')
|
|
933
|
+
* };
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
static remove(path) {
|
|
937
|
+
return {
|
|
938
|
+
op: "remove" /* REMOVE */,
|
|
939
|
+
path
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
__name(_WebhookActionResponse, "WebhookActionResponse");
|
|
944
|
+
var WebhookActionResponse = _WebhookActionResponse;
|
|
945
|
+
var response_default2 = WebhookActionResponse;
|
|
946
|
+
|
|
947
|
+
// src/framework/webhook-action/types.ts
|
|
948
|
+
var SignatureVerification = /* @__PURE__ */ ((SignatureVerification2) => {
|
|
949
|
+
SignatureVerification2["ENABLED"] = "enabled";
|
|
950
|
+
SignatureVerification2["DISABLED"] = "disabled";
|
|
951
|
+
return SignatureVerification2;
|
|
952
|
+
})(SignatureVerification || {});
|
|
953
|
+
|
|
954
|
+
// src/framework/webhook-action/index.ts
|
|
955
|
+
var import_crypto = __toESM(require("crypto"));
|
|
956
|
+
var _WebhookAction = class _WebhookAction {
|
|
957
|
+
/**
|
|
958
|
+
* Execute a webhook action with validation and response handling.
|
|
959
|
+
*
|
|
960
|
+
* @param name - Name of the webhook action
|
|
961
|
+
* @param requiredParams - Required parameters in the webhook payload
|
|
962
|
+
* @param requiredHeaders - Required headers (e.g., signature headers)
|
|
963
|
+
* @param signatureVerification - Enable/disable signature verification
|
|
964
|
+
* @param action - Webhook action function returning WebhookActionResponse
|
|
965
|
+
* @returns Function that handles the webhook HTTP request
|
|
966
|
+
*/
|
|
967
|
+
static execute(name = "webhook", requiredParams = [], requiredHeaders = [], signatureVerification = "disabled" /* DISABLED */, action = async () => response_default2.success()) {
|
|
968
|
+
const httpMethods = ["POST" /* POST */];
|
|
969
|
+
const verifySignature = /* @__PURE__ */ __name(async (params) => {
|
|
970
|
+
const signature = params.__ow_headers["x-adobe-commerce-webhook-signature"] || "";
|
|
971
|
+
if (!signature) {
|
|
972
|
+
return "Header `x-adobe-commerce-webhook-signature` not found. Make sure Webhooks signature is enabled in the Commerce instance.";
|
|
973
|
+
}
|
|
974
|
+
const body = params.__ow_body;
|
|
975
|
+
if (!body) {
|
|
976
|
+
return "Request body not found. Make sure the action is configured with `raw-http: true`.";
|
|
977
|
+
}
|
|
978
|
+
let publicKey = params.PUBLIC_KEY;
|
|
979
|
+
if (!publicKey && params.PUBLIC_KEY_BASE64) {
|
|
980
|
+
publicKey = atob(params.PUBLIC_KEY_BASE64);
|
|
981
|
+
}
|
|
982
|
+
if (!publicKey) {
|
|
983
|
+
return "Public key not found. Make sure the action is configured with the input `PUBLIC_KEY` or `PUBLIC_KEY_BASE64` and it is defined in .env file.";
|
|
984
|
+
}
|
|
985
|
+
try {
|
|
986
|
+
const verifier = import_crypto.default.createVerify("SHA256");
|
|
987
|
+
verifier.update(body);
|
|
988
|
+
const isSignatureValid = verifier.verify(publicKey, signature, "base64");
|
|
989
|
+
if (!isSignatureValid) {
|
|
990
|
+
return "The signature is invalid.";
|
|
991
|
+
}
|
|
992
|
+
} catch (error) {
|
|
993
|
+
return "The signature is invalid.";
|
|
994
|
+
}
|
|
995
|
+
return null;
|
|
996
|
+
}, "verifySignature");
|
|
997
|
+
const callback = /* @__PURE__ */ __name(async (params, ctx) => {
|
|
998
|
+
if (signatureVerification === "enabled" /* ENABLED */) {
|
|
999
|
+
const verificationErrorMessage = await verifySignature(params);
|
|
1000
|
+
if (verificationErrorMessage) {
|
|
1001
|
+
const verificationErrorResponse = response_default2.exception(verificationErrorMessage);
|
|
1002
|
+
return response_default.success(JSON.stringify(verificationErrorResponse));
|
|
1003
|
+
}
|
|
1004
|
+
params = {
|
|
1005
|
+
...params,
|
|
1006
|
+
...JSON.parse(atob(params.__ow_body))
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
const errorMessage = validator_default.checkMissingRequestInputs(params, requiredParams, requiredHeaders) ?? "";
|
|
1010
|
+
if (errorMessage) {
|
|
1011
|
+
const errorMessageResponse = response_default2.exception(errorMessage);
|
|
1012
|
+
return response_default.success(JSON.stringify(errorMessageResponse));
|
|
1013
|
+
}
|
|
1014
|
+
const response = await action(params, ctx);
|
|
1015
|
+
return response_default.success(JSON.stringify(response));
|
|
1016
|
+
}, "callback");
|
|
1017
|
+
return runtime_action_default.execute(name, httpMethods, [], [], callback);
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
__name(_WebhookAction, "WebhookAction");
|
|
1021
|
+
var WebhookAction = _WebhookAction;
|
|
1022
|
+
var webhook_action_default = WebhookAction;
|
|
1023
|
+
|
|
708
1024
|
// src/integration/bearer-token/index.ts
|
|
709
1025
|
var _BearerToken = class _BearerToken {
|
|
710
1026
|
/**
|
|
@@ -3532,7 +3848,7 @@ var RegistrationManager = _RegistrationManager;
|
|
|
3532
3848
|
var registration_default = RegistrationManager;
|
|
3533
3849
|
|
|
3534
3850
|
// src/integration/onboard-events/create-providers/index.ts
|
|
3535
|
-
var
|
|
3851
|
+
var import_crypto2 = require("crypto");
|
|
3536
3852
|
var _CreateProviders = class _CreateProviders {
|
|
3537
3853
|
/**
|
|
3538
3854
|
* Creates a new CreateProviders instance
|
|
@@ -3728,7 +4044,7 @@ var _CreateProviders = class _CreateProviders {
|
|
|
3728
4044
|
}
|
|
3729
4045
|
if (this.isCommerceProvider(providerData)) {
|
|
3730
4046
|
input.provider_metadata = "dx_commerce_events";
|
|
3731
|
-
input.instance_id = (0,
|
|
4047
|
+
input.instance_id = (0, import_crypto2.randomUUID)();
|
|
3732
4048
|
}
|
|
3733
4049
|
return input;
|
|
3734
4050
|
}
|
|
@@ -4534,7 +4850,7 @@ var onboard_events_default = OnboardEvents;
|
|
|
4534
4850
|
|
|
4535
4851
|
// src/integration/infinite-loop-breaker/index.ts
|
|
4536
4852
|
var import_aio_sdk7 = require("@adobe/aio-sdk");
|
|
4537
|
-
var
|
|
4853
|
+
var import_crypto3 = __toESM(require("crypto"));
|
|
4538
4854
|
var _InfiniteLoopBreaker = class _InfiniteLoopBreaker {
|
|
4539
4855
|
// seconds
|
|
4540
4856
|
/**
|
|
@@ -4614,7 +4930,7 @@ var _InfiniteLoopBreaker = class _InfiniteLoopBreaker {
|
|
|
4614
4930
|
* @returns The fingerprint
|
|
4615
4931
|
*/
|
|
4616
4932
|
static fingerPrint(data) {
|
|
4617
|
-
const hash =
|
|
4933
|
+
const hash = import_crypto3.default.createHash(_InfiniteLoopBreaker.FINGERPRINT_ALGORITHM);
|
|
4618
4934
|
hash.update(JSON.stringify(data));
|
|
4619
4935
|
return hash.digest(_InfiniteLoopBreaker.FINGERPRINT_ENCODING);
|
|
4620
4936
|
}
|
|
@@ -4673,26 +4989,22 @@ var AdobeAuth = _AdobeAuth;
|
|
|
4673
4989
|
var adobe_auth_default = AdobeAuth;
|
|
4674
4990
|
|
|
4675
4991
|
// src/commerce/adobe-commerce-client/index.ts
|
|
4676
|
-
var import_aio_sdk8 = require("@adobe/aio-sdk");
|
|
4677
4992
|
var import_got = __toESM(require("got"));
|
|
4678
4993
|
var _AdobeCommerceClient = class _AdobeCommerceClient {
|
|
4679
4994
|
/**
|
|
4680
4995
|
* @param baseUrl
|
|
4681
4996
|
* @param connection
|
|
4682
4997
|
* @param logger
|
|
4998
|
+
* @param httpsOptions
|
|
4683
4999
|
*/
|
|
4684
|
-
constructor(baseUrl, connection, logger = null) {
|
|
5000
|
+
constructor(baseUrl, connection, logger = null, httpsOptions) {
|
|
4685
5001
|
if (!baseUrl) {
|
|
4686
5002
|
throw new Error("Commerce URL must be provided");
|
|
4687
5003
|
}
|
|
4688
5004
|
this.baseUrl = baseUrl;
|
|
4689
5005
|
this.connection = connection;
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
level: "debug"
|
|
4693
|
-
});
|
|
4694
|
-
}
|
|
4695
|
-
this.logger = logger;
|
|
5006
|
+
this.httpsOptions = httpsOptions;
|
|
5007
|
+
this.logger = new custom_logger_default(logger);
|
|
4696
5008
|
}
|
|
4697
5009
|
/**
|
|
4698
5010
|
* @param endpoint
|
|
@@ -4779,6 +5091,7 @@ var _AdobeCommerceClient = class _AdobeCommerceClient {
|
|
|
4779
5091
|
headers: {
|
|
4780
5092
|
"Content-Type": "application/json"
|
|
4781
5093
|
},
|
|
5094
|
+
...this.httpsOptions && { https: this.httpsOptions },
|
|
4782
5095
|
hooks: {
|
|
4783
5096
|
beforeRequest: [
|
|
4784
5097
|
(options) => this.logger.debug(`Request [${options.method}] ${options.url}`)
|
|
@@ -4814,11 +5127,8 @@ __name(_AdobeCommerceClient, "AdobeCommerceClient");
|
|
|
4814
5127
|
var AdobeCommerceClient = _AdobeCommerceClient;
|
|
4815
5128
|
var adobe_commerce_client_default = AdobeCommerceClient;
|
|
4816
5129
|
|
|
4817
|
-
// src/commerce/adobe-commerce-client/basic-auth-connection/index.ts
|
|
4818
|
-
var import_aio_sdk10 = require("@adobe/aio-sdk");
|
|
4819
|
-
|
|
4820
5130
|
// src/commerce/adobe-commerce-client/basic-auth-connection/generate-basic-auth-token/index.ts
|
|
4821
|
-
var
|
|
5131
|
+
var import_aio_sdk8 = require("@adobe/aio-sdk");
|
|
4822
5132
|
var _GenerateBasicAuthToken = class _GenerateBasicAuthToken {
|
|
4823
5133
|
/**
|
|
4824
5134
|
* @param baseUrl
|
|
@@ -4831,12 +5141,7 @@ var _GenerateBasicAuthToken = class _GenerateBasicAuthToken {
|
|
|
4831
5141
|
this.username = username;
|
|
4832
5142
|
this.password = password;
|
|
4833
5143
|
this.key = "adobe_commerce_basic_auth_token";
|
|
4834
|
-
|
|
4835
|
-
logger = import_aio_sdk9.Core.Logger("adobe-commerce-client", {
|
|
4836
|
-
level: "debug"
|
|
4837
|
-
});
|
|
4838
|
-
}
|
|
4839
|
-
this.logger = logger;
|
|
5144
|
+
this.logger = new custom_logger_default(logger);
|
|
4840
5145
|
}
|
|
4841
5146
|
/**
|
|
4842
5147
|
* @return string | null
|
|
@@ -4973,7 +5278,7 @@ var _GenerateBasicAuthToken = class _GenerateBasicAuthToken {
|
|
|
4973
5278
|
async getState() {
|
|
4974
5279
|
if (this.state === void 0) {
|
|
4975
5280
|
try {
|
|
4976
|
-
this.state = await
|
|
5281
|
+
this.state = await import_aio_sdk8.State.init();
|
|
4977
5282
|
} catch (error) {
|
|
4978
5283
|
this.logger.debug("State API initialization failed, running without caching");
|
|
4979
5284
|
this.state = null;
|
|
@@ -4998,12 +5303,7 @@ var _BasicAuthConnection = class _BasicAuthConnection {
|
|
|
4998
5303
|
this.baseUrl = baseUrl;
|
|
4999
5304
|
this.username = username;
|
|
5000
5305
|
this.password = password;
|
|
5001
|
-
|
|
5002
|
-
logger = import_aio_sdk10.Core.Logger("adobe-commerce-client", {
|
|
5003
|
-
level: "debug"
|
|
5004
|
-
});
|
|
5005
|
-
}
|
|
5006
|
-
this.logger = logger;
|
|
5306
|
+
this.logger = new custom_logger_default(logger);
|
|
5007
5307
|
}
|
|
5008
5308
|
/**
|
|
5009
5309
|
* @param commerceGot
|
|
@@ -5014,7 +5314,7 @@ var _BasicAuthConnection = class _BasicAuthConnection {
|
|
|
5014
5314
|
this.baseUrl,
|
|
5015
5315
|
this.username,
|
|
5016
5316
|
this.password,
|
|
5017
|
-
this.logger
|
|
5317
|
+
this.logger.getLogger()
|
|
5018
5318
|
);
|
|
5019
5319
|
const token = await generateToken.execute();
|
|
5020
5320
|
return commerceGot.extend({
|
|
@@ -5029,9 +5329,8 @@ var BasicAuthConnection = _BasicAuthConnection;
|
|
|
5029
5329
|
var basic_auth_connection_default = BasicAuthConnection;
|
|
5030
5330
|
|
|
5031
5331
|
// src/commerce/adobe-commerce-client/oauth1a-connection/index.ts
|
|
5032
|
-
var import_aio_sdk11 = require("@adobe/aio-sdk");
|
|
5033
5332
|
var import_oauth_1 = __toESM(require("oauth-1.0a"));
|
|
5034
|
-
var
|
|
5333
|
+
var crypto3 = __toESM(require("crypto"));
|
|
5035
5334
|
var _Oauth1aConnection = class _Oauth1aConnection {
|
|
5036
5335
|
/**
|
|
5037
5336
|
* @param consumerKey
|
|
@@ -5045,12 +5344,7 @@ var _Oauth1aConnection = class _Oauth1aConnection {
|
|
|
5045
5344
|
this.consumerSecret = consumerSecret;
|
|
5046
5345
|
this.accessToken = accessToken;
|
|
5047
5346
|
this.accessTokenSecret = accessTokenSecret;
|
|
5048
|
-
|
|
5049
|
-
logger = import_aio_sdk11.Core.Logger("adobe-commerce-client", {
|
|
5050
|
-
level: "debug"
|
|
5051
|
-
});
|
|
5052
|
-
}
|
|
5053
|
-
this.logger = logger;
|
|
5347
|
+
this.logger = new custom_logger_default(logger);
|
|
5054
5348
|
}
|
|
5055
5349
|
/**
|
|
5056
5350
|
* @param commerceGot
|
|
@@ -5080,7 +5374,7 @@ var _Oauth1aConnection = class _Oauth1aConnection {
|
|
|
5080
5374
|
secret: this.consumerSecret
|
|
5081
5375
|
},
|
|
5082
5376
|
signature_method: "HMAC-SHA256",
|
|
5083
|
-
hash_function: /* @__PURE__ */ __name((baseString, key) =>
|
|
5377
|
+
hash_function: /* @__PURE__ */ __name((baseString, key) => crypto3.createHmac("sha256", key).update(baseString).digest("base64"), "hash_function")
|
|
5084
5378
|
});
|
|
5085
5379
|
const oauthToken = {
|
|
5086
5380
|
key: this.accessToken,
|
|
@@ -5094,7 +5388,7 @@ var Oauth1aConnection = _Oauth1aConnection;
|
|
|
5094
5388
|
var oauth1a_connection_default = Oauth1aConnection;
|
|
5095
5389
|
|
|
5096
5390
|
// src/commerce/adobe-commerce-client/ims-connection/generate-ims-token/index.ts
|
|
5097
|
-
var
|
|
5391
|
+
var import_aio_sdk9 = require("@adobe/aio-sdk");
|
|
5098
5392
|
var _GenerateImsToken = class _GenerateImsToken {
|
|
5099
5393
|
/**
|
|
5100
5394
|
* @param clientId
|
|
@@ -5234,7 +5528,7 @@ var _GenerateImsToken = class _GenerateImsToken {
|
|
|
5234
5528
|
if (this.state === void 0) {
|
|
5235
5529
|
try {
|
|
5236
5530
|
this.customLogger.debug("Initializing State API for token caching");
|
|
5237
|
-
this.state = await
|
|
5531
|
+
this.state = await import_aio_sdk9.State.init();
|
|
5238
5532
|
} catch (error) {
|
|
5239
5533
|
this.customLogger.error(`Failed to initialize State API: ${error.message}`);
|
|
5240
5534
|
this.state = null;
|
|
@@ -5297,6 +5591,390 @@ __name(_ImsConnection, "ImsConnection");
|
|
|
5297
5591
|
var ImsConnection = _ImsConnection;
|
|
5298
5592
|
var ims_connection_default = ImsConnection;
|
|
5299
5593
|
|
|
5594
|
+
// src/commerce/shipping-carrier/method/index.ts
|
|
5595
|
+
var _ShippingCarrierMethod = class _ShippingCarrierMethod {
|
|
5596
|
+
constructor(carrierCode, method) {
|
|
5597
|
+
this.methodData = { carrier_code: carrierCode, method, additional_data: [] };
|
|
5598
|
+
}
|
|
5599
|
+
/**
|
|
5600
|
+
* Sets the display name for the shipping method
|
|
5601
|
+
*
|
|
5602
|
+
* @param methodTitle - Display name for the shipping method
|
|
5603
|
+
* @returns The rate builder instance for method chaining
|
|
5604
|
+
*/
|
|
5605
|
+
setMethodTitle(methodTitle) {
|
|
5606
|
+
this.methodData.method_title = methodTitle;
|
|
5607
|
+
return this;
|
|
5608
|
+
}
|
|
5609
|
+
/**
|
|
5610
|
+
* Sets the price charged to the customer
|
|
5611
|
+
*
|
|
5612
|
+
* @param price - Price charged to the customer
|
|
5613
|
+
* @returns The rate builder instance for method chaining
|
|
5614
|
+
*/
|
|
5615
|
+
setPrice(price) {
|
|
5616
|
+
this.methodData.price = price;
|
|
5617
|
+
return this;
|
|
5618
|
+
}
|
|
5619
|
+
/**
|
|
5620
|
+
* Sets the cost to the merchant
|
|
5621
|
+
*
|
|
5622
|
+
* @param cost - Cost to the merchant
|
|
5623
|
+
* @returns The rate builder instance for method chaining
|
|
5624
|
+
*/
|
|
5625
|
+
setCost(cost) {
|
|
5626
|
+
this.methodData.cost = cost;
|
|
5627
|
+
return this;
|
|
5628
|
+
}
|
|
5629
|
+
/**
|
|
5630
|
+
* Adds additional data to the shipping method
|
|
5631
|
+
*
|
|
5632
|
+
* @param key - Key for the additional data
|
|
5633
|
+
* @param value - Value for the additional data
|
|
5634
|
+
* @returns The rate builder instance for method chaining
|
|
5635
|
+
*
|
|
5636
|
+
* @example
|
|
5637
|
+
* ```typescript
|
|
5638
|
+
* rate.addAdditionalData('delivery_time', '3-5 business days')
|
|
5639
|
+
* .addAdditionalData('tracking_available', true);
|
|
5640
|
+
* ```
|
|
5641
|
+
*/
|
|
5642
|
+
addAdditionalData(key, value) {
|
|
5643
|
+
const additionalDataItem = { key, value };
|
|
5644
|
+
this.methodData.additional_data?.push(additionalDataItem);
|
|
5645
|
+
return this;
|
|
5646
|
+
}
|
|
5647
|
+
/**
|
|
5648
|
+
* Gets and returns the shipping carrier method data
|
|
5649
|
+
*
|
|
5650
|
+
* @returns The shipping carrier method data
|
|
5651
|
+
*/
|
|
5652
|
+
getData() {
|
|
5653
|
+
return this.methodData;
|
|
5654
|
+
}
|
|
5655
|
+
};
|
|
5656
|
+
__name(_ShippingCarrierMethod, "ShippingCarrierMethod");
|
|
5657
|
+
var ShippingCarrierMethod = _ShippingCarrierMethod;
|
|
5658
|
+
var method_default = ShippingCarrierMethod;
|
|
5659
|
+
|
|
5660
|
+
// src/commerce/shipping-carrier/index.ts
|
|
5661
|
+
var _ShippingCarrier = class _ShippingCarrier {
|
|
5662
|
+
constructor(code, callback) {
|
|
5663
|
+
this.addedMethods = [];
|
|
5664
|
+
this.removedMethods = [];
|
|
5665
|
+
this.validateCarrierCode(code);
|
|
5666
|
+
this.carrierData = {
|
|
5667
|
+
code,
|
|
5668
|
+
active: true,
|
|
5669
|
+
tracking_available: true,
|
|
5670
|
+
shipping_labels_available: true
|
|
5671
|
+
};
|
|
5672
|
+
this.addedMethods = [];
|
|
5673
|
+
this.removedMethods = [];
|
|
5674
|
+
if (callback) {
|
|
5675
|
+
callback(this);
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
/**
|
|
5679
|
+
* Validates that the carrier code contains only alphanumeric characters and underscores
|
|
5680
|
+
*
|
|
5681
|
+
* @param code - Carrier code to validate
|
|
5682
|
+
* @throws Error if code is invalid
|
|
5683
|
+
*/
|
|
5684
|
+
validateCarrierCode(code) {
|
|
5685
|
+
if (!code || code.trim() === "") {
|
|
5686
|
+
throw new Error("Carrier code cannot be empty");
|
|
5687
|
+
}
|
|
5688
|
+
const validPattern = /^[a-zA-Z0-9_]+$/;
|
|
5689
|
+
if (!validPattern.test(code)) {
|
|
5690
|
+
throw new Error("Carrier code must contain only alphanumeric characters and underscores");
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
/**
|
|
5694
|
+
* Validates that the method code contains only alphanumeric characters and underscores
|
|
5695
|
+
*
|
|
5696
|
+
* @param method - Method code to validate
|
|
5697
|
+
* @throws Error if method code is invalid
|
|
5698
|
+
*/
|
|
5699
|
+
validateMethodCode(method) {
|
|
5700
|
+
if (!method || method.trim() === "") {
|
|
5701
|
+
throw new Error("Method code cannot be empty");
|
|
5702
|
+
}
|
|
5703
|
+
const validPattern = /^[a-zA-Z0-9_]+$/;
|
|
5704
|
+
if (!validPattern.test(method)) {
|
|
5705
|
+
throw new Error("Method code must contain only alphanumeric characters and underscores");
|
|
5706
|
+
}
|
|
5707
|
+
}
|
|
5708
|
+
/**
|
|
5709
|
+
* Sets the title for the shipping carrier
|
|
5710
|
+
*
|
|
5711
|
+
* @param title - Display title for the carrier
|
|
5712
|
+
* @returns The builder instance for method chaining
|
|
5713
|
+
*
|
|
5714
|
+
* @example
|
|
5715
|
+
* ```typescript
|
|
5716
|
+
* carrier.setTitle('FedEx Express');
|
|
5717
|
+
* ```
|
|
5718
|
+
*/
|
|
5719
|
+
setTitle(title) {
|
|
5720
|
+
this.carrierData.title = title;
|
|
5721
|
+
return this;
|
|
5722
|
+
}
|
|
5723
|
+
/**
|
|
5724
|
+
* Sets the stores for the shipping carrier
|
|
5725
|
+
*
|
|
5726
|
+
* @param stores - Array of store codes
|
|
5727
|
+
* @returns The builder instance for method chaining
|
|
5728
|
+
*
|
|
5729
|
+
* @example
|
|
5730
|
+
* ```typescript
|
|
5731
|
+
* carrier.setStores(['default', 'store1', 'store2']);
|
|
5732
|
+
* ```
|
|
5733
|
+
*/
|
|
5734
|
+
setStores(stores) {
|
|
5735
|
+
this.carrierData.stores = stores;
|
|
5736
|
+
return this;
|
|
5737
|
+
}
|
|
5738
|
+
/**
|
|
5739
|
+
* Sets the countries for the shipping carrier
|
|
5740
|
+
*
|
|
5741
|
+
* @param countries - Array of country codes
|
|
5742
|
+
* @returns The builder instance for method chaining
|
|
5743
|
+
*
|
|
5744
|
+
* @example
|
|
5745
|
+
* ```typescript
|
|
5746
|
+
* carrier.setCountries(['US', 'CA', 'MX']);
|
|
5747
|
+
* ```
|
|
5748
|
+
*/
|
|
5749
|
+
setCountries(countries) {
|
|
5750
|
+
this.carrierData.countries = countries;
|
|
5751
|
+
return this;
|
|
5752
|
+
}
|
|
5753
|
+
/**
|
|
5754
|
+
* Sets the sort order for the shipping carrier
|
|
5755
|
+
*
|
|
5756
|
+
* @param sortOrder - Sort order number
|
|
5757
|
+
* @returns The builder instance for method chaining
|
|
5758
|
+
*
|
|
5759
|
+
* @example
|
|
5760
|
+
* ```typescript
|
|
5761
|
+
* carrier.setSortOrder(10);
|
|
5762
|
+
* ```
|
|
5763
|
+
*/
|
|
5764
|
+
setSortOrder(sortOrder) {
|
|
5765
|
+
this.carrierData.sort_order = sortOrder;
|
|
5766
|
+
return this;
|
|
5767
|
+
}
|
|
5768
|
+
/**
|
|
5769
|
+
* Sets the active status for the shipping carrier
|
|
5770
|
+
*
|
|
5771
|
+
* @param active - Active status
|
|
5772
|
+
* @returns The builder instance for method chaining
|
|
5773
|
+
*
|
|
5774
|
+
* @example
|
|
5775
|
+
* ```typescript
|
|
5776
|
+
* carrier.setActive(true);
|
|
5777
|
+
* carrier.setActive(false);
|
|
5778
|
+
* ```
|
|
5779
|
+
*/
|
|
5780
|
+
setActive(active) {
|
|
5781
|
+
this.carrierData.active = active;
|
|
5782
|
+
return this;
|
|
5783
|
+
}
|
|
5784
|
+
/**
|
|
5785
|
+
* Sets the tracking availability for the shipping carrier
|
|
5786
|
+
*
|
|
5787
|
+
* @param trackingAvailable - Tracking availability status
|
|
5788
|
+
* @returns The builder instance for method chaining
|
|
5789
|
+
*
|
|
5790
|
+
* @example
|
|
5791
|
+
* ```typescript
|
|
5792
|
+
* carrier.setTrackingAvailable(true);
|
|
5793
|
+
* carrier.setTrackingAvailable(false);
|
|
5794
|
+
* ```
|
|
5795
|
+
*/
|
|
5796
|
+
setTrackingAvailable(trackingAvailable) {
|
|
5797
|
+
this.carrierData.tracking_available = trackingAvailable;
|
|
5798
|
+
return this;
|
|
5799
|
+
}
|
|
5800
|
+
/**
|
|
5801
|
+
* Sets the shipping labels availability for the shipping carrier
|
|
5802
|
+
*
|
|
5803
|
+
* @param shippingLabelsAvailable - Shipping labels availability status
|
|
5804
|
+
* @returns The builder instance for method chaining
|
|
5805
|
+
*
|
|
5806
|
+
* @example
|
|
5807
|
+
* ```typescript
|
|
5808
|
+
* carrier.setShippingLabelsAvailable(true);
|
|
5809
|
+
* carrier.setShippingLabelsAvailable(false);
|
|
5810
|
+
* ```
|
|
5811
|
+
*/
|
|
5812
|
+
setShippingLabelsAvailable(shippingLabelsAvailable) {
|
|
5813
|
+
this.carrierData.shipping_labels_available = shippingLabelsAvailable;
|
|
5814
|
+
return this;
|
|
5815
|
+
}
|
|
5816
|
+
/**
|
|
5817
|
+
* Sets the carrier data from a ShippingCarrierData object
|
|
5818
|
+
* Note: The code property cannot be changed once set in the constructor
|
|
5819
|
+
*
|
|
5820
|
+
* @param carrierData - Carrier data object
|
|
5821
|
+
* @returns The builder instance for method chaining
|
|
5822
|
+
*
|
|
5823
|
+
* @example
|
|
5824
|
+
* ```typescript
|
|
5825
|
+
* carrier.setData({
|
|
5826
|
+
* code: 'fedex',
|
|
5827
|
+
* title: 'FedEx Express',
|
|
5828
|
+
* stores: ['default'],
|
|
5829
|
+
* countries: ['US', 'CA'],
|
|
5830
|
+
* sort_order: 10,
|
|
5831
|
+
* active: true,
|
|
5832
|
+
* tracking_available: true,
|
|
5833
|
+
* shipping_labels_available: true
|
|
5834
|
+
* });
|
|
5835
|
+
* ```
|
|
5836
|
+
*/
|
|
5837
|
+
setData(carrierData) {
|
|
5838
|
+
const originalCode = this.carrierData.code;
|
|
5839
|
+
if (carrierData.code !== void 0) {
|
|
5840
|
+
this.validateCarrierCode(carrierData.code);
|
|
5841
|
+
}
|
|
5842
|
+
this.carrierData = { ...carrierData, code: originalCode };
|
|
5843
|
+
return this;
|
|
5844
|
+
}
|
|
5845
|
+
/**
|
|
5846
|
+
* Adds a shipping method to the carrier using a callback pattern
|
|
5847
|
+
*
|
|
5848
|
+
* @param method - Unique method for the shipping rate
|
|
5849
|
+
* @param callback - Optional callback function to configure the method
|
|
5850
|
+
* @returns The builder instance for method chaining
|
|
5851
|
+
*
|
|
5852
|
+
* @example
|
|
5853
|
+
* ```typescript
|
|
5854
|
+
* builder.addMethod('standard', (method) => {
|
|
5855
|
+
* method.setMethodTitle('Standard Shipping')
|
|
5856
|
+
* .setPrice(9.99)
|
|
5857
|
+
* .setCost(5.00)
|
|
5858
|
+
* .addAdditionalData('delivery_time', '3-5 business days');
|
|
5859
|
+
* });
|
|
5860
|
+
* ```
|
|
5861
|
+
*/
|
|
5862
|
+
addMethod(method, callback) {
|
|
5863
|
+
this.validateMethodCode(method);
|
|
5864
|
+
const methodBuilder = new method_default(this.carrierData.code, method);
|
|
5865
|
+
if (callback) {
|
|
5866
|
+
callback(methodBuilder);
|
|
5867
|
+
}
|
|
5868
|
+
this.addedMethods.push(methodBuilder.getData());
|
|
5869
|
+
return this;
|
|
5870
|
+
}
|
|
5871
|
+
/**
|
|
5872
|
+
* Removes a shipping method from the carrier
|
|
5873
|
+
*
|
|
5874
|
+
* @param method - Method code to remove
|
|
5875
|
+
* @returns The builder instance for method chaining
|
|
5876
|
+
*
|
|
5877
|
+
* @example
|
|
5878
|
+
* ```typescript
|
|
5879
|
+
* builder.removeMethod('express');
|
|
5880
|
+
* ```
|
|
5881
|
+
*/
|
|
5882
|
+
removeMethod(method) {
|
|
5883
|
+
this.validateMethodCode(method);
|
|
5884
|
+
this.removedMethods.push(method);
|
|
5885
|
+
return this;
|
|
5886
|
+
}
|
|
5887
|
+
/**
|
|
5888
|
+
* Gets and returns the shipping carrier data as a JSON object
|
|
5889
|
+
*
|
|
5890
|
+
* @returns The shipping carrier data
|
|
5891
|
+
*
|
|
5892
|
+
* @example
|
|
5893
|
+
* ```typescript
|
|
5894
|
+
* const carrierData = carrier.getData();
|
|
5895
|
+
* // Returns:
|
|
5896
|
+
* // {
|
|
5897
|
+
* // code: 'DPS',
|
|
5898
|
+
* // title: 'Demo Postal Service',
|
|
5899
|
+
* // stores: ['default'],
|
|
5900
|
+
* // countries: ['US', 'CA'],
|
|
5901
|
+
* // sort_order: 10,
|
|
5902
|
+
* // active: true,
|
|
5903
|
+
* // tracking_available: true,
|
|
5904
|
+
* // shipping_labels_available: true
|
|
5905
|
+
* // }
|
|
5906
|
+
* ```
|
|
5907
|
+
*/
|
|
5908
|
+
getData() {
|
|
5909
|
+
return this.carrierData;
|
|
5910
|
+
}
|
|
5911
|
+
/**
|
|
5912
|
+
* Gets the list of methods that have been added to the carrier
|
|
5913
|
+
*
|
|
5914
|
+
* @returns Array of added shipping carrier methods
|
|
5915
|
+
*
|
|
5916
|
+
* @example
|
|
5917
|
+
* ```typescript
|
|
5918
|
+
* const addedMethods = carrier.getAddedMethods();
|
|
5919
|
+
* // Returns: [{ carrier_code: 'fedex', method: 'standard', ... }, ...]
|
|
5920
|
+
* ```
|
|
5921
|
+
*/
|
|
5922
|
+
getAddedMethods() {
|
|
5923
|
+
return this.addedMethods;
|
|
5924
|
+
}
|
|
5925
|
+
/**
|
|
5926
|
+
* Gets the list of method codes that have been marked for removal
|
|
5927
|
+
*
|
|
5928
|
+
* @returns Array of method codes to be removed
|
|
5929
|
+
*
|
|
5930
|
+
* @example
|
|
5931
|
+
* ```typescript
|
|
5932
|
+
* const removedMethods = carrier.getRemovedMethods();
|
|
5933
|
+
* // Returns: ['overnight', 'express']
|
|
5934
|
+
* ```
|
|
5935
|
+
*/
|
|
5936
|
+
getRemovedMethods() {
|
|
5937
|
+
return this.removedMethods;
|
|
5938
|
+
}
|
|
5939
|
+
};
|
|
5940
|
+
__name(_ShippingCarrier, "ShippingCarrier");
|
|
5941
|
+
var ShippingCarrier = _ShippingCarrier;
|
|
5942
|
+
var shipping_carrier_default = ShippingCarrier;
|
|
5943
|
+
|
|
5944
|
+
// src/commerce/shipping-carrier/response/index.ts
|
|
5945
|
+
var _ShippingCarrierResponse = class _ShippingCarrierResponse {
|
|
5946
|
+
constructor(carrier) {
|
|
5947
|
+
this.carrier = carrier;
|
|
5948
|
+
}
|
|
5949
|
+
/**
|
|
5950
|
+
* Generates and returns an array of WebhookActionResponse operations
|
|
5951
|
+
*
|
|
5952
|
+
* @returns Array of WebhookActionResponse operations
|
|
5953
|
+
*
|
|
5954
|
+
* @example
|
|
5955
|
+
* ```typescript
|
|
5956
|
+
* const carrier = new ShippingCarrier('fedex');
|
|
5957
|
+
* const response = new ShippingCarrierResponse(carrier);
|
|
5958
|
+
* const operations = response.generate();
|
|
5959
|
+
* ```
|
|
5960
|
+
*/
|
|
5961
|
+
generate() {
|
|
5962
|
+
const operations = [];
|
|
5963
|
+
const addedMethods = this.carrier["addedMethods"];
|
|
5964
|
+
for (const method of addedMethods) {
|
|
5965
|
+
operations.push(response_default2.add("result", method));
|
|
5966
|
+
}
|
|
5967
|
+
const removedMethods = this.carrier["removedMethods"];
|
|
5968
|
+
for (const method of removedMethods) {
|
|
5969
|
+
operations.push(response_default2.add("result", { method, remove: true }));
|
|
5970
|
+
}
|
|
5971
|
+
return operations;
|
|
5972
|
+
}
|
|
5973
|
+
};
|
|
5974
|
+
__name(_ShippingCarrierResponse, "ShippingCarrierResponse");
|
|
5975
|
+
var ShippingCarrierResponse = _ShippingCarrierResponse;
|
|
5976
|
+
var response_default3 = ShippingCarrierResponse;
|
|
5977
|
+
|
|
5300
5978
|
// src/experience/admin-ui-sdk/index.ts
|
|
5301
5979
|
var _AdminUiSdk = class _AdminUiSdk {
|
|
5302
5980
|
/**
|
|
@@ -5487,6 +6165,13 @@ var AdminUiSdk = _AdminUiSdk;
|
|
|
5487
6165
|
RestClient,
|
|
5488
6166
|
RuntimeAction,
|
|
5489
6167
|
RuntimeActionResponse,
|
|
5490
|
-
|
|
6168
|
+
ShippingCarrier,
|
|
6169
|
+
ShippingCarrierMethod,
|
|
6170
|
+
ShippingCarrierResponse,
|
|
6171
|
+
SignatureVerification,
|
|
6172
|
+
Validator,
|
|
6173
|
+
WebhookAction,
|
|
6174
|
+
WebhookActionOperation,
|
|
6175
|
+
WebhookActionResponse
|
|
5491
6176
|
});
|
|
5492
6177
|
//# sourceMappingURL=index.js.map
|