@rezamirzapour/pod-sdk 1.0.2 → 1.0.4

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
@@ -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
- formatContentItem(item, normalizer) {
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
- if (Array.isArray(item?.metadata?.content)) {
689
- item.metadata.content.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;
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.formatContentItem(val)
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 content from CMS, formatted with generic metadata type T and optional normalized type P.
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 getContent(params = {}, options = {}) {
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/contents/enable", {
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.formatGetContentResponse(res, options.normalizer);
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 content using managing credentials (Access-Token).
812
+ * Retrieves all products using Provider credentials (Access-Token).
813
+ * Swagger: GET /api/core/products
788
814
  */
789
- async getContent2(params = {}, options = {}) {
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/contents", {
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.formatGetContentResponse(res, options.normalizer);
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 unpublished/draft content (enable: false).
841
+ * Retrieves products for management view.
842
+ * Swagger: GET /api/core/products/manage
816
843
  */
817
- async getUnpublishedContent(params = {}, options = {}) {
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/contents", {
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.formatGetContentResponse(res, options.normalizer);
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 single content by entityId and optional contentTypeUniqueId.
870
+ * Retrieves products by ProductType unique identifier.
871
+ * Swagger: GET /api/core/products/{productTypeUniqueId}
845
872
  */
846
- async getContentByEntityId(params, options = {}) {
847
- const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/enable/${params.entityId}` : `/api/core/contents/enable/${params.entityId}`;
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.formatGetContentResponse(res, options.normalizer);
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 tag/category tree.
925
+ * Retrieves a single product by uniqueId.
926
+ * Swagger: GET /api/core/products/{productUniqueId}/byProductUniqueId/enable
867
927
  */
868
- async getCategories(params = {}, options = {}) {
928
+ async getProductByUniqueId(productUniqueId, options = {}) {
869
929
  try {
870
- return await this.http.get("/api/core/tags/root/tree/enable", {
871
- params,
872
- headers: {
873
- ...this.commonHeaders,
874
- ...options.headers
875
- },
876
- cache: options.cache,
877
- signal: options.signal,
878
- next: {
879
- revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
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 details of a content type structure.
950
+ * Retrieves products matching a barcode.
951
+ * Swagger: GET /api/core/products/barcode/enable
888
952
  */
889
- async getContentTypeDetail(contentTypeUniqueId) {
953
+ async getProductByBarcode(barcode, options = {}) {
890
954
  try {
891
- return await this.http.get(`/api/core/content-types/${contentTypeUniqueId}`, {
892
- headers: this.managingHeaders
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
- * Adds and publishes new content to CMS.
976
+ * Searches published products by keyword.
977
+ * Swagger: GET /api/core/products/enable/search
900
978
  */
901
- async addContent(params, options = {}) {
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/contents/${params.contentTypeUniqueId}/add-publish`,
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.formatGetContentResponse(res, options.normalizer);
1013
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
910
1014
  }
911
1015
  /**
912
- * Edits and publishes existing content by entityId.
1016
+ * Creates a draft/unpublished product.
1017
+ * Swagger: POST /api/core/products/{productTypeUniqueId}
913
1018
  */
914
- async editContent(entityId, params, options = {}) {
1019
+ async createProduct(params, options = {}) {
915
1020
  const res = await this.http.post(
916
- `/api/core/contents/${params.contentTypeUniqueId}/${entityId}/edit-publish`,
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.formatGetContentResponse(res, options.normalizer);
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,1001 @@ var CmsService = class {
933
1164
  if (query?.offset) {
934
1165
  params.offset = query.offset;
935
1166
  }
936
- return this.http.get("/api/core/ai-service/timeline-search/enable", {
937
- params,
938
- headers: this.commonHeaders
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
+ var CmsTagService = class {
1180
+ http;
1181
+ clientId;
1182
+ apiToken;
1183
+ revalidate;
1184
+ constructor(options) {
1185
+ this.clientId = options.clientId || "";
1186
+ this.apiToken = options.apiToken || "";
1187
+ this.revalidate = Number(options.revalidate) || 0;
1188
+ this.http = options.http || createNextHttp({
1189
+ baseUrl: options.baseUrl || "https://cms.pod.ir",
1190
+ serviceName: "POD-CMS-TAGS"
1191
+ });
1192
+ }
1193
+ get commonHeaders() {
1194
+ return {
1195
+ "Client-Id": this.clientId,
1196
+ "Content-Type": "application/json"
1197
+ };
1198
+ }
1199
+ get managingHeaders() {
1200
+ return {
1201
+ ...this.commonHeaders,
1202
+ "Access-Token": this.apiToken
1203
+ };
1204
+ }
1205
+ // =========================================================================
1206
+ // 1. TAG CATEGORY MANAGEMENT (Swagger: /api/core/tags/category)
1207
+ // =========================================================================
1208
+ /**
1209
+ * Retrieves list of tag categories.
1210
+ * Swagger: GET /api/core/tags/category
1211
+ */
1212
+ async getTagCategories(params = {}, options = {}) {
1213
+ try {
1214
+ return await this.http.get("/api/core/tags/category", {
1215
+ params,
1216
+ headers: {
1217
+ ...this.managingHeaders,
1218
+ ...options.headers
1219
+ },
1220
+ cache: options.cache,
1221
+ signal: options.signal,
1222
+ next: {
1223
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1224
+ }
1225
+ });
1226
+ } catch {
1227
+ return { hasError: true, result: [] };
1228
+ }
1229
+ }
1230
+ /**
1231
+ * Creates a new tag category.
1232
+ * Swagger: POST /api/core/tags/category
1233
+ */
1234
+ async createTagCategory(params, options = {}) {
1235
+ return this.http.post(
1236
+ "/api/core/tags/category",
1237
+ {},
1238
+ {
1239
+ params: {
1240
+ name: params.name,
1241
+ desc: params.desc
1242
+ },
1243
+ headers: {
1244
+ ...this.managingHeaders,
1245
+ ...options.headers
1246
+ }
1247
+ }
1248
+ );
1249
+ }
1250
+ /**
1251
+ * Retrieves single tag category by ID.
1252
+ * Swagger: GET /api/core/tags/category/{id}
1253
+ */
1254
+ async getTagCategory(id, options = {}) {
1255
+ return this.http.get(`/api/core/tags/category/${id}`, {
1256
+ headers: {
1257
+ ...this.managingHeaders,
1258
+ ...options.headers
1259
+ },
1260
+ cache: options.cache,
1261
+ signal: options.signal,
1262
+ next: {
1263
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1264
+ }
939
1265
  });
940
1266
  }
1267
+ /**
1268
+ * Updates an existing tag category.
1269
+ * Swagger: PUT /api/core/tags/category/{id}
1270
+ */
1271
+ async updateTagCategory(id, params, options = {}) {
1272
+ return this.http.put(
1273
+ `/api/core/tags/category/${id}`,
1274
+ {},
1275
+ {
1276
+ params: {
1277
+ name: params.name,
1278
+ desc: params.desc,
1279
+ enable: params.enable
1280
+ },
1281
+ headers: {
1282
+ ...this.managingHeaders,
1283
+ ...options.headers
1284
+ }
1285
+ }
1286
+ );
1287
+ }
1288
+ /**
1289
+ * Publishes a tag category.
1290
+ * Swagger: PUT /api/core/tags/category/{id}/publish
1291
+ */
1292
+ async publishTagCategory(id, options = {}) {
1293
+ return this.http.put(
1294
+ `/api/core/tags/category/${id}/publish`,
1295
+ {},
1296
+ {
1297
+ headers: {
1298
+ ...this.managingHeaders,
1299
+ ...options.headers
1300
+ }
1301
+ }
1302
+ );
1303
+ }
1304
+ /**
1305
+ * Unpublishes a tag category.
1306
+ * Swagger: PUT /api/core/tags/category/{id}/unpublish
1307
+ */
1308
+ async unpublishTagCategory(id, options = {}) {
1309
+ return this.http.put(
1310
+ `/api/core/tags/category/${id}/unpublish`,
1311
+ {},
1312
+ {
1313
+ headers: {
1314
+ ...this.managingHeaders,
1315
+ ...options.headers
1316
+ }
1317
+ }
1318
+ );
1319
+ }
1320
+ // =========================================================================
1321
+ // 2. TAG TREE & HIERARCHY (Swagger: /api/core/tags/{categoryId}/tree/...)
1322
+ // =========================================================================
1323
+ /**
1324
+ * Retrieves enabled published tag tree for category (defaults to 'root').
1325
+ * End user call (without requiring Access-Token).
1326
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
1327
+ */
1328
+ async getTagTree(categoryId = "root", params = {}, options = {}) {
1329
+ try {
1330
+ return await this.http.get(
1331
+ `/api/core/tags/${categoryId}/tree/enable`,
1332
+ {
1333
+ params,
1334
+ headers: {
1335
+ ...this.commonHeaders,
1336
+ ...options.headers
1337
+ },
1338
+ cache: options.cache,
1339
+ signal: options.signal,
1340
+ next: {
1341
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1342
+ }
1343
+ }
1344
+ );
1345
+ } catch {
1346
+ return { hasError: true, result: [] };
1347
+ }
1348
+ }
1349
+ /**
1350
+ * Retrieves tag tree for category with management credentials.
1351
+ * Swagger: GET /api/core/tags/{categoryId}/tree/manage
1352
+ */
1353
+ async getManageTagTree(categoryId, params = {}, options = {}) {
1354
+ try {
1355
+ return await this.http.get(
1356
+ `/api/core/tags/${categoryId}/tree/manage`,
1357
+ {
1358
+ params,
1359
+ headers: {
1360
+ ...this.managingHeaders,
1361
+ ...options.headers
1362
+ },
1363
+ cache: options.cache,
1364
+ signal: options.signal,
1365
+ next: {
1366
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1367
+ }
1368
+ }
1369
+ );
1370
+ } catch {
1371
+ return { hasError: true, result: [] };
1372
+ }
1373
+ }
1374
+ /**
1375
+ * Creates a new tag tree node for category.
1376
+ * Swagger: POST /api/core/tags/{categoryId}/tree
1377
+ */
1378
+ async createTagTreeItem(categoryId, params, options = {}) {
1379
+ const { relatedContentIds, ...rest } = params;
1380
+ const queryParams = { ...rest };
1381
+ if (Array.isArray(relatedContentIds)) {
1382
+ queryParams["relatedContentIds[]"] = relatedContentIds;
1383
+ }
1384
+ return this.http.post(
1385
+ `/api/core/tags/${categoryId}/tree`,
1386
+ {},
1387
+ {
1388
+ params: queryParams,
1389
+ headers: {
1390
+ ...this.managingHeaders,
1391
+ ...options.headers
1392
+ }
1393
+ }
1394
+ );
1395
+ }
1396
+ /**
1397
+ * Shows a single enabled tag tree item for end users.
1398
+ * Swagger: GET /api/core/tags/{categoryId}/tree/{id}/enable
1399
+ */
1400
+ async getTagTreeItem(categoryId, id, options = {}) {
1401
+ return this.http.get(`/api/core/tags/${categoryId}/tree/${id}/enable`, {
1402
+ headers: {
1403
+ ...this.commonHeaders,
1404
+ ...options.headers
1405
+ },
1406
+ cache: options.cache,
1407
+ signal: options.signal,
1408
+ next: {
1409
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1410
+ }
1411
+ });
1412
+ }
1413
+ /**
1414
+ * Shows a single tag tree item for manager (with token).
1415
+ * Swagger: GET /api/core/tags/{categoryId}/tree/{id}/manage
1416
+ */
1417
+ async getManageTagTreeItem(categoryId, id, options = {}) {
1418
+ return this.http.get(`/api/core/tags/${categoryId}/tree/${id}/manage`, {
1419
+ headers: {
1420
+ ...this.managingHeaders,
1421
+ ...options.headers
1422
+ },
1423
+ cache: options.cache,
1424
+ signal: options.signal,
1425
+ next: {
1426
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1427
+ }
1428
+ });
1429
+ }
1430
+ /**
1431
+ * Updates an existing tag tree node.
1432
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/{id}
1433
+ */
1434
+ async updateTagTreeItem(categoryId, id, params, options = {}) {
1435
+ const { relatedContentIds, ...rest } = params;
1436
+ const queryParams = { ...rest };
1437
+ if (Array.isArray(relatedContentIds)) {
1438
+ queryParams["relatedContentIds[]"] = relatedContentIds;
1439
+ }
1440
+ return this.http.put(
1441
+ `/api/core/tags/${categoryId}/tree/${id}`,
1442
+ {},
1443
+ {
1444
+ params: queryParams,
1445
+ headers: {
1446
+ ...this.managingHeaders,
1447
+ ...options.headers
1448
+ }
1449
+ }
1450
+ );
1451
+ }
1452
+ /**
1453
+ * Publishes a tag tree item.
1454
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/publish/{id}
1455
+ */
1456
+ async publishTagTreeItem(categoryId, id, options = {}) {
1457
+ return this.http.put(
1458
+ `/api/core/tags/${categoryId}/tree/publish/${id}`,
1459
+ {},
1460
+ {
1461
+ headers: {
1462
+ ...this.managingHeaders,
1463
+ ...options.headers
1464
+ }
1465
+ }
1466
+ );
1467
+ }
1468
+ /**
1469
+ * Unpublishes a tag tree item.
1470
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/unpublish/{id}
1471
+ */
1472
+ async unpublishTagTreeItem(categoryId, id, options = {}) {
1473
+ return this.http.put(
1474
+ `/api/core/tags/${categoryId}/tree/unpublish/${id}`,
1475
+ {},
1476
+ {
1477
+ headers: {
1478
+ ...this.managingHeaders,
1479
+ ...options.headers
1480
+ }
1481
+ }
1482
+ );
1483
+ }
1484
+ /**
1485
+ * Updates the parent of a tag tree item.
1486
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/parent/{id}
1487
+ */
1488
+ async updateTagTreeParent(categoryId, id, parentId, options = {}) {
1489
+ return this.http.put(
1490
+ `/api/core/tags/${categoryId}/tree/parent/${id}`,
1491
+ {},
1492
+ {
1493
+ params: {
1494
+ parentId: parentId !== void 0 ? String(parentId) : ""
1495
+ },
1496
+ headers: {
1497
+ ...this.managingHeaders,
1498
+ ...options.headers
1499
+ }
1500
+ }
1501
+ );
1502
+ }
1503
+ /**
1504
+ * Retrieves tag tree ancestors for end user.
1505
+ * Swagger: GET /api/core/tags/{categoryId}/tree/parent/{id}/enable
1506
+ */
1507
+ async getTagTreeAncestors(categoryId, id, params = {}, options = {}) {
1508
+ try {
1509
+ return await this.http.get(
1510
+ `/api/core/tags/${categoryId}/tree/parent/${id}/enable`,
1511
+ {
1512
+ params,
1513
+ headers: {
1514
+ ...this.commonHeaders,
1515
+ ...options.headers
1516
+ },
1517
+ cache: options.cache,
1518
+ signal: options.signal,
1519
+ next: {
1520
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1521
+ }
1522
+ }
1523
+ );
1524
+ } catch {
1525
+ return { hasError: true, result: [] };
1526
+ }
1527
+ }
1528
+ /**
1529
+ * Retrieves tag tree ancestors for manager (with token).
1530
+ * Swagger: GET /api/core/tags/{categoryId}/tree/parent/{id}/manage
1531
+ */
1532
+ async getManageTagTreeAncestors(categoryId, id, params = {}, options = {}) {
1533
+ try {
1534
+ return await this.http.get(
1535
+ `/api/core/tags/${categoryId}/tree/parent/${id}/manage`,
1536
+ {
1537
+ params,
1538
+ headers: {
1539
+ ...this.managingHeaders,
1540
+ ...options.headers
1541
+ },
1542
+ cache: options.cache,
1543
+ signal: options.signal,
1544
+ next: {
1545
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1546
+ }
1547
+ }
1548
+ );
1549
+ } catch {
1550
+ return { hasError: true, result: [] };
1551
+ }
1552
+ }
1553
+ /**
1554
+ * Updates tag tree code for category.
1555
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/code/{id}
1556
+ */
1557
+ async updateTagTreeCode(categoryId, id, code, options = {}) {
1558
+ return this.http.put(
1559
+ `/api/core/tags/${categoryId}/tree/code/${id}`,
1560
+ {},
1561
+ {
1562
+ params: { code },
1563
+ headers: {
1564
+ ...this.managingHeaders,
1565
+ ...options.headers
1566
+ }
1567
+ }
1568
+ );
1569
+ }
1570
+ };
1571
+
1572
+ // src/services/cms/index.ts
1573
+ var CmsService = class {
1574
+ http;
1575
+ formatter;
1576
+ clientId;
1577
+ apiToken;
1578
+ revalidate;
1579
+ /**
1580
+ * Dedicated CMS Product sub-service.
1581
+ * Swagger: tag=product
1582
+ */
1583
+ products;
1584
+ /**
1585
+ * Dedicated CMS Tags & Tag Categories sub-service.
1586
+ * Swagger: tag=tags
1587
+ */
1588
+ tags;
1589
+ constructor(options) {
1590
+ this.clientId = options.clientId || "";
1591
+ this.apiToken = options.apiToken || "";
1592
+ this.revalidate = Number(options.revalidate) || 0;
1593
+ this.formatter = new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
1594
+ this.http = createNextHttp({
1595
+ baseUrl: options.baseUrl,
1596
+ serviceName: "POD-CMS"
1597
+ });
1598
+ this.products = new CmsProductService({
1599
+ http: this.http,
1600
+ formatter: this.formatter,
1601
+ clientId: this.clientId,
1602
+ apiToken: this.apiToken,
1603
+ revalidate: this.revalidate
1604
+ });
1605
+ this.tags = new CmsTagService({
1606
+ http: this.http,
1607
+ clientId: this.clientId,
1608
+ apiToken: this.apiToken,
1609
+ revalidate: this.revalidate
1610
+ });
1611
+ }
1612
+ get commonHeaders() {
1613
+ return {
1614
+ "Client-Id": this.clientId,
1615
+ "Content-Type": "application/json"
1616
+ };
1617
+ }
1618
+ get managingHeaders() {
1619
+ return {
1620
+ ...this.commonHeaders,
1621
+ "Access-Token": this.apiToken
1622
+ };
1623
+ }
1624
+ // =========================================================================
1625
+ // CONTENT METHODS (Swagger: tag=content)
1626
+ // =========================================================================
1627
+ /**
1628
+ * Retrieves enabled published content from CMS, formatted with generic metadata type T and optional normalized type P.
1629
+ * Swagger: GET /api/core/contents/enable
1630
+ */
1631
+ async getContent(params = {}, options = {}) {
1632
+ const transferParams = {
1633
+ size: 50,
1634
+ offset: 0,
1635
+ showDetail: true,
1636
+ ...params
1637
+ };
1638
+ try {
1639
+ const res = await this.http.get("/api/core/contents/enable", {
1640
+ params: transferParams,
1641
+ headers: {
1642
+ ...this.commonHeaders,
1643
+ ...options.headers
1644
+ },
1645
+ cache: options.cache,
1646
+ signal: options.signal,
1647
+ next: {
1648
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1649
+ }
1650
+ });
1651
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1652
+ } catch {
1653
+ return { hasError: true, result: [] };
1654
+ }
1655
+ }
1656
+ /**
1657
+ * Retrieves all contents using managing credentials (Access-Token).
1658
+ * Swagger: GET /api/core/contents
1659
+ */
1660
+ async getAllContents(params = {}, options = {}) {
1661
+ const transferParams = {
1662
+ size: 50,
1663
+ offset: 0,
1664
+ showDetail: true,
1665
+ ...params
1666
+ };
1667
+ try {
1668
+ const res = await this.http.get("/api/core/contents", {
1669
+ params: transferParams,
1670
+ headers: {
1671
+ ...this.managingHeaders,
1672
+ ...options.headers
1673
+ },
1674
+ cache: options.cache,
1675
+ signal: options.signal,
1676
+ next: {
1677
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1678
+ }
1679
+ });
1680
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1681
+ } catch {
1682
+ return { hasError: true, result: [] };
1683
+ }
1684
+ }
1685
+ /**
1686
+ * Retrieves current user/client contents.
1687
+ * Swagger: GET /api/core/contents/my
1688
+ */
1689
+ async getMyContents(params = {}, options = {}) {
1690
+ const transferParams = {
1691
+ size: 50,
1692
+ offset: 0,
1693
+ showDetail: true,
1694
+ ...params
1695
+ };
1696
+ try {
1697
+ const res = await this.http.get("/api/core/contents/my", {
1698
+ params: transferParams,
1699
+ headers: {
1700
+ ...this.managingHeaders,
1701
+ ...options.headers
1702
+ },
1703
+ cache: options.cache,
1704
+ signal: options.signal,
1705
+ next: {
1706
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1707
+ }
1708
+ });
1709
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1710
+ } catch {
1711
+ return { hasError: true, result: [] };
1712
+ }
1713
+ }
1714
+ /**
1715
+ * Retrieves contents by ContentType unique identifier.
1716
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}
1717
+ */
1718
+ async getContentsByType(contentTypeUniqueId, params = {}, options = {}) {
1719
+ const transferParams = {
1720
+ size: 50,
1721
+ offset: 0,
1722
+ showDetail: true,
1723
+ ...params
1724
+ };
1725
+ try {
1726
+ const res = await this.http.get(
1727
+ `/api/core/contents/${contentTypeUniqueId}`,
1728
+ {
1729
+ params: transferParams,
1730
+ headers: {
1731
+ ...this.managingHeaders,
1732
+ ...options.headers
1733
+ },
1734
+ cache: options.cache,
1735
+ signal: options.signal,
1736
+ next: {
1737
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1738
+ }
1739
+ }
1740
+ );
1741
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1742
+ } catch {
1743
+ return { hasError: true, result: [] };
1744
+ }
1745
+ }
1746
+ /**
1747
+ * Retrieves unpublished content (enable: false).
1748
+ */
1749
+ async getUnpublishedContent(params = {}, options = {}) {
1750
+ return this.getAllContents({ ...params, enable: false }, options);
1751
+ }
1752
+ /**
1753
+ * Retrieves single content by entityId and optional contentTypeUniqueId.
1754
+ * Swagger: GET /api/core/contents/enable/{entityId} OR /api/core/contents/{contentTypeUniqueId}/enable/{entityId}
1755
+ */
1756
+ async getContentByEntityId(params, options = {}) {
1757
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/enable/${params.entityId}` : `/api/core/contents/enable/${params.entityId}`;
1758
+ try {
1759
+ const res = await this.http.get(url, {
1760
+ headers: {
1761
+ ...this.commonHeaders,
1762
+ ...options.headers
1763
+ },
1764
+ cache: options.cache,
1765
+ signal: options.signal,
1766
+ next: {
1767
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1768
+ }
1769
+ });
1770
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1771
+ } catch {
1772
+ return { hasError: true, result: [] };
1773
+ }
1774
+ }
1775
+ /**
1776
+ * Retrieves content by unique identifier.
1777
+ * Swagger: GET /api/core/contents/{contentUniqueId}/byContentUniqueId/enable
1778
+ */
1779
+ async getContentByUniqueId(contentUniqueId, options = {}) {
1780
+ try {
1781
+ const res = await this.http.get(
1782
+ `/api/core/contents/${contentUniqueId}/byContentUniqueId/enable`,
1783
+ {
1784
+ headers: {
1785
+ ...this.commonHeaders,
1786
+ ...options.headers
1787
+ },
1788
+ cache: options.cache,
1789
+ signal: options.signal,
1790
+ next: {
1791
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1792
+ }
1793
+ }
1794
+ );
1795
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1796
+ } catch {
1797
+ return { hasError: true, result: [] };
1798
+ }
1799
+ }
1800
+ /**
1801
+ * Searches published contents by keyword.
1802
+ * Swagger: GET /api/core/contents/search
1803
+ */
1804
+ async searchContent(params = {}, options = {}) {
1805
+ try {
1806
+ const res = await this.http.get("/api/core/contents/search", {
1807
+ params,
1808
+ headers: {
1809
+ ...this.commonHeaders,
1810
+ ...options.headers
1811
+ },
1812
+ cache: options.cache,
1813
+ signal: options.signal,
1814
+ next: {
1815
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1816
+ }
1817
+ });
1818
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1819
+ } catch {
1820
+ return { hasError: true, result: [] };
1821
+ }
1822
+ }
1823
+ /**
1824
+ * Adds and publishes new content to CMS.
1825
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/add-publish
1826
+ */
1827
+ async addContent(params, options = {}) {
1828
+ const res = await this.http.post(
1829
+ `/api/core/contents/${params.contentTypeUniqueId}/add-publish`,
1830
+ params.body,
1831
+ {
1832
+ headers: this.managingHeaders
1833
+ }
1834
+ );
1835
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1836
+ }
1837
+ /**
1838
+ * Creates a new draft/unpublished content.
1839
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}
1840
+ */
1841
+ async createContent(params, options = {}) {
1842
+ const res = await this.http.post(
1843
+ `/api/core/contents/${params.contentTypeUniqueId}`,
1844
+ params.body,
1845
+ {
1846
+ headers: this.managingHeaders
1847
+ }
1848
+ );
1849
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1850
+ }
1851
+ /**
1852
+ * Edits and publishes existing content by entityId.
1853
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}/edit-publish
1854
+ */
1855
+ async editContent(entityId, params, options = {}) {
1856
+ const res = await this.http.post(
1857
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}/edit-publish`,
1858
+ params.body,
1859
+ {
1860
+ headers: this.managingHeaders
1861
+ }
1862
+ );
1863
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1864
+ }
1865
+ /**
1866
+ * Updates existing content.
1867
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}
1868
+ */
1869
+ async updateContent(entityId, params, options = {}) {
1870
+ const res = await this.http.post(
1871
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
1872
+ params.body,
1873
+ {
1874
+ headers: this.managingHeaders
1875
+ }
1876
+ );
1877
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1878
+ }
1879
+ /**
1880
+ * Partially updates existing content.
1881
+ * Swagger: PATCH /api/core/contents/{contentTypeUniqueId}/{entityId}
1882
+ */
1883
+ async patchContent(entityId, params, options = {}) {
1884
+ const res = await this.http.patch(
1885
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
1886
+ params.body,
1887
+ {
1888
+ headers: this.managingHeaders
1889
+ }
1890
+ );
1891
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1892
+ }
1893
+ /**
1894
+ * Publishes existing content.
1895
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/publish/{entityId}
1896
+ */
1897
+ async publishContent(contentTypeUniqueId, entityId) {
1898
+ return this.http.post(
1899
+ `/api/core/contents/${contentTypeUniqueId}/publish/${entityId}`,
1900
+ {},
1901
+ {
1902
+ headers: this.managingHeaders
1903
+ }
1904
+ );
1905
+ }
1906
+ /**
1907
+ * Unpublishes existing content.
1908
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/unpublish/{entityId}
1909
+ */
1910
+ async unpublishContent(contentTypeUniqueId, entityId) {
1911
+ return this.http.post(
1912
+ `/api/core/contents/${contentTypeUniqueId}/unpublish/${entityId}`,
1913
+ {},
1914
+ {
1915
+ headers: this.managingHeaders
1916
+ }
1917
+ );
1918
+ }
1919
+ /**
1920
+ * Batch publishes content items.
1921
+ * Swagger: PUT /api/core/contents/{contentTypeUniqueId}/publish OR /api/core/contents/publish
1922
+ */
1923
+ async batchPublish(params) {
1924
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/publish` : "/api/core/contents/publish";
1925
+ return this.http.put(url, { entityIds: params.entityIds }, {
1926
+ headers: this.managingHeaders
1927
+ });
1928
+ }
1929
+ /**
1930
+ * Batch unpublishes content items.
1931
+ * Swagger: PUT /api/core/contents/{contentTypeUniqueId}/unpublish OR /api/core/contents/unpublish
1932
+ */
1933
+ async batchUnpublish(params) {
1934
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unpublish` : "/api/core/contents/unpublish";
1935
+ return this.http.put(url, { entityIds: params.entityIds }, {
1936
+ headers: this.managingHeaders
1937
+ });
1938
+ }
1939
+ /**
1940
+ * Archives content items.
1941
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/archive
1942
+ */
1943
+ async archiveContent(params) {
1944
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/archive` : "/api/core/contents/archive";
1945
+ return this.http.post(url, { entityIds: params.entityIds }, {
1946
+ headers: this.managingHeaders
1947
+ });
1948
+ }
1949
+ /**
1950
+ * Unarchives content items.
1951
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/unarchive
1952
+ */
1953
+ async unarchiveContent(params) {
1954
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unarchive` : "/api/core/contents/unarchive";
1955
+ return this.http.post(url, { entityIds: params.entityIds }, {
1956
+ headers: this.managingHeaders
1957
+ });
1958
+ }
1959
+ /**
1960
+ * Retrieves list of archived contents.
1961
+ * Swagger: GET /api/core/contents/archive OR /api/core/contents/{contentTypeUniqueId}/archive
1962
+ */
1963
+ async getArchivedContents(params = {}, options = {}) {
1964
+ const { contentTypeUniqueId, ...rest } = params;
1965
+ const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/archive` : "/api/core/contents/archive";
1966
+ try {
1967
+ const res = await this.http.get(url, {
1968
+ params: rest,
1969
+ headers: this.managingHeaders
1970
+ });
1971
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1972
+ } catch {
1973
+ return { hasError: true, result: [] };
1974
+ }
1975
+ }
1976
+ /**
1977
+ * Retrieves drafts.
1978
+ * Swagger: GET /api/core/contents/draft OR /api/core/contents/{contentTypeUniqueId}/draft
1979
+ */
1980
+ async getDrafts(params = {}, options = {}) {
1981
+ const { contentTypeUniqueId, ...rest } = params;
1982
+ const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/draft` : "/api/core/contents/draft";
1983
+ try {
1984
+ const res = await this.http.get(url, {
1985
+ params: rest,
1986
+ headers: this.managingHeaders
1987
+ });
1988
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1989
+ } catch {
1990
+ return { hasError: true, result: [] };
1991
+ }
1992
+ }
1993
+ /**
1994
+ * Creates a draft.
1995
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft
1996
+ */
1997
+ async createDraft(params, options = {}) {
1998
+ const res = await this.http.post(
1999
+ `/api/core/contents/${params.contentTypeUniqueId}/draft`,
2000
+ params.body,
2001
+ {
2002
+ headers: this.managingHeaders
2003
+ }
2004
+ );
2005
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
2006
+ }
2007
+ /**
2008
+ * Gets a specific draft by entityId.
2009
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
2010
+ */
2011
+ async getDraftById(contentTypeUniqueId, entityId, options = {}) {
2012
+ try {
2013
+ const res = await this.http.get(
2014
+ `/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
2015
+ {
2016
+ headers: this.managingHeaders
2017
+ }
2018
+ );
2019
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
2020
+ } catch {
2021
+ return { hasError: true, result: [] };
2022
+ }
2023
+ }
2024
+ /**
2025
+ * Updates a draft.
2026
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
2027
+ */
2028
+ async updateDraft(contentTypeUniqueId, entityId, params, options = {}) {
2029
+ const res = await this.http.post(
2030
+ `/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
2031
+ params.body,
2032
+ {
2033
+ headers: this.managingHeaders
2034
+ }
2035
+ );
2036
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
2037
+ }
2038
+ /**
2039
+ * Undrafts content by entityId.
2040
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/undraft/{entityId}
2041
+ */
2042
+ async undraftContent(contentTypeUniqueId, entityId) {
2043
+ return this.http.post(
2044
+ `/api/core/contents/${contentTypeUniqueId}/undraft/${entityId}`,
2045
+ {},
2046
+ {
2047
+ headers: this.managingHeaders
2048
+ }
2049
+ );
2050
+ }
2051
+ /**
2052
+ * Retrieves comments on content.
2053
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}/comments/{entityId}
2054
+ */
2055
+ async getComments(contentTypeUniqueId, entityId, params = {}) {
2056
+ return this.http.get(
2057
+ `/api/core/contents/${contentTypeUniqueId}/comments/${entityId}`,
2058
+ {
2059
+ params,
2060
+ headers: this.commonHeaders
2061
+ }
2062
+ );
2063
+ }
2064
+ /**
2065
+ * Retrieves list of likes for content.
2066
+ * Swagger: GET /api/core/contents/{contentUniqueId}/like/{entityId}
2067
+ */
2068
+ async getLikes(contentUniqueId, entityId, params = {}) {
2069
+ return this.http.get(
2070
+ `/api/core/contents/${contentUniqueId}/like/${entityId}`,
2071
+ {
2072
+ params,
2073
+ headers: this.commonHeaders
2074
+ }
2075
+ );
2076
+ }
2077
+ /**
2078
+ * Retrieves list of dislikes for content.
2079
+ * Swagger: GET /api/core/contents/{contentUniqueId}/dislike/{entityId}
2080
+ */
2081
+ async getDislikes(contentUniqueId, entityId, params = {}) {
2082
+ return this.http.get(
2083
+ `/api/core/contents/${contentUniqueId}/dislike/${entityId}`,
2084
+ {
2085
+ params,
2086
+ headers: this.commonHeaders
2087
+ }
2088
+ );
2089
+ }
2090
+ /**
2091
+ * Retrieves tag/category tree.
2092
+ * Backward-compatible delegate pointing to `cms.tags.getTagTree('root', params, options)`.
2093
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
2094
+ */
2095
+ async getCategories(params = {}, options = {}) {
2096
+ return this.tags.getTagTree("root", params, options);
2097
+ }
2098
+ /**
2099
+ * Retrieves details of a content type structure.
2100
+ * Swagger: GET /api/core/content-types/{contentTypeUniqueId}
2101
+ */
2102
+ async getContentTypeDetail(contentTypeUniqueId) {
2103
+ try {
2104
+ return await this.http.get(`/api/core/content-types/${contentTypeUniqueId}`, {
2105
+ headers: this.managingHeaders
2106
+ });
2107
+ } catch {
2108
+ return {};
2109
+ }
2110
+ }
2111
+ /**
2112
+ * Performs advanced AI timeline search on content.
2113
+ * Swagger: GET /api/core/contents/ai/timeline-search/enable
2114
+ */
2115
+ async timelineSearch(query) {
2116
+ const params = {};
2117
+ if (query?.advance) {
2118
+ params.advance = JSON.stringify(query.advance);
2119
+ params.newVersion = true;
2120
+ }
2121
+ if (query?.offset) {
2122
+ params.offset = query.offset;
2123
+ }
2124
+ if (query?.size) {
2125
+ params.size = query.size;
2126
+ }
2127
+ return this.http.get(
2128
+ "/api/core/contents/ai/timeline-search/enable",
2129
+ {
2130
+ params,
2131
+ headers: this.commonHeaders
2132
+ }
2133
+ );
2134
+ }
2135
+ // =========================================================================
2136
+ // CONVENIENCE DELEGATES FOR PRODUCTS
2137
+ // =========================================================================
2138
+ /**
2139
+ * Delegate to `cms.products.getProducts(...)`.
2140
+ */
2141
+ async getProducts(params = {}, options = {}) {
2142
+ return this.products.getProducts(params, options);
2143
+ }
2144
+ /**
2145
+ * Delegate to `cms.products.getProductByEntityId(...)`.
2146
+ */
2147
+ async getProductByEntityId(params, options = {}) {
2148
+ return this.products.getProductByEntityId(params, options);
2149
+ }
2150
+ /**
2151
+ * Delegate to `cms.products.addProduct(...)`.
2152
+ */
2153
+ async addProduct(params, options = {}) {
2154
+ return this.products.addProduct(params, options);
2155
+ }
2156
+ /**
2157
+ * Delegate to `cms.products.editProduct(...)`.
2158
+ */
2159
+ async editProduct(entityId, params, options = {}) {
2160
+ return this.products.editProduct(entityId, params, options);
2161
+ }
941
2162
  };
942
2163
  var IumsService = class {
943
2164
  http;
@@ -1017,6 +2238,8 @@ var PodSdk = class {
1017
2238
  notification;
1018
2239
  social;
1019
2240
  cms;
2241
+ product;
2242
+ tags;
1020
2243
  iums;
1021
2244
  constructor(config) {
1022
2245
  const urls = {
@@ -1073,6 +2296,8 @@ var PodSdk = class {
1073
2296
  podspaceUrl: urls.podspace,
1074
2297
  revalidate
1075
2298
  });
2299
+ this.product = this.cms.products;
2300
+ this.tags = this.cms.tags;
1076
2301
  this.iums = new IumsService({
1077
2302
  baseUrl: urls.iums,
1078
2303
  clientId,
@@ -1091,6 +2316,6 @@ function createPodSdk(config) {
1091
2316
  }
1092
2317
  var client_default = PodSdk;
1093
2318
 
1094
- export { CmsDataFormatter, CmsService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
2319
+ export { CmsDataFormatter, CmsProductService, CmsService, CmsTagService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
1095
2320
  //# sourceMappingURL=index.mjs.map
1096
2321
  //# sourceMappingURL=index.mjs.map