@rezamirzapour/pod-sdk 1.0.2 → 1.0.3
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/README.md +214 -210
- package/dist/index.d.mts +593 -44
- package/dist/index.d.ts +593 -44
- package/dist/index.js +903 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +903 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -675,7 +675,7 @@ var CmsDataFormatter = class {
|
|
|
675
675
|
generateImage(hash, defaultSrc = "") {
|
|
676
676
|
return hash ? `${this.podspaceUrl}/api/images/${hash}?dl=1` : defaultSrc;
|
|
677
677
|
}
|
|
678
|
-
|
|
678
|
+
formatItem(item, normalizer) {
|
|
679
679
|
if (typeof item === "number" || !item || typeof item !== "object") {
|
|
680
680
|
return item;
|
|
681
681
|
}
|
|
@@ -685,23 +685,31 @@ var CmsDataFormatter = class {
|
|
|
685
685
|
__normalized: {}
|
|
686
686
|
};
|
|
687
687
|
const formatted = {};
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}
|
|
695
|
-
default:
|
|
696
|
-
formatted[detail.code] = detail.value !== void 0 ? detail.value : "";
|
|
688
|
+
const fieldList = Array.isArray(item?.metadata?.content) ? item.metadata.content : Array.isArray(item?.metadata?.product) ? item.metadata.product : [];
|
|
689
|
+
fieldList.forEach((detail) => {
|
|
690
|
+
switch (detail.type) {
|
|
691
|
+
case "IMAGE_TYPE": {
|
|
692
|
+
formatted[detail.code] = Array.isArray(detail.value) ? detail.value.map((v) => this.generateImage(v)) : this.generateImage(detail.value);
|
|
693
|
+
break;
|
|
697
694
|
}
|
|
698
|
-
|
|
699
|
-
|
|
695
|
+
default:
|
|
696
|
+
formatted[detail.code] = detail.value !== void 0 ? detail.value : "";
|
|
697
|
+
}
|
|
698
|
+
});
|
|
700
699
|
if (Array.isArray(item?.metadata?.content_related)) {
|
|
701
700
|
item.metadata.content_related.forEach((detail) => {
|
|
702
701
|
if (detail?.uniqueId && Array.isArray(detail.values)) {
|
|
703
702
|
formatted[detail.uniqueId] = detail.values.map(
|
|
704
|
-
(val) => this.
|
|
703
|
+
(val) => this.formatItem(val)
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
if (Array.isArray(item?.metadata?.product_related)) {
|
|
709
|
+
item.metadata.product_related.forEach((detail) => {
|
|
710
|
+
if (detail?.uniqueId && Array.isArray(detail.values)) {
|
|
711
|
+
formatted[detail.uniqueId] = detail.values.map(
|
|
712
|
+
(val) => this.formatItem(val)
|
|
705
713
|
);
|
|
706
714
|
}
|
|
707
715
|
});
|
|
@@ -712,6 +720,12 @@ var CmsDataFormatter = class {
|
|
|
712
720
|
}
|
|
713
721
|
return newItem;
|
|
714
722
|
}
|
|
723
|
+
formatContentItem(item, normalizer) {
|
|
724
|
+
return this.formatItem(item, normalizer);
|
|
725
|
+
}
|
|
726
|
+
formatProductItem(item, normalizer) {
|
|
727
|
+
return this.formatItem(item, normalizer);
|
|
728
|
+
}
|
|
715
729
|
formatGetContentResponse(response, normalizer) {
|
|
716
730
|
if (response && Array.isArray(response.result)) {
|
|
717
731
|
const result = response.result.map(
|
|
@@ -724,10 +738,20 @@ var CmsDataFormatter = class {
|
|
|
724
738
|
}
|
|
725
739
|
return response || {};
|
|
726
740
|
}
|
|
741
|
+
formatGetProductResponse(response, normalizer) {
|
|
742
|
+
if (response && Array.isArray(response.result)) {
|
|
743
|
+
const result = response.result.map(
|
|
744
|
+
(item) => this.formatProductItem(item, normalizer)
|
|
745
|
+
);
|
|
746
|
+
return {
|
|
747
|
+
...response,
|
|
748
|
+
result
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
return response || {};
|
|
752
|
+
}
|
|
727
753
|
};
|
|
728
|
-
|
|
729
|
-
// src/services/cms/index.ts
|
|
730
|
-
var CmsService = class {
|
|
754
|
+
var CmsProductService = class {
|
|
731
755
|
http;
|
|
732
756
|
formatter;
|
|
733
757
|
clientId;
|
|
@@ -737,10 +761,10 @@ var CmsService = class {
|
|
|
737
761
|
this.clientId = options.clientId || "";
|
|
738
762
|
this.apiToken = options.apiToken || "";
|
|
739
763
|
this.revalidate = Number(options.revalidate) || 0;
|
|
740
|
-
this.formatter = new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
|
|
741
|
-
this.http = createNextHttp({
|
|
742
|
-
baseUrl: options.baseUrl,
|
|
743
|
-
serviceName: "POD-CMS"
|
|
764
|
+
this.formatter = options.formatter || new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
|
|
765
|
+
this.http = options.http || createNextHttp({
|
|
766
|
+
baseUrl: options.baseUrl || "https://cms.pod.ir",
|
|
767
|
+
serviceName: "POD-CMS-PRODUCT"
|
|
744
768
|
});
|
|
745
769
|
}
|
|
746
770
|
get commonHeaders() {
|
|
@@ -756,9 +780,10 @@ var CmsService = class {
|
|
|
756
780
|
};
|
|
757
781
|
}
|
|
758
782
|
/**
|
|
759
|
-
* Retrieves enabled published
|
|
783
|
+
* Retrieves enabled published products from CMS, formatted with generic metadata type T and optional normalized type P.
|
|
784
|
+
* Swagger: GET /api/core/products/enable
|
|
760
785
|
*/
|
|
761
|
-
async
|
|
786
|
+
async getProducts(params = {}, options = {}) {
|
|
762
787
|
const transferParams = {
|
|
763
788
|
size: 50,
|
|
764
789
|
offset: 0,
|
|
@@ -766,7 +791,7 @@ var CmsService = class {
|
|
|
766
791
|
...params
|
|
767
792
|
};
|
|
768
793
|
try {
|
|
769
|
-
const res = await this.http.get("/api/core/
|
|
794
|
+
const res = await this.http.get("/api/core/products/enable", {
|
|
770
795
|
params: transferParams,
|
|
771
796
|
headers: {
|
|
772
797
|
...this.commonHeaders,
|
|
@@ -778,15 +803,16 @@ var CmsService = class {
|
|
|
778
803
|
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
779
804
|
}
|
|
780
805
|
});
|
|
781
|
-
return this.formatter.
|
|
806
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
782
807
|
} catch {
|
|
783
808
|
return { hasError: true, result: [] };
|
|
784
809
|
}
|
|
785
810
|
}
|
|
786
811
|
/**
|
|
787
|
-
* Retrieves
|
|
812
|
+
* Retrieves all products using Provider credentials (Access-Token).
|
|
813
|
+
* Swagger: GET /api/core/products
|
|
788
814
|
*/
|
|
789
|
-
async
|
|
815
|
+
async getAllProducts(params = {}, options = {}) {
|
|
790
816
|
const transferParams = {
|
|
791
817
|
size: 50,
|
|
792
818
|
offset: 0,
|
|
@@ -794,7 +820,7 @@ var CmsService = class {
|
|
|
794
820
|
...params
|
|
795
821
|
};
|
|
796
822
|
try {
|
|
797
|
-
const res = await this.http.get("/api/core/
|
|
823
|
+
const res = await this.http.get("/api/core/products", {
|
|
798
824
|
params: transferParams,
|
|
799
825
|
headers: {
|
|
800
826
|
...this.managingHeaders,
|
|
@@ -806,24 +832,24 @@ var CmsService = class {
|
|
|
806
832
|
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
807
833
|
}
|
|
808
834
|
});
|
|
809
|
-
return this.formatter.
|
|
835
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
810
836
|
} catch {
|
|
811
837
|
return { hasError: true, result: [] };
|
|
812
838
|
}
|
|
813
839
|
}
|
|
814
840
|
/**
|
|
815
|
-
* Retrieves
|
|
841
|
+
* Retrieves products for management view.
|
|
842
|
+
* Swagger: GET /api/core/products/manage
|
|
816
843
|
*/
|
|
817
|
-
async
|
|
844
|
+
async getManageProducts(params = {}, options = {}) {
|
|
818
845
|
const transferParams = {
|
|
819
846
|
size: 50,
|
|
820
847
|
offset: 0,
|
|
821
848
|
showDetail: true,
|
|
822
|
-
enable: false,
|
|
823
849
|
...params
|
|
824
850
|
};
|
|
825
851
|
try {
|
|
826
|
-
const res = await this.http.get("/api/core/
|
|
852
|
+
const res = await this.http.get("/api/core/products/manage", {
|
|
827
853
|
params: transferParams,
|
|
828
854
|
headers: {
|
|
829
855
|
...this.managingHeaders,
|
|
@@ -835,16 +861,49 @@ var CmsService = class {
|
|
|
835
861
|
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
836
862
|
}
|
|
837
863
|
});
|
|
838
|
-
return this.formatter.
|
|
864
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
839
865
|
} catch {
|
|
840
866
|
return { hasError: true, result: [] };
|
|
841
867
|
}
|
|
842
868
|
}
|
|
843
869
|
/**
|
|
844
|
-
* Retrieves
|
|
870
|
+
* Retrieves products by ProductType unique identifier.
|
|
871
|
+
* Swagger: GET /api/core/products/{productTypeUniqueId}
|
|
845
872
|
*/
|
|
846
|
-
async
|
|
847
|
-
const
|
|
873
|
+
async getProductsByType(productTypeUniqueId, params = {}, options = {}) {
|
|
874
|
+
const transferParams = {
|
|
875
|
+
size: 50,
|
|
876
|
+
offset: 0,
|
|
877
|
+
showDetail: true,
|
|
878
|
+
...params
|
|
879
|
+
};
|
|
880
|
+
try {
|
|
881
|
+
const res = await this.http.get(
|
|
882
|
+
`/api/core/products/${productTypeUniqueId}`,
|
|
883
|
+
{
|
|
884
|
+
params: transferParams,
|
|
885
|
+
headers: {
|
|
886
|
+
...this.managingHeaders,
|
|
887
|
+
...options.headers
|
|
888
|
+
},
|
|
889
|
+
cache: options.cache,
|
|
890
|
+
signal: options.signal,
|
|
891
|
+
next: {
|
|
892
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
);
|
|
896
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
897
|
+
} catch {
|
|
898
|
+
return { hasError: true, result: [] };
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Retrieves a single published product by entityId.
|
|
903
|
+
* Swagger: GET /api/core/products/enable/{entityId} OR /api/core/products/{productTypeUniqueId}/enable/{entityId}
|
|
904
|
+
*/
|
|
905
|
+
async getProductByEntityId(params, options = {}) {
|
|
906
|
+
const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/enable/${params.entityId}` : `/api/core/products/enable/${params.entityId}`;
|
|
848
907
|
try {
|
|
849
908
|
const res = await this.http.get(url, {
|
|
850
909
|
headers: {
|
|
@@ -857,72 +916,244 @@ var CmsService = class {
|
|
|
857
916
|
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
858
917
|
}
|
|
859
918
|
});
|
|
860
|
-
return this.formatter.
|
|
919
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
861
920
|
} catch {
|
|
862
921
|
return { hasError: true, result: [] };
|
|
863
922
|
}
|
|
864
923
|
}
|
|
865
924
|
/**
|
|
866
|
-
* Retrieves
|
|
925
|
+
* Retrieves a single product by uniqueId.
|
|
926
|
+
* Swagger: GET /api/core/products/{productUniqueId}/byProductUniqueId/enable
|
|
867
927
|
*/
|
|
868
|
-
async
|
|
928
|
+
async getProductByUniqueId(productUniqueId, options = {}) {
|
|
869
929
|
try {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
930
|
+
const res = await this.http.get(
|
|
931
|
+
`/api/core/products/${productUniqueId}/byProductUniqueId/enable`,
|
|
932
|
+
{
|
|
933
|
+
headers: {
|
|
934
|
+
...this.commonHeaders,
|
|
935
|
+
...options.headers
|
|
936
|
+
},
|
|
937
|
+
cache: options.cache,
|
|
938
|
+
signal: options.signal,
|
|
939
|
+
next: {
|
|
940
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
941
|
+
}
|
|
880
942
|
}
|
|
881
|
-
|
|
943
|
+
);
|
|
944
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
882
945
|
} catch {
|
|
883
946
|
return { hasError: true, result: [] };
|
|
884
947
|
}
|
|
885
948
|
}
|
|
886
949
|
/**
|
|
887
|
-
* Retrieves
|
|
950
|
+
* Retrieves products matching a barcode.
|
|
951
|
+
* Swagger: GET /api/core/products/barcode/enable
|
|
888
952
|
*/
|
|
889
|
-
async
|
|
953
|
+
async getProductByBarcode(barcode, options = {}) {
|
|
890
954
|
try {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
955
|
+
const res = await this.http.get(
|
|
956
|
+
"/api/core/products/barcode/enable",
|
|
957
|
+
{
|
|
958
|
+
params: { barcode },
|
|
959
|
+
headers: {
|
|
960
|
+
...this.commonHeaders,
|
|
961
|
+
...options.headers
|
|
962
|
+
},
|
|
963
|
+
cache: options.cache,
|
|
964
|
+
signal: options.signal,
|
|
965
|
+
next: {
|
|
966
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
);
|
|
970
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
894
971
|
} catch {
|
|
895
|
-
return {};
|
|
972
|
+
return { hasError: true, result: [] };
|
|
896
973
|
}
|
|
897
974
|
}
|
|
898
975
|
/**
|
|
899
|
-
*
|
|
976
|
+
* Searches published products by keyword.
|
|
977
|
+
* Swagger: GET /api/core/products/enable/search
|
|
900
978
|
*/
|
|
901
|
-
async
|
|
979
|
+
async searchProducts(params = {}, options = {}) {
|
|
980
|
+
try {
|
|
981
|
+
const res = await this.http.get(
|
|
982
|
+
"/api/core/products/enable/search",
|
|
983
|
+
{
|
|
984
|
+
params,
|
|
985
|
+
headers: {
|
|
986
|
+
...this.commonHeaders,
|
|
987
|
+
...options.headers
|
|
988
|
+
},
|
|
989
|
+
cache: options.cache,
|
|
990
|
+
signal: options.signal,
|
|
991
|
+
next: {
|
|
992
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
);
|
|
996
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
997
|
+
} catch {
|
|
998
|
+
return { hasError: true, result: [] };
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Creates and publishes a new product.
|
|
1003
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/add-publish
|
|
1004
|
+
*/
|
|
1005
|
+
async addProduct(params, options = {}) {
|
|
902
1006
|
const res = await this.http.post(
|
|
903
|
-
`/api/core/
|
|
1007
|
+
`/api/core/products/${params.productTypeUniqueId}/add-publish`,
|
|
904
1008
|
params.body,
|
|
905
1009
|
{
|
|
906
1010
|
headers: this.managingHeaders
|
|
907
1011
|
}
|
|
908
1012
|
);
|
|
909
|
-
return this.formatter.
|
|
1013
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
910
1014
|
}
|
|
911
1015
|
/**
|
|
912
|
-
*
|
|
1016
|
+
* Creates a draft/unpublished product.
|
|
1017
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}
|
|
913
1018
|
*/
|
|
914
|
-
async
|
|
1019
|
+
async createProduct(params, options = {}) {
|
|
915
1020
|
const res = await this.http.post(
|
|
916
|
-
`/api/core/
|
|
1021
|
+
`/api/core/products/${params.productTypeUniqueId}`,
|
|
917
1022
|
params.body,
|
|
918
1023
|
{
|
|
919
1024
|
headers: this.managingHeaders
|
|
920
1025
|
}
|
|
921
1026
|
);
|
|
922
|
-
return this.formatter.
|
|
1027
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Edits and publishes an existing product by entityId.
|
|
1031
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/{entityId}/edit-publish
|
|
1032
|
+
*/
|
|
1033
|
+
async editProduct(entityId, params, options = {}) {
|
|
1034
|
+
const res = await this.http.post(
|
|
1035
|
+
`/api/core/products/${params.productTypeUniqueId}/${entityId}/edit-publish`,
|
|
1036
|
+
params.body,
|
|
1037
|
+
{
|
|
1038
|
+
headers: this.managingHeaders
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Updates an existing product.
|
|
1045
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/{entityId}
|
|
1046
|
+
*/
|
|
1047
|
+
async updateProduct(entityId, params, options = {}) {
|
|
1048
|
+
const res = await this.http.post(
|
|
1049
|
+
`/api/core/products/${params.productTypeUniqueId}/${entityId}`,
|
|
1050
|
+
params.body,
|
|
1051
|
+
{
|
|
1052
|
+
headers: this.managingHeaders
|
|
1053
|
+
}
|
|
1054
|
+
);
|
|
1055
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Partially updates an existing product.
|
|
1059
|
+
* Swagger: PATCH /api/core/products/{productTypeUniqueId}/{entityId}
|
|
1060
|
+
*/
|
|
1061
|
+
async patchProduct(entityId, params, options = {}) {
|
|
1062
|
+
const res = await this.http.patch(
|
|
1063
|
+
`/api/core/products/${params.productTypeUniqueId}/${entityId}`,
|
|
1064
|
+
params.body,
|
|
1065
|
+
{
|
|
1066
|
+
headers: this.managingHeaders
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1069
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Publishes an existing product.
|
|
1073
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/publish/{entityId}
|
|
1074
|
+
*/
|
|
1075
|
+
async publishProduct(productTypeUniqueId, entityId) {
|
|
1076
|
+
return this.http.post(
|
|
1077
|
+
`/api/core/products/${productTypeUniqueId}/publish/${entityId}`,
|
|
1078
|
+
{},
|
|
1079
|
+
{
|
|
1080
|
+
headers: this.managingHeaders
|
|
1081
|
+
}
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Unpublishes an existing product.
|
|
1086
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/unpublish/{entityId}
|
|
1087
|
+
*/
|
|
1088
|
+
async unpublishProduct(productTypeUniqueId, entityId) {
|
|
1089
|
+
return this.http.post(
|
|
1090
|
+
`/api/core/products/${productTypeUniqueId}/unpublish/${entityId}`,
|
|
1091
|
+
{},
|
|
1092
|
+
{
|
|
1093
|
+
headers: this.managingHeaders
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Batch publishes products.
|
|
1099
|
+
* Swagger: PUT /api/core/products/{productTypeUniqueId}/publish OR /api/core/products/publish
|
|
1100
|
+
*/
|
|
1101
|
+
async batchPublish(params) {
|
|
1102
|
+
const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/publish` : "/api/core/products/publish";
|
|
1103
|
+
return this.http.put(url, { entityIds: params.entityIds }, {
|
|
1104
|
+
headers: this.managingHeaders
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Batch unpublishes products.
|
|
1109
|
+
* Swagger: PUT /api/core/products/{productTypeUniqueId}/unpublish OR /api/core/products/unpublish
|
|
1110
|
+
*/
|
|
1111
|
+
async batchUnpublish(params) {
|
|
1112
|
+
const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/unpublish` : "/api/core/products/unpublish";
|
|
1113
|
+
return this.http.put(url, { entityIds: params.entityIds }, {
|
|
1114
|
+
headers: this.managingHeaders
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Archives products.
|
|
1119
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/archive OR /api/core/products/archive
|
|
1120
|
+
*/
|
|
1121
|
+
async archiveProduct(params) {
|
|
1122
|
+
const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/archive` : "/api/core/products/archive";
|
|
1123
|
+
return this.http.post(url, { entityIds: params.entityIds }, {
|
|
1124
|
+
headers: this.managingHeaders
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Unarchives products.
|
|
1129
|
+
* Swagger: POST /api/core/products/{productTypeUniqueId}/unarchive OR /api/core/products/unarchive
|
|
1130
|
+
*/
|
|
1131
|
+
async unarchiveProduct(params) {
|
|
1132
|
+
const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/unarchive` : "/api/core/products/unarchive";
|
|
1133
|
+
return this.http.post(url, { entityIds: params.entityIds }, {
|
|
1134
|
+
headers: this.managingHeaders
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Gets list of archived products.
|
|
1139
|
+
* Swagger: GET /api/core/products/archive OR /api/core/products/{productTypeUniqueId}/archive
|
|
1140
|
+
*/
|
|
1141
|
+
async getArchivedProducts(params = {}, options = {}) {
|
|
1142
|
+
const { productTypeUniqueId, ...rest } = params;
|
|
1143
|
+
const url = productTypeUniqueId ? `/api/core/products/${productTypeUniqueId}/archive` : "/api/core/products/archive";
|
|
1144
|
+
try {
|
|
1145
|
+
const res = await this.http.get(url, {
|
|
1146
|
+
params: rest,
|
|
1147
|
+
headers: this.managingHeaders
|
|
1148
|
+
});
|
|
1149
|
+
return this.formatter.formatGetProductResponse(res, options.normalizer);
|
|
1150
|
+
} catch {
|
|
1151
|
+
return { hasError: true, result: [] };
|
|
1152
|
+
}
|
|
923
1153
|
}
|
|
924
1154
|
/**
|
|
925
|
-
* Performs advanced AI timeline search.
|
|
1155
|
+
* Performs advanced AI timeline search on products.
|
|
1156
|
+
* Swagger: GET /api/core/products/ai/timeline-search/enable
|
|
926
1157
|
*/
|
|
927
1158
|
async timelineSearch(query) {
|
|
928
1159
|
const params = {};
|
|
@@ -933,11 +1164,612 @@ var CmsService = class {
|
|
|
933
1164
|
if (query?.offset) {
|
|
934
1165
|
params.offset = query.offset;
|
|
935
1166
|
}
|
|
936
|
-
|
|
937
|
-
params
|
|
938
|
-
|
|
1167
|
+
if (query?.size) {
|
|
1168
|
+
params.size = query.size;
|
|
1169
|
+
}
|
|
1170
|
+
return this.http.get(
|
|
1171
|
+
"/api/core/products/ai/timeline-search/enable",
|
|
1172
|
+
{
|
|
1173
|
+
params,
|
|
1174
|
+
headers: this.commonHeaders
|
|
1175
|
+
}
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
// src/services/cms/index.ts
|
|
1181
|
+
var CmsService = class {
|
|
1182
|
+
http;
|
|
1183
|
+
formatter;
|
|
1184
|
+
clientId;
|
|
1185
|
+
apiToken;
|
|
1186
|
+
revalidate;
|
|
1187
|
+
/**
|
|
1188
|
+
* Dedicated CMS Product sub-service.
|
|
1189
|
+
* Swagger: tag=product
|
|
1190
|
+
*/
|
|
1191
|
+
products;
|
|
1192
|
+
constructor(options) {
|
|
1193
|
+
this.clientId = options.clientId || "";
|
|
1194
|
+
this.apiToken = options.apiToken || "";
|
|
1195
|
+
this.revalidate = Number(options.revalidate) || 0;
|
|
1196
|
+
this.formatter = new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
|
|
1197
|
+
this.http = createNextHttp({
|
|
1198
|
+
baseUrl: options.baseUrl,
|
|
1199
|
+
serviceName: "POD-CMS"
|
|
1200
|
+
});
|
|
1201
|
+
this.products = new CmsProductService({
|
|
1202
|
+
http: this.http,
|
|
1203
|
+
formatter: this.formatter,
|
|
1204
|
+
clientId: this.clientId,
|
|
1205
|
+
apiToken: this.apiToken,
|
|
1206
|
+
revalidate: this.revalidate
|
|
939
1207
|
});
|
|
940
1208
|
}
|
|
1209
|
+
get commonHeaders() {
|
|
1210
|
+
return {
|
|
1211
|
+
"Client-Id": this.clientId,
|
|
1212
|
+
"Content-Type": "application/json"
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
get managingHeaders() {
|
|
1216
|
+
return {
|
|
1217
|
+
...this.commonHeaders,
|
|
1218
|
+
"Access-Token": this.apiToken
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
// =========================================================================
|
|
1222
|
+
// CONTENT METHODS (Swagger: tag=content)
|
|
1223
|
+
// =========================================================================
|
|
1224
|
+
/**
|
|
1225
|
+
* Retrieves enabled published content from CMS, formatted with generic metadata type T and optional normalized type P.
|
|
1226
|
+
* Swagger: GET /api/core/contents/enable
|
|
1227
|
+
*/
|
|
1228
|
+
async getContent(params = {}, options = {}) {
|
|
1229
|
+
const transferParams = {
|
|
1230
|
+
size: 50,
|
|
1231
|
+
offset: 0,
|
|
1232
|
+
showDetail: true,
|
|
1233
|
+
...params
|
|
1234
|
+
};
|
|
1235
|
+
try {
|
|
1236
|
+
const res = await this.http.get("/api/core/contents/enable", {
|
|
1237
|
+
params: transferParams,
|
|
1238
|
+
headers: {
|
|
1239
|
+
...this.commonHeaders,
|
|
1240
|
+
...options.headers
|
|
1241
|
+
},
|
|
1242
|
+
cache: options.cache,
|
|
1243
|
+
signal: options.signal,
|
|
1244
|
+
next: {
|
|
1245
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1249
|
+
} catch {
|
|
1250
|
+
return { hasError: true, result: [] };
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Retrieves all contents using managing credentials (Access-Token).
|
|
1255
|
+
* Swagger: GET /api/core/contents
|
|
1256
|
+
*/
|
|
1257
|
+
async getAllContents(params = {}, options = {}) {
|
|
1258
|
+
const transferParams = {
|
|
1259
|
+
size: 50,
|
|
1260
|
+
offset: 0,
|
|
1261
|
+
showDetail: true,
|
|
1262
|
+
...params
|
|
1263
|
+
};
|
|
1264
|
+
try {
|
|
1265
|
+
const res = await this.http.get("/api/core/contents", {
|
|
1266
|
+
params: transferParams,
|
|
1267
|
+
headers: {
|
|
1268
|
+
...this.managingHeaders,
|
|
1269
|
+
...options.headers
|
|
1270
|
+
},
|
|
1271
|
+
cache: options.cache,
|
|
1272
|
+
signal: options.signal,
|
|
1273
|
+
next: {
|
|
1274
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1278
|
+
} catch {
|
|
1279
|
+
return { hasError: true, result: [] };
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Retrieves current user/client contents.
|
|
1284
|
+
* Swagger: GET /api/core/contents/my
|
|
1285
|
+
*/
|
|
1286
|
+
async getMyContents(params = {}, options = {}) {
|
|
1287
|
+
const transferParams = {
|
|
1288
|
+
size: 50,
|
|
1289
|
+
offset: 0,
|
|
1290
|
+
showDetail: true,
|
|
1291
|
+
...params
|
|
1292
|
+
};
|
|
1293
|
+
try {
|
|
1294
|
+
const res = await this.http.get("/api/core/contents/my", {
|
|
1295
|
+
params: transferParams,
|
|
1296
|
+
headers: {
|
|
1297
|
+
...this.managingHeaders,
|
|
1298
|
+
...options.headers
|
|
1299
|
+
},
|
|
1300
|
+
cache: options.cache,
|
|
1301
|
+
signal: options.signal,
|
|
1302
|
+
next: {
|
|
1303
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1307
|
+
} catch {
|
|
1308
|
+
return { hasError: true, result: [] };
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Retrieves contents by ContentType unique identifier.
|
|
1313
|
+
* Swagger: GET /api/core/contents/{contentTypeUniqueId}
|
|
1314
|
+
*/
|
|
1315
|
+
async getContentsByType(contentTypeUniqueId, params = {}, options = {}) {
|
|
1316
|
+
const transferParams = {
|
|
1317
|
+
size: 50,
|
|
1318
|
+
offset: 0,
|
|
1319
|
+
showDetail: true,
|
|
1320
|
+
...params
|
|
1321
|
+
};
|
|
1322
|
+
try {
|
|
1323
|
+
const res = await this.http.get(
|
|
1324
|
+
`/api/core/contents/${contentTypeUniqueId}`,
|
|
1325
|
+
{
|
|
1326
|
+
params: transferParams,
|
|
1327
|
+
headers: {
|
|
1328
|
+
...this.managingHeaders,
|
|
1329
|
+
...options.headers
|
|
1330
|
+
},
|
|
1331
|
+
cache: options.cache,
|
|
1332
|
+
signal: options.signal,
|
|
1333
|
+
next: {
|
|
1334
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
);
|
|
1338
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1339
|
+
} catch {
|
|
1340
|
+
return { hasError: true, result: [] };
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Retrieves unpublished content (enable: false).
|
|
1345
|
+
*/
|
|
1346
|
+
async getUnpublishedContent(params = {}, options = {}) {
|
|
1347
|
+
return this.getAllContents({ ...params, enable: false }, options);
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Retrieves single content by entityId and optional contentTypeUniqueId.
|
|
1351
|
+
* Swagger: GET /api/core/contents/enable/{entityId} OR /api/core/contents/{contentTypeUniqueId}/enable/{entityId}
|
|
1352
|
+
*/
|
|
1353
|
+
async getContentByEntityId(params, options = {}) {
|
|
1354
|
+
const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/enable/${params.entityId}` : `/api/core/contents/enable/${params.entityId}`;
|
|
1355
|
+
try {
|
|
1356
|
+
const res = await this.http.get(url, {
|
|
1357
|
+
headers: {
|
|
1358
|
+
...this.commonHeaders,
|
|
1359
|
+
...options.headers
|
|
1360
|
+
},
|
|
1361
|
+
cache: options.cache,
|
|
1362
|
+
signal: options.signal,
|
|
1363
|
+
next: {
|
|
1364
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1368
|
+
} catch {
|
|
1369
|
+
return { hasError: true, result: [] };
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Retrieves content by unique identifier.
|
|
1374
|
+
* Swagger: GET /api/core/contents/{contentUniqueId}/byContentUniqueId/enable
|
|
1375
|
+
*/
|
|
1376
|
+
async getContentByUniqueId(contentUniqueId, options = {}) {
|
|
1377
|
+
try {
|
|
1378
|
+
const res = await this.http.get(
|
|
1379
|
+
`/api/core/contents/${contentUniqueId}/byContentUniqueId/enable`,
|
|
1380
|
+
{
|
|
1381
|
+
headers: {
|
|
1382
|
+
...this.commonHeaders,
|
|
1383
|
+
...options.headers
|
|
1384
|
+
},
|
|
1385
|
+
cache: options.cache,
|
|
1386
|
+
signal: options.signal,
|
|
1387
|
+
next: {
|
|
1388
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
);
|
|
1392
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1393
|
+
} catch {
|
|
1394
|
+
return { hasError: true, result: [] };
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Searches published contents by keyword.
|
|
1399
|
+
* Swagger: GET /api/core/contents/search
|
|
1400
|
+
*/
|
|
1401
|
+
async searchContent(params = {}, options = {}) {
|
|
1402
|
+
try {
|
|
1403
|
+
const res = await this.http.get("/api/core/contents/search", {
|
|
1404
|
+
params,
|
|
1405
|
+
headers: {
|
|
1406
|
+
...this.commonHeaders,
|
|
1407
|
+
...options.headers
|
|
1408
|
+
},
|
|
1409
|
+
cache: options.cache,
|
|
1410
|
+
signal: options.signal,
|
|
1411
|
+
next: {
|
|
1412
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1416
|
+
} catch {
|
|
1417
|
+
return { hasError: true, result: [] };
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Adds and publishes new content to CMS.
|
|
1422
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/add-publish
|
|
1423
|
+
*/
|
|
1424
|
+
async addContent(params, options = {}) {
|
|
1425
|
+
const res = await this.http.post(
|
|
1426
|
+
`/api/core/contents/${params.contentTypeUniqueId}/add-publish`,
|
|
1427
|
+
params.body,
|
|
1428
|
+
{
|
|
1429
|
+
headers: this.managingHeaders
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1432
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Creates a new draft/unpublished content.
|
|
1436
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}
|
|
1437
|
+
*/
|
|
1438
|
+
async createContent(params, options = {}) {
|
|
1439
|
+
const res = await this.http.post(
|
|
1440
|
+
`/api/core/contents/${params.contentTypeUniqueId}`,
|
|
1441
|
+
params.body,
|
|
1442
|
+
{
|
|
1443
|
+
headers: this.managingHeaders
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Edits and publishes existing content by entityId.
|
|
1450
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}/edit-publish
|
|
1451
|
+
*/
|
|
1452
|
+
async editContent(entityId, params, options = {}) {
|
|
1453
|
+
const res = await this.http.post(
|
|
1454
|
+
`/api/core/contents/${params.contentTypeUniqueId}/${entityId}/edit-publish`,
|
|
1455
|
+
params.body,
|
|
1456
|
+
{
|
|
1457
|
+
headers: this.managingHeaders
|
|
1458
|
+
}
|
|
1459
|
+
);
|
|
1460
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Updates existing content.
|
|
1464
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}
|
|
1465
|
+
*/
|
|
1466
|
+
async updateContent(entityId, params, options = {}) {
|
|
1467
|
+
const res = await this.http.post(
|
|
1468
|
+
`/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
|
|
1469
|
+
params.body,
|
|
1470
|
+
{
|
|
1471
|
+
headers: this.managingHeaders
|
|
1472
|
+
}
|
|
1473
|
+
);
|
|
1474
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Partially updates existing content.
|
|
1478
|
+
* Swagger: PATCH /api/core/contents/{contentTypeUniqueId}/{entityId}
|
|
1479
|
+
*/
|
|
1480
|
+
async patchContent(entityId, params, options = {}) {
|
|
1481
|
+
const res = await this.http.patch(
|
|
1482
|
+
`/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
|
|
1483
|
+
params.body,
|
|
1484
|
+
{
|
|
1485
|
+
headers: this.managingHeaders
|
|
1486
|
+
}
|
|
1487
|
+
);
|
|
1488
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Publishes existing content.
|
|
1492
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/publish/{entityId}
|
|
1493
|
+
*/
|
|
1494
|
+
async publishContent(contentTypeUniqueId, entityId) {
|
|
1495
|
+
return this.http.post(
|
|
1496
|
+
`/api/core/contents/${contentTypeUniqueId}/publish/${entityId}`,
|
|
1497
|
+
{},
|
|
1498
|
+
{
|
|
1499
|
+
headers: this.managingHeaders
|
|
1500
|
+
}
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Unpublishes existing content.
|
|
1505
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/unpublish/{entityId}
|
|
1506
|
+
*/
|
|
1507
|
+
async unpublishContent(contentTypeUniqueId, entityId) {
|
|
1508
|
+
return this.http.post(
|
|
1509
|
+
`/api/core/contents/${contentTypeUniqueId}/unpublish/${entityId}`,
|
|
1510
|
+
{},
|
|
1511
|
+
{
|
|
1512
|
+
headers: this.managingHeaders
|
|
1513
|
+
}
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Batch publishes content items.
|
|
1518
|
+
* Swagger: PUT /api/core/contents/{contentTypeUniqueId}/publish OR /api/core/contents/publish
|
|
1519
|
+
*/
|
|
1520
|
+
async batchPublish(params) {
|
|
1521
|
+
const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/publish` : "/api/core/contents/publish";
|
|
1522
|
+
return this.http.put(url, { entityIds: params.entityIds }, {
|
|
1523
|
+
headers: this.managingHeaders
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Batch unpublishes content items.
|
|
1528
|
+
* Swagger: PUT /api/core/contents/{contentTypeUniqueId}/unpublish OR /api/core/contents/unpublish
|
|
1529
|
+
*/
|
|
1530
|
+
async batchUnpublish(params) {
|
|
1531
|
+
const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unpublish` : "/api/core/contents/unpublish";
|
|
1532
|
+
return this.http.put(url, { entityIds: params.entityIds }, {
|
|
1533
|
+
headers: this.managingHeaders
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Archives content items.
|
|
1538
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/archive
|
|
1539
|
+
*/
|
|
1540
|
+
async archiveContent(params) {
|
|
1541
|
+
const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/archive` : "/api/core/contents/archive";
|
|
1542
|
+
return this.http.post(url, { entityIds: params.entityIds }, {
|
|
1543
|
+
headers: this.managingHeaders
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Unarchives content items.
|
|
1548
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/unarchive
|
|
1549
|
+
*/
|
|
1550
|
+
async unarchiveContent(params) {
|
|
1551
|
+
const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unarchive` : "/api/core/contents/unarchive";
|
|
1552
|
+
return this.http.post(url, { entityIds: params.entityIds }, {
|
|
1553
|
+
headers: this.managingHeaders
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Retrieves list of archived contents.
|
|
1558
|
+
* Swagger: GET /api/core/contents/archive OR /api/core/contents/{contentTypeUniqueId}/archive
|
|
1559
|
+
*/
|
|
1560
|
+
async getArchivedContents(params = {}, options = {}) {
|
|
1561
|
+
const { contentTypeUniqueId, ...rest } = params;
|
|
1562
|
+
const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/archive` : "/api/core/contents/archive";
|
|
1563
|
+
try {
|
|
1564
|
+
const res = await this.http.get(url, {
|
|
1565
|
+
params: rest,
|
|
1566
|
+
headers: this.managingHeaders
|
|
1567
|
+
});
|
|
1568
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1569
|
+
} catch {
|
|
1570
|
+
return { hasError: true, result: [] };
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Retrieves drafts.
|
|
1575
|
+
* Swagger: GET /api/core/contents/draft OR /api/core/contents/{contentTypeUniqueId}/draft
|
|
1576
|
+
*/
|
|
1577
|
+
async getDrafts(params = {}, options = {}) {
|
|
1578
|
+
const { contentTypeUniqueId, ...rest } = params;
|
|
1579
|
+
const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/draft` : "/api/core/contents/draft";
|
|
1580
|
+
try {
|
|
1581
|
+
const res = await this.http.get(url, {
|
|
1582
|
+
params: rest,
|
|
1583
|
+
headers: this.managingHeaders
|
|
1584
|
+
});
|
|
1585
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1586
|
+
} catch {
|
|
1587
|
+
return { hasError: true, result: [] };
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Creates a draft.
|
|
1592
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft
|
|
1593
|
+
*/
|
|
1594
|
+
async createDraft(params, options = {}) {
|
|
1595
|
+
const res = await this.http.post(
|
|
1596
|
+
`/api/core/contents/${params.contentTypeUniqueId}/draft`,
|
|
1597
|
+
params.body,
|
|
1598
|
+
{
|
|
1599
|
+
headers: this.managingHeaders
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1602
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1603
|
+
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Gets a specific draft by entityId.
|
|
1606
|
+
* Swagger: GET /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
|
|
1607
|
+
*/
|
|
1608
|
+
async getDraftById(contentTypeUniqueId, entityId, options = {}) {
|
|
1609
|
+
try {
|
|
1610
|
+
const res = await this.http.get(
|
|
1611
|
+
`/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
|
|
1612
|
+
{
|
|
1613
|
+
headers: this.managingHeaders
|
|
1614
|
+
}
|
|
1615
|
+
);
|
|
1616
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1617
|
+
} catch {
|
|
1618
|
+
return { hasError: true, result: [] };
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Updates a draft.
|
|
1623
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
|
|
1624
|
+
*/
|
|
1625
|
+
async updateDraft(contentTypeUniqueId, entityId, params, options = {}) {
|
|
1626
|
+
const res = await this.http.post(
|
|
1627
|
+
`/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
|
|
1628
|
+
params.body,
|
|
1629
|
+
{
|
|
1630
|
+
headers: this.managingHeaders
|
|
1631
|
+
}
|
|
1632
|
+
);
|
|
1633
|
+
return this.formatter.formatGetContentResponse(res, options.normalizer);
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Undrafts content by entityId.
|
|
1637
|
+
* Swagger: POST /api/core/contents/{contentTypeUniqueId}/undraft/{entityId}
|
|
1638
|
+
*/
|
|
1639
|
+
async undraftContent(contentTypeUniqueId, entityId) {
|
|
1640
|
+
return this.http.post(
|
|
1641
|
+
`/api/core/contents/${contentTypeUniqueId}/undraft/${entityId}`,
|
|
1642
|
+
{},
|
|
1643
|
+
{
|
|
1644
|
+
headers: this.managingHeaders
|
|
1645
|
+
}
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Retrieves comments on content.
|
|
1650
|
+
* Swagger: GET /api/core/contents/{contentTypeUniqueId}/comments/{entityId}
|
|
1651
|
+
*/
|
|
1652
|
+
async getComments(contentTypeUniqueId, entityId, params = {}) {
|
|
1653
|
+
return this.http.get(
|
|
1654
|
+
`/api/core/contents/${contentTypeUniqueId}/comments/${entityId}`,
|
|
1655
|
+
{
|
|
1656
|
+
params,
|
|
1657
|
+
headers: this.commonHeaders
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Retrieves list of likes for content.
|
|
1663
|
+
* Swagger: GET /api/core/contents/{contentUniqueId}/like/{entityId}
|
|
1664
|
+
*/
|
|
1665
|
+
async getLikes(contentUniqueId, entityId, params = {}) {
|
|
1666
|
+
return this.http.get(
|
|
1667
|
+
`/api/core/contents/${contentUniqueId}/like/${entityId}`,
|
|
1668
|
+
{
|
|
1669
|
+
params,
|
|
1670
|
+
headers: this.commonHeaders
|
|
1671
|
+
}
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Retrieves list of dislikes for content.
|
|
1676
|
+
* Swagger: GET /api/core/contents/{contentUniqueId}/dislike/{entityId}
|
|
1677
|
+
*/
|
|
1678
|
+
async getDislikes(contentUniqueId, entityId, params = {}) {
|
|
1679
|
+
return this.http.get(
|
|
1680
|
+
`/api/core/contents/${contentUniqueId}/dislike/${entityId}`,
|
|
1681
|
+
{
|
|
1682
|
+
params,
|
|
1683
|
+
headers: this.commonHeaders
|
|
1684
|
+
}
|
|
1685
|
+
);
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Retrieves tag/category tree.
|
|
1689
|
+
* Swagger: GET /api/core/tags/root/tree/enable
|
|
1690
|
+
*/
|
|
1691
|
+
async getCategories(params = {}, options = {}) {
|
|
1692
|
+
try {
|
|
1693
|
+
return await this.http.get("/api/core/tags/root/tree/enable", {
|
|
1694
|
+
params,
|
|
1695
|
+
headers: {
|
|
1696
|
+
...this.commonHeaders,
|
|
1697
|
+
...options.headers
|
|
1698
|
+
},
|
|
1699
|
+
cache: options.cache,
|
|
1700
|
+
signal: options.signal,
|
|
1701
|
+
next: {
|
|
1702
|
+
revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
} catch {
|
|
1706
|
+
return { hasError: true, result: [] };
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Retrieves details of a content type structure.
|
|
1711
|
+
* Swagger: GET /api/core/content-types/{contentTypeUniqueId}
|
|
1712
|
+
*/
|
|
1713
|
+
async getContentTypeDetail(contentTypeUniqueId) {
|
|
1714
|
+
try {
|
|
1715
|
+
return await this.http.get(`/api/core/content-types/${contentTypeUniqueId}`, {
|
|
1716
|
+
headers: this.managingHeaders
|
|
1717
|
+
});
|
|
1718
|
+
} catch {
|
|
1719
|
+
return {};
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Performs advanced AI timeline search on content.
|
|
1724
|
+
* Swagger: GET /api/core/contents/ai/timeline-search/enable
|
|
1725
|
+
*/
|
|
1726
|
+
async timelineSearch(query) {
|
|
1727
|
+
const params = {};
|
|
1728
|
+
if (query?.advance) {
|
|
1729
|
+
params.advance = JSON.stringify(query.advance);
|
|
1730
|
+
params.newVersion = true;
|
|
1731
|
+
}
|
|
1732
|
+
if (query?.offset) {
|
|
1733
|
+
params.offset = query.offset;
|
|
1734
|
+
}
|
|
1735
|
+
if (query?.size) {
|
|
1736
|
+
params.size = query.size;
|
|
1737
|
+
}
|
|
1738
|
+
return this.http.get(
|
|
1739
|
+
"/api/core/contents/ai/timeline-search/enable",
|
|
1740
|
+
{
|
|
1741
|
+
params,
|
|
1742
|
+
headers: this.commonHeaders
|
|
1743
|
+
}
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
// =========================================================================
|
|
1747
|
+
// CONVENIENCE DELEGATES FOR PRODUCTS
|
|
1748
|
+
// =========================================================================
|
|
1749
|
+
/**
|
|
1750
|
+
* Delegate to `cms.products.getProducts(...)`.
|
|
1751
|
+
*/
|
|
1752
|
+
async getProducts(params = {}, options = {}) {
|
|
1753
|
+
return this.products.getProducts(params, options);
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Delegate to `cms.products.getProductByEntityId(...)`.
|
|
1757
|
+
*/
|
|
1758
|
+
async getProductByEntityId(params, options = {}) {
|
|
1759
|
+
return this.products.getProductByEntityId(params, options);
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Delegate to `cms.products.addProduct(...)`.
|
|
1763
|
+
*/
|
|
1764
|
+
async addProduct(params, options = {}) {
|
|
1765
|
+
return this.products.addProduct(params, options);
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Delegate to `cms.products.editProduct(...)`.
|
|
1769
|
+
*/
|
|
1770
|
+
async editProduct(entityId, params, options = {}) {
|
|
1771
|
+
return this.products.editProduct(entityId, params, options);
|
|
1772
|
+
}
|
|
941
1773
|
};
|
|
942
1774
|
var IumsService = class {
|
|
943
1775
|
http;
|
|
@@ -1017,6 +1849,7 @@ var PodSdk = class {
|
|
|
1017
1849
|
notification;
|
|
1018
1850
|
social;
|
|
1019
1851
|
cms;
|
|
1852
|
+
product;
|
|
1020
1853
|
iums;
|
|
1021
1854
|
constructor(config) {
|
|
1022
1855
|
const urls = {
|
|
@@ -1073,6 +1906,7 @@ var PodSdk = class {
|
|
|
1073
1906
|
podspaceUrl: urls.podspace,
|
|
1074
1907
|
revalidate
|
|
1075
1908
|
});
|
|
1909
|
+
this.product = this.cms.products;
|
|
1076
1910
|
this.iums = new IumsService({
|
|
1077
1911
|
baseUrl: urls.iums,
|
|
1078
1912
|
clientId,
|
|
@@ -1091,6 +1925,6 @@ function createPodSdk(config) {
|
|
|
1091
1925
|
}
|
|
1092
1926
|
var client_default = PodSdk;
|
|
1093
1927
|
|
|
1094
|
-
export { CmsDataFormatter, CmsService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
|
|
1928
|
+
export { CmsDataFormatter, CmsProductService, CmsService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
|
|
1095
1929
|
//# sourceMappingURL=index.mjs.map
|
|
1096
1930
|
//# sourceMappingURL=index.mjs.map
|