@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.js CHANGED
@@ -679,7 +679,7 @@ var CmsDataFormatter = class {
679
679
  generateImage(hash, defaultSrc = "") {
680
680
  return hash ? `${this.podspaceUrl}/api/images/${hash}?dl=1` : defaultSrc;
681
681
  }
682
- formatContentItem(item, normalizer) {
682
+ formatItem(item, normalizer) {
683
683
  if (typeof item === "number" || !item || typeof item !== "object") {
684
684
  return item;
685
685
  }
@@ -689,23 +689,31 @@ var CmsDataFormatter = class {
689
689
  __normalized: {}
690
690
  };
691
691
  const formatted = {};
692
- if (Array.isArray(item?.metadata?.content)) {
693
- item.metadata.content.forEach((detail) => {
694
- switch (detail.type) {
695
- case "IMAGE_TYPE": {
696
- formatted[detail.code] = Array.isArray(detail.value) ? detail.value.map((v) => this.generateImage(v)) : this.generateImage(detail.value);
697
- break;
698
- }
699
- default:
700
- formatted[detail.code] = detail.value !== void 0 ? detail.value : "";
692
+ const fieldList = Array.isArray(item?.metadata?.content) ? item.metadata.content : Array.isArray(item?.metadata?.product) ? item.metadata.product : [];
693
+ fieldList.forEach((detail) => {
694
+ switch (detail.type) {
695
+ case "IMAGE_TYPE": {
696
+ formatted[detail.code] = Array.isArray(detail.value) ? detail.value.map((v) => this.generateImage(v)) : this.generateImage(detail.value);
697
+ break;
701
698
  }
702
- });
703
- }
699
+ default:
700
+ formatted[detail.code] = detail.value !== void 0 ? detail.value : "";
701
+ }
702
+ });
704
703
  if (Array.isArray(item?.metadata?.content_related)) {
705
704
  item.metadata.content_related.forEach((detail) => {
706
705
  if (detail?.uniqueId && Array.isArray(detail.values)) {
707
706
  formatted[detail.uniqueId] = detail.values.map(
708
- (val) => this.formatContentItem(val)
707
+ (val) => this.formatItem(val)
708
+ );
709
+ }
710
+ });
711
+ }
712
+ if (Array.isArray(item?.metadata?.product_related)) {
713
+ item.metadata.product_related.forEach((detail) => {
714
+ if (detail?.uniqueId && Array.isArray(detail.values)) {
715
+ formatted[detail.uniqueId] = detail.values.map(
716
+ (val) => this.formatItem(val)
709
717
  );
710
718
  }
711
719
  });
@@ -716,6 +724,12 @@ var CmsDataFormatter = class {
716
724
  }
717
725
  return newItem;
718
726
  }
727
+ formatContentItem(item, normalizer) {
728
+ return this.formatItem(item, normalizer);
729
+ }
730
+ formatProductItem(item, normalizer) {
731
+ return this.formatItem(item, normalizer);
732
+ }
719
733
  formatGetContentResponse(response, normalizer) {
720
734
  if (response && Array.isArray(response.result)) {
721
735
  const result = response.result.map(
@@ -728,10 +742,20 @@ var CmsDataFormatter = class {
728
742
  }
729
743
  return response || {};
730
744
  }
745
+ formatGetProductResponse(response, normalizer) {
746
+ if (response && Array.isArray(response.result)) {
747
+ const result = response.result.map(
748
+ (item) => this.formatProductItem(item, normalizer)
749
+ );
750
+ return {
751
+ ...response,
752
+ result
753
+ };
754
+ }
755
+ return response || {};
756
+ }
731
757
  };
732
-
733
- // src/services/cms/index.ts
734
- var CmsService = class {
758
+ var CmsProductService = class {
735
759
  http;
736
760
  formatter;
737
761
  clientId;
@@ -741,10 +765,10 @@ var CmsService = class {
741
765
  this.clientId = options.clientId || "";
742
766
  this.apiToken = options.apiToken || "";
743
767
  this.revalidate = Number(options.revalidate) || 0;
744
- this.formatter = new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
745
- this.http = http.createNextHttp({
746
- baseUrl: options.baseUrl,
747
- serviceName: "POD-CMS"
768
+ this.formatter = options.formatter || new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
769
+ this.http = options.http || http.createNextHttp({
770
+ baseUrl: options.baseUrl || "https://cms.pod.ir",
771
+ serviceName: "POD-CMS-PRODUCT"
748
772
  });
749
773
  }
750
774
  get commonHeaders() {
@@ -760,9 +784,10 @@ var CmsService = class {
760
784
  };
761
785
  }
762
786
  /**
763
- * Retrieves enabled published content from CMS, formatted with generic metadata type T and optional normalized type P.
787
+ * Retrieves enabled published products from CMS, formatted with generic metadata type T and optional normalized type P.
788
+ * Swagger: GET /api/core/products/enable
764
789
  */
765
- async getContent(params = {}, options = {}) {
790
+ async getProducts(params = {}, options = {}) {
766
791
  const transferParams = {
767
792
  size: 50,
768
793
  offset: 0,
@@ -770,7 +795,7 @@ var CmsService = class {
770
795
  ...params
771
796
  };
772
797
  try {
773
- const res = await this.http.get("/api/core/contents/enable", {
798
+ const res = await this.http.get("/api/core/products/enable", {
774
799
  params: transferParams,
775
800
  headers: {
776
801
  ...this.commonHeaders,
@@ -782,15 +807,16 @@ var CmsService = class {
782
807
  revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
783
808
  }
784
809
  });
785
- return this.formatter.formatGetContentResponse(res, options.normalizer);
810
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
786
811
  } catch {
787
812
  return { hasError: true, result: [] };
788
813
  }
789
814
  }
790
815
  /**
791
- * Retrieves content using managing credentials (Access-Token).
816
+ * Retrieves all products using Provider credentials (Access-Token).
817
+ * Swagger: GET /api/core/products
792
818
  */
793
- async getContent2(params = {}, options = {}) {
819
+ async getAllProducts(params = {}, options = {}) {
794
820
  const transferParams = {
795
821
  size: 50,
796
822
  offset: 0,
@@ -798,7 +824,7 @@ var CmsService = class {
798
824
  ...params
799
825
  };
800
826
  try {
801
- const res = await this.http.get("/api/core/contents", {
827
+ const res = await this.http.get("/api/core/products", {
802
828
  params: transferParams,
803
829
  headers: {
804
830
  ...this.managingHeaders,
@@ -810,24 +836,24 @@ var CmsService = class {
810
836
  revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
811
837
  }
812
838
  });
813
- return this.formatter.formatGetContentResponse(res, options.normalizer);
839
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
814
840
  } catch {
815
841
  return { hasError: true, result: [] };
816
842
  }
817
843
  }
818
844
  /**
819
- * Retrieves unpublished/draft content (enable: false).
845
+ * Retrieves products for management view.
846
+ * Swagger: GET /api/core/products/manage
820
847
  */
821
- async getUnpublishedContent(params = {}, options = {}) {
848
+ async getManageProducts(params = {}, options = {}) {
822
849
  const transferParams = {
823
850
  size: 50,
824
851
  offset: 0,
825
852
  showDetail: true,
826
- enable: false,
827
853
  ...params
828
854
  };
829
855
  try {
830
- const res = await this.http.get("/api/core/contents", {
856
+ const res = await this.http.get("/api/core/products/manage", {
831
857
  params: transferParams,
832
858
  headers: {
833
859
  ...this.managingHeaders,
@@ -839,16 +865,49 @@ var CmsService = class {
839
865
  revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
840
866
  }
841
867
  });
842
- return this.formatter.formatGetContentResponse(res, options.normalizer);
868
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
843
869
  } catch {
844
870
  return { hasError: true, result: [] };
845
871
  }
846
872
  }
847
873
  /**
848
- * Retrieves single content by entityId and optional contentTypeUniqueId.
874
+ * Retrieves products by ProductType unique identifier.
875
+ * Swagger: GET /api/core/products/{productTypeUniqueId}
849
876
  */
850
- async getContentByEntityId(params, options = {}) {
851
- const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/enable/${params.entityId}` : `/api/core/contents/enable/${params.entityId}`;
877
+ async getProductsByType(productTypeUniqueId, params = {}, options = {}) {
878
+ const transferParams = {
879
+ size: 50,
880
+ offset: 0,
881
+ showDetail: true,
882
+ ...params
883
+ };
884
+ try {
885
+ const res = await this.http.get(
886
+ `/api/core/products/${productTypeUniqueId}`,
887
+ {
888
+ params: transferParams,
889
+ headers: {
890
+ ...this.managingHeaders,
891
+ ...options.headers
892
+ },
893
+ cache: options.cache,
894
+ signal: options.signal,
895
+ next: {
896
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
897
+ }
898
+ }
899
+ );
900
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
901
+ } catch {
902
+ return { hasError: true, result: [] };
903
+ }
904
+ }
905
+ /**
906
+ * Retrieves a single published product by entityId.
907
+ * Swagger: GET /api/core/products/enable/{entityId} OR /api/core/products/{productTypeUniqueId}/enable/{entityId}
908
+ */
909
+ async getProductByEntityId(params, options = {}) {
910
+ const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/enable/${params.entityId}` : `/api/core/products/enable/${params.entityId}`;
852
911
  try {
853
912
  const res = await this.http.get(url, {
854
913
  headers: {
@@ -861,72 +920,244 @@ var CmsService = class {
861
920
  revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
862
921
  }
863
922
  });
864
- return this.formatter.formatGetContentResponse(res, options.normalizer);
923
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
865
924
  } catch {
866
925
  return { hasError: true, result: [] };
867
926
  }
868
927
  }
869
928
  /**
870
- * Retrieves tag/category tree.
929
+ * Retrieves a single product by uniqueId.
930
+ * Swagger: GET /api/core/products/{productUniqueId}/byProductUniqueId/enable
871
931
  */
872
- async getCategories(params = {}, options = {}) {
932
+ async getProductByUniqueId(productUniqueId, options = {}) {
873
933
  try {
874
- return await this.http.get("/api/core/tags/root/tree/enable", {
875
- params,
876
- headers: {
877
- ...this.commonHeaders,
878
- ...options.headers
879
- },
880
- cache: options.cache,
881
- signal: options.signal,
882
- next: {
883
- revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
934
+ const res = await this.http.get(
935
+ `/api/core/products/${productUniqueId}/byProductUniqueId/enable`,
936
+ {
937
+ headers: {
938
+ ...this.commonHeaders,
939
+ ...options.headers
940
+ },
941
+ cache: options.cache,
942
+ signal: options.signal,
943
+ next: {
944
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
945
+ }
884
946
  }
885
- });
947
+ );
948
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
886
949
  } catch {
887
950
  return { hasError: true, result: [] };
888
951
  }
889
952
  }
890
953
  /**
891
- * Retrieves details of a content type structure.
954
+ * Retrieves products matching a barcode.
955
+ * Swagger: GET /api/core/products/barcode/enable
892
956
  */
893
- async getContentTypeDetail(contentTypeUniqueId) {
957
+ async getProductByBarcode(barcode, options = {}) {
894
958
  try {
895
- return await this.http.get(`/api/core/content-types/${contentTypeUniqueId}`, {
896
- headers: this.managingHeaders
897
- });
959
+ const res = await this.http.get(
960
+ "/api/core/products/barcode/enable",
961
+ {
962
+ params: { barcode },
963
+ headers: {
964
+ ...this.commonHeaders,
965
+ ...options.headers
966
+ },
967
+ cache: options.cache,
968
+ signal: options.signal,
969
+ next: {
970
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
971
+ }
972
+ }
973
+ );
974
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
898
975
  } catch {
899
- return {};
976
+ return { hasError: true, result: [] };
900
977
  }
901
978
  }
902
979
  /**
903
- * Adds and publishes new content to CMS.
980
+ * Searches published products by keyword.
981
+ * Swagger: GET /api/core/products/enable/search
904
982
  */
905
- async addContent(params, options = {}) {
983
+ async searchProducts(params = {}, options = {}) {
984
+ try {
985
+ const res = await this.http.get(
986
+ "/api/core/products/enable/search",
987
+ {
988
+ params,
989
+ headers: {
990
+ ...this.commonHeaders,
991
+ ...options.headers
992
+ },
993
+ cache: options.cache,
994
+ signal: options.signal,
995
+ next: {
996
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
997
+ }
998
+ }
999
+ );
1000
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
1001
+ } catch {
1002
+ return { hasError: true, result: [] };
1003
+ }
1004
+ }
1005
+ /**
1006
+ * Creates and publishes a new product.
1007
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/add-publish
1008
+ */
1009
+ async addProduct(params, options = {}) {
906
1010
  const res = await this.http.post(
907
- `/api/core/contents/${params.contentTypeUniqueId}/add-publish`,
1011
+ `/api/core/products/${params.productTypeUniqueId}/add-publish`,
908
1012
  params.body,
909
1013
  {
910
1014
  headers: this.managingHeaders
911
1015
  }
912
1016
  );
913
- return this.formatter.formatGetContentResponse(res, options.normalizer);
1017
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
914
1018
  }
915
1019
  /**
916
- * Edits and publishes existing content by entityId.
1020
+ * Creates a draft/unpublished product.
1021
+ * Swagger: POST /api/core/products/{productTypeUniqueId}
917
1022
  */
918
- async editContent(entityId, params, options = {}) {
1023
+ async createProduct(params, options = {}) {
919
1024
  const res = await this.http.post(
920
- `/api/core/contents/${params.contentTypeUniqueId}/${entityId}/edit-publish`,
1025
+ `/api/core/products/${params.productTypeUniqueId}`,
921
1026
  params.body,
922
1027
  {
923
1028
  headers: this.managingHeaders
924
1029
  }
925
1030
  );
926
- return this.formatter.formatGetContentResponse(res, options.normalizer);
1031
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
1032
+ }
1033
+ /**
1034
+ * Edits and publishes an existing product by entityId.
1035
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/{entityId}/edit-publish
1036
+ */
1037
+ async editProduct(entityId, params, options = {}) {
1038
+ const res = await this.http.post(
1039
+ `/api/core/products/${params.productTypeUniqueId}/${entityId}/edit-publish`,
1040
+ params.body,
1041
+ {
1042
+ headers: this.managingHeaders
1043
+ }
1044
+ );
1045
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
1046
+ }
1047
+ /**
1048
+ * Updates an existing product.
1049
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/{entityId}
1050
+ */
1051
+ async updateProduct(entityId, params, options = {}) {
1052
+ const res = await this.http.post(
1053
+ `/api/core/products/${params.productTypeUniqueId}/${entityId}`,
1054
+ params.body,
1055
+ {
1056
+ headers: this.managingHeaders
1057
+ }
1058
+ );
1059
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
1060
+ }
1061
+ /**
1062
+ * Partially updates an existing product.
1063
+ * Swagger: PATCH /api/core/products/{productTypeUniqueId}/{entityId}
1064
+ */
1065
+ async patchProduct(entityId, params, options = {}) {
1066
+ const res = await this.http.patch(
1067
+ `/api/core/products/${params.productTypeUniqueId}/${entityId}`,
1068
+ params.body,
1069
+ {
1070
+ headers: this.managingHeaders
1071
+ }
1072
+ );
1073
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
1074
+ }
1075
+ /**
1076
+ * Publishes an existing product.
1077
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/publish/{entityId}
1078
+ */
1079
+ async publishProduct(productTypeUniqueId, entityId) {
1080
+ return this.http.post(
1081
+ `/api/core/products/${productTypeUniqueId}/publish/${entityId}`,
1082
+ {},
1083
+ {
1084
+ headers: this.managingHeaders
1085
+ }
1086
+ );
1087
+ }
1088
+ /**
1089
+ * Unpublishes an existing product.
1090
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/unpublish/{entityId}
1091
+ */
1092
+ async unpublishProduct(productTypeUniqueId, entityId) {
1093
+ return this.http.post(
1094
+ `/api/core/products/${productTypeUniqueId}/unpublish/${entityId}`,
1095
+ {},
1096
+ {
1097
+ headers: this.managingHeaders
1098
+ }
1099
+ );
1100
+ }
1101
+ /**
1102
+ * Batch publishes products.
1103
+ * Swagger: PUT /api/core/products/{productTypeUniqueId}/publish OR /api/core/products/publish
1104
+ */
1105
+ async batchPublish(params) {
1106
+ const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/publish` : "/api/core/products/publish";
1107
+ return this.http.put(url, { entityIds: params.entityIds }, {
1108
+ headers: this.managingHeaders
1109
+ });
1110
+ }
1111
+ /**
1112
+ * Batch unpublishes products.
1113
+ * Swagger: PUT /api/core/products/{productTypeUniqueId}/unpublish OR /api/core/products/unpublish
1114
+ */
1115
+ async batchUnpublish(params) {
1116
+ const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/unpublish` : "/api/core/products/unpublish";
1117
+ return this.http.put(url, { entityIds: params.entityIds }, {
1118
+ headers: this.managingHeaders
1119
+ });
1120
+ }
1121
+ /**
1122
+ * Archives products.
1123
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/archive OR /api/core/products/archive
1124
+ */
1125
+ async archiveProduct(params) {
1126
+ const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/archive` : "/api/core/products/archive";
1127
+ return this.http.post(url, { entityIds: params.entityIds }, {
1128
+ headers: this.managingHeaders
1129
+ });
1130
+ }
1131
+ /**
1132
+ * Unarchives products.
1133
+ * Swagger: POST /api/core/products/{productTypeUniqueId}/unarchive OR /api/core/products/unarchive
1134
+ */
1135
+ async unarchiveProduct(params) {
1136
+ const url = params.productTypeUniqueId ? `/api/core/products/${params.productTypeUniqueId}/unarchive` : "/api/core/products/unarchive";
1137
+ return this.http.post(url, { entityIds: params.entityIds }, {
1138
+ headers: this.managingHeaders
1139
+ });
1140
+ }
1141
+ /**
1142
+ * Gets list of archived products.
1143
+ * Swagger: GET /api/core/products/archive OR /api/core/products/{productTypeUniqueId}/archive
1144
+ */
1145
+ async getArchivedProducts(params = {}, options = {}) {
1146
+ const { productTypeUniqueId, ...rest } = params;
1147
+ const url = productTypeUniqueId ? `/api/core/products/${productTypeUniqueId}/archive` : "/api/core/products/archive";
1148
+ try {
1149
+ const res = await this.http.get(url, {
1150
+ params: rest,
1151
+ headers: this.managingHeaders
1152
+ });
1153
+ return this.formatter.formatGetProductResponse(res, options.normalizer);
1154
+ } catch {
1155
+ return { hasError: true, result: [] };
1156
+ }
927
1157
  }
928
1158
  /**
929
- * Performs advanced AI timeline search.
1159
+ * Performs advanced AI timeline search on products.
1160
+ * Swagger: GET /api/core/products/ai/timeline-search/enable
930
1161
  */
931
1162
  async timelineSearch(query) {
932
1163
  const params = {};
@@ -937,11 +1168,1001 @@ var CmsService = class {
937
1168
  if (query?.offset) {
938
1169
  params.offset = query.offset;
939
1170
  }
940
- return this.http.get("/api/core/ai-service/timeline-search/enable", {
941
- params,
942
- headers: this.commonHeaders
1171
+ if (query?.size) {
1172
+ params.size = query.size;
1173
+ }
1174
+ return this.http.get(
1175
+ "/api/core/products/ai/timeline-search/enable",
1176
+ {
1177
+ params,
1178
+ headers: this.commonHeaders
1179
+ }
1180
+ );
1181
+ }
1182
+ };
1183
+ var CmsTagService = class {
1184
+ http;
1185
+ clientId;
1186
+ apiToken;
1187
+ revalidate;
1188
+ constructor(options) {
1189
+ this.clientId = options.clientId || "";
1190
+ this.apiToken = options.apiToken || "";
1191
+ this.revalidate = Number(options.revalidate) || 0;
1192
+ this.http = options.http || http.createNextHttp({
1193
+ baseUrl: options.baseUrl || "https://cms.pod.ir",
1194
+ serviceName: "POD-CMS-TAGS"
1195
+ });
1196
+ }
1197
+ get commonHeaders() {
1198
+ return {
1199
+ "Client-Id": this.clientId,
1200
+ "Content-Type": "application/json"
1201
+ };
1202
+ }
1203
+ get managingHeaders() {
1204
+ return {
1205
+ ...this.commonHeaders,
1206
+ "Access-Token": this.apiToken
1207
+ };
1208
+ }
1209
+ // =========================================================================
1210
+ // 1. TAG CATEGORY MANAGEMENT (Swagger: /api/core/tags/category)
1211
+ // =========================================================================
1212
+ /**
1213
+ * Retrieves list of tag categories.
1214
+ * Swagger: GET /api/core/tags/category
1215
+ */
1216
+ async getTagCategories(params = {}, options = {}) {
1217
+ try {
1218
+ return await this.http.get("/api/core/tags/category", {
1219
+ params,
1220
+ headers: {
1221
+ ...this.managingHeaders,
1222
+ ...options.headers
1223
+ },
1224
+ cache: options.cache,
1225
+ signal: options.signal,
1226
+ next: {
1227
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1228
+ }
1229
+ });
1230
+ } catch {
1231
+ return { hasError: true, result: [] };
1232
+ }
1233
+ }
1234
+ /**
1235
+ * Creates a new tag category.
1236
+ * Swagger: POST /api/core/tags/category
1237
+ */
1238
+ async createTagCategory(params, options = {}) {
1239
+ return this.http.post(
1240
+ "/api/core/tags/category",
1241
+ {},
1242
+ {
1243
+ params: {
1244
+ name: params.name,
1245
+ desc: params.desc
1246
+ },
1247
+ headers: {
1248
+ ...this.managingHeaders,
1249
+ ...options.headers
1250
+ }
1251
+ }
1252
+ );
1253
+ }
1254
+ /**
1255
+ * Retrieves single tag category by ID.
1256
+ * Swagger: GET /api/core/tags/category/{id}
1257
+ */
1258
+ async getTagCategory(id, options = {}) {
1259
+ return this.http.get(`/api/core/tags/category/${id}`, {
1260
+ headers: {
1261
+ ...this.managingHeaders,
1262
+ ...options.headers
1263
+ },
1264
+ cache: options.cache,
1265
+ signal: options.signal,
1266
+ next: {
1267
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1268
+ }
943
1269
  });
944
1270
  }
1271
+ /**
1272
+ * Updates an existing tag category.
1273
+ * Swagger: PUT /api/core/tags/category/{id}
1274
+ */
1275
+ async updateTagCategory(id, params, options = {}) {
1276
+ return this.http.put(
1277
+ `/api/core/tags/category/${id}`,
1278
+ {},
1279
+ {
1280
+ params: {
1281
+ name: params.name,
1282
+ desc: params.desc,
1283
+ enable: params.enable
1284
+ },
1285
+ headers: {
1286
+ ...this.managingHeaders,
1287
+ ...options.headers
1288
+ }
1289
+ }
1290
+ );
1291
+ }
1292
+ /**
1293
+ * Publishes a tag category.
1294
+ * Swagger: PUT /api/core/tags/category/{id}/publish
1295
+ */
1296
+ async publishTagCategory(id, options = {}) {
1297
+ return this.http.put(
1298
+ `/api/core/tags/category/${id}/publish`,
1299
+ {},
1300
+ {
1301
+ headers: {
1302
+ ...this.managingHeaders,
1303
+ ...options.headers
1304
+ }
1305
+ }
1306
+ );
1307
+ }
1308
+ /**
1309
+ * Unpublishes a tag category.
1310
+ * Swagger: PUT /api/core/tags/category/{id}/unpublish
1311
+ */
1312
+ async unpublishTagCategory(id, options = {}) {
1313
+ return this.http.put(
1314
+ `/api/core/tags/category/${id}/unpublish`,
1315
+ {},
1316
+ {
1317
+ headers: {
1318
+ ...this.managingHeaders,
1319
+ ...options.headers
1320
+ }
1321
+ }
1322
+ );
1323
+ }
1324
+ // =========================================================================
1325
+ // 2. TAG TREE & HIERARCHY (Swagger: /api/core/tags/{categoryId}/tree/...)
1326
+ // =========================================================================
1327
+ /**
1328
+ * Retrieves enabled published tag tree for category (defaults to 'root').
1329
+ * End user call (without requiring Access-Token).
1330
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
1331
+ */
1332
+ async getTagTree(categoryId = "root", params = {}, options = {}) {
1333
+ try {
1334
+ return await this.http.get(
1335
+ `/api/core/tags/${categoryId}/tree/enable`,
1336
+ {
1337
+ params,
1338
+ headers: {
1339
+ ...this.commonHeaders,
1340
+ ...options.headers
1341
+ },
1342
+ cache: options.cache,
1343
+ signal: options.signal,
1344
+ next: {
1345
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1346
+ }
1347
+ }
1348
+ );
1349
+ } catch {
1350
+ return { hasError: true, result: [] };
1351
+ }
1352
+ }
1353
+ /**
1354
+ * Retrieves tag tree for category with management credentials.
1355
+ * Swagger: GET /api/core/tags/{categoryId}/tree/manage
1356
+ */
1357
+ async getManageTagTree(categoryId, params = {}, options = {}) {
1358
+ try {
1359
+ return await this.http.get(
1360
+ `/api/core/tags/${categoryId}/tree/manage`,
1361
+ {
1362
+ params,
1363
+ headers: {
1364
+ ...this.managingHeaders,
1365
+ ...options.headers
1366
+ },
1367
+ cache: options.cache,
1368
+ signal: options.signal,
1369
+ next: {
1370
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1371
+ }
1372
+ }
1373
+ );
1374
+ } catch {
1375
+ return { hasError: true, result: [] };
1376
+ }
1377
+ }
1378
+ /**
1379
+ * Creates a new tag tree node for category.
1380
+ * Swagger: POST /api/core/tags/{categoryId}/tree
1381
+ */
1382
+ async createTagTreeItem(categoryId, params, options = {}) {
1383
+ const { relatedContentIds, ...rest } = params;
1384
+ const queryParams = { ...rest };
1385
+ if (Array.isArray(relatedContentIds)) {
1386
+ queryParams["relatedContentIds[]"] = relatedContentIds;
1387
+ }
1388
+ return this.http.post(
1389
+ `/api/core/tags/${categoryId}/tree`,
1390
+ {},
1391
+ {
1392
+ params: queryParams,
1393
+ headers: {
1394
+ ...this.managingHeaders,
1395
+ ...options.headers
1396
+ }
1397
+ }
1398
+ );
1399
+ }
1400
+ /**
1401
+ * Shows a single enabled tag tree item for end users.
1402
+ * Swagger: GET /api/core/tags/{categoryId}/tree/{id}/enable
1403
+ */
1404
+ async getTagTreeItem(categoryId, id, options = {}) {
1405
+ return this.http.get(`/api/core/tags/${categoryId}/tree/${id}/enable`, {
1406
+ headers: {
1407
+ ...this.commonHeaders,
1408
+ ...options.headers
1409
+ },
1410
+ cache: options.cache,
1411
+ signal: options.signal,
1412
+ next: {
1413
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1414
+ }
1415
+ });
1416
+ }
1417
+ /**
1418
+ * Shows a single tag tree item for manager (with token).
1419
+ * Swagger: GET /api/core/tags/{categoryId}/tree/{id}/manage
1420
+ */
1421
+ async getManageTagTreeItem(categoryId, id, options = {}) {
1422
+ return this.http.get(`/api/core/tags/${categoryId}/tree/${id}/manage`, {
1423
+ headers: {
1424
+ ...this.managingHeaders,
1425
+ ...options.headers
1426
+ },
1427
+ cache: options.cache,
1428
+ signal: options.signal,
1429
+ next: {
1430
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1431
+ }
1432
+ });
1433
+ }
1434
+ /**
1435
+ * Updates an existing tag tree node.
1436
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/{id}
1437
+ */
1438
+ async updateTagTreeItem(categoryId, id, params, options = {}) {
1439
+ const { relatedContentIds, ...rest } = params;
1440
+ const queryParams = { ...rest };
1441
+ if (Array.isArray(relatedContentIds)) {
1442
+ queryParams["relatedContentIds[]"] = relatedContentIds;
1443
+ }
1444
+ return this.http.put(
1445
+ `/api/core/tags/${categoryId}/tree/${id}`,
1446
+ {},
1447
+ {
1448
+ params: queryParams,
1449
+ headers: {
1450
+ ...this.managingHeaders,
1451
+ ...options.headers
1452
+ }
1453
+ }
1454
+ );
1455
+ }
1456
+ /**
1457
+ * Publishes a tag tree item.
1458
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/publish/{id}
1459
+ */
1460
+ async publishTagTreeItem(categoryId, id, options = {}) {
1461
+ return this.http.put(
1462
+ `/api/core/tags/${categoryId}/tree/publish/${id}`,
1463
+ {},
1464
+ {
1465
+ headers: {
1466
+ ...this.managingHeaders,
1467
+ ...options.headers
1468
+ }
1469
+ }
1470
+ );
1471
+ }
1472
+ /**
1473
+ * Unpublishes a tag tree item.
1474
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/unpublish/{id}
1475
+ */
1476
+ async unpublishTagTreeItem(categoryId, id, options = {}) {
1477
+ return this.http.put(
1478
+ `/api/core/tags/${categoryId}/tree/unpublish/${id}`,
1479
+ {},
1480
+ {
1481
+ headers: {
1482
+ ...this.managingHeaders,
1483
+ ...options.headers
1484
+ }
1485
+ }
1486
+ );
1487
+ }
1488
+ /**
1489
+ * Updates the parent of a tag tree item.
1490
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/parent/{id}
1491
+ */
1492
+ async updateTagTreeParent(categoryId, id, parentId, options = {}) {
1493
+ return this.http.put(
1494
+ `/api/core/tags/${categoryId}/tree/parent/${id}`,
1495
+ {},
1496
+ {
1497
+ params: {
1498
+ parentId: parentId !== void 0 ? String(parentId) : ""
1499
+ },
1500
+ headers: {
1501
+ ...this.managingHeaders,
1502
+ ...options.headers
1503
+ }
1504
+ }
1505
+ );
1506
+ }
1507
+ /**
1508
+ * Retrieves tag tree ancestors for end user.
1509
+ * Swagger: GET /api/core/tags/{categoryId}/tree/parent/{id}/enable
1510
+ */
1511
+ async getTagTreeAncestors(categoryId, id, params = {}, options = {}) {
1512
+ try {
1513
+ return await this.http.get(
1514
+ `/api/core/tags/${categoryId}/tree/parent/${id}/enable`,
1515
+ {
1516
+ params,
1517
+ headers: {
1518
+ ...this.commonHeaders,
1519
+ ...options.headers
1520
+ },
1521
+ cache: options.cache,
1522
+ signal: options.signal,
1523
+ next: {
1524
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1525
+ }
1526
+ }
1527
+ );
1528
+ } catch {
1529
+ return { hasError: true, result: [] };
1530
+ }
1531
+ }
1532
+ /**
1533
+ * Retrieves tag tree ancestors for manager (with token).
1534
+ * Swagger: GET /api/core/tags/{categoryId}/tree/parent/{id}/manage
1535
+ */
1536
+ async getManageTagTreeAncestors(categoryId, id, params = {}, options = {}) {
1537
+ try {
1538
+ return await this.http.get(
1539
+ `/api/core/tags/${categoryId}/tree/parent/${id}/manage`,
1540
+ {
1541
+ params,
1542
+ headers: {
1543
+ ...this.managingHeaders,
1544
+ ...options.headers
1545
+ },
1546
+ cache: options.cache,
1547
+ signal: options.signal,
1548
+ next: {
1549
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1550
+ }
1551
+ }
1552
+ );
1553
+ } catch {
1554
+ return { hasError: true, result: [] };
1555
+ }
1556
+ }
1557
+ /**
1558
+ * Updates tag tree code for category.
1559
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/code/{id}
1560
+ */
1561
+ async updateTagTreeCode(categoryId, id, code, options = {}) {
1562
+ return this.http.put(
1563
+ `/api/core/tags/${categoryId}/tree/code/${id}`,
1564
+ {},
1565
+ {
1566
+ params: { code },
1567
+ headers: {
1568
+ ...this.managingHeaders,
1569
+ ...options.headers
1570
+ }
1571
+ }
1572
+ );
1573
+ }
1574
+ };
1575
+
1576
+ // src/services/cms/index.ts
1577
+ var CmsService = class {
1578
+ http;
1579
+ formatter;
1580
+ clientId;
1581
+ apiToken;
1582
+ revalidate;
1583
+ /**
1584
+ * Dedicated CMS Product sub-service.
1585
+ * Swagger: tag=product
1586
+ */
1587
+ products;
1588
+ /**
1589
+ * Dedicated CMS Tags & Tag Categories sub-service.
1590
+ * Swagger: tag=tags
1591
+ */
1592
+ tags;
1593
+ constructor(options) {
1594
+ this.clientId = options.clientId || "";
1595
+ this.apiToken = options.apiToken || "";
1596
+ this.revalidate = Number(options.revalidate) || 0;
1597
+ this.formatter = new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
1598
+ this.http = http.createNextHttp({
1599
+ baseUrl: options.baseUrl,
1600
+ serviceName: "POD-CMS"
1601
+ });
1602
+ this.products = new CmsProductService({
1603
+ http: this.http,
1604
+ formatter: this.formatter,
1605
+ clientId: this.clientId,
1606
+ apiToken: this.apiToken,
1607
+ revalidate: this.revalidate
1608
+ });
1609
+ this.tags = new CmsTagService({
1610
+ http: this.http,
1611
+ clientId: this.clientId,
1612
+ apiToken: this.apiToken,
1613
+ revalidate: this.revalidate
1614
+ });
1615
+ }
1616
+ get commonHeaders() {
1617
+ return {
1618
+ "Client-Id": this.clientId,
1619
+ "Content-Type": "application/json"
1620
+ };
1621
+ }
1622
+ get managingHeaders() {
1623
+ return {
1624
+ ...this.commonHeaders,
1625
+ "Access-Token": this.apiToken
1626
+ };
1627
+ }
1628
+ // =========================================================================
1629
+ // CONTENT METHODS (Swagger: tag=content)
1630
+ // =========================================================================
1631
+ /**
1632
+ * Retrieves enabled published content from CMS, formatted with generic metadata type T and optional normalized type P.
1633
+ * Swagger: GET /api/core/contents/enable
1634
+ */
1635
+ async getContent(params = {}, options = {}) {
1636
+ const transferParams = {
1637
+ size: 50,
1638
+ offset: 0,
1639
+ showDetail: true,
1640
+ ...params
1641
+ };
1642
+ try {
1643
+ const res = await this.http.get("/api/core/contents/enable", {
1644
+ params: transferParams,
1645
+ headers: {
1646
+ ...this.commonHeaders,
1647
+ ...options.headers
1648
+ },
1649
+ cache: options.cache,
1650
+ signal: options.signal,
1651
+ next: {
1652
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1653
+ }
1654
+ });
1655
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1656
+ } catch {
1657
+ return { hasError: true, result: [] };
1658
+ }
1659
+ }
1660
+ /**
1661
+ * Retrieves all contents using managing credentials (Access-Token).
1662
+ * Swagger: GET /api/core/contents
1663
+ */
1664
+ async getAllContents(params = {}, options = {}) {
1665
+ const transferParams = {
1666
+ size: 50,
1667
+ offset: 0,
1668
+ showDetail: true,
1669
+ ...params
1670
+ };
1671
+ try {
1672
+ const res = await this.http.get("/api/core/contents", {
1673
+ params: transferParams,
1674
+ headers: {
1675
+ ...this.managingHeaders,
1676
+ ...options.headers
1677
+ },
1678
+ cache: options.cache,
1679
+ signal: options.signal,
1680
+ next: {
1681
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1682
+ }
1683
+ });
1684
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1685
+ } catch {
1686
+ return { hasError: true, result: [] };
1687
+ }
1688
+ }
1689
+ /**
1690
+ * Retrieves current user/client contents.
1691
+ * Swagger: GET /api/core/contents/my
1692
+ */
1693
+ async getMyContents(params = {}, options = {}) {
1694
+ const transferParams = {
1695
+ size: 50,
1696
+ offset: 0,
1697
+ showDetail: true,
1698
+ ...params
1699
+ };
1700
+ try {
1701
+ const res = await this.http.get("/api/core/contents/my", {
1702
+ params: transferParams,
1703
+ headers: {
1704
+ ...this.managingHeaders,
1705
+ ...options.headers
1706
+ },
1707
+ cache: options.cache,
1708
+ signal: options.signal,
1709
+ next: {
1710
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1711
+ }
1712
+ });
1713
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1714
+ } catch {
1715
+ return { hasError: true, result: [] };
1716
+ }
1717
+ }
1718
+ /**
1719
+ * Retrieves contents by ContentType unique identifier.
1720
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}
1721
+ */
1722
+ async getContentsByType(contentTypeUniqueId, params = {}, options = {}) {
1723
+ const transferParams = {
1724
+ size: 50,
1725
+ offset: 0,
1726
+ showDetail: true,
1727
+ ...params
1728
+ };
1729
+ try {
1730
+ const res = await this.http.get(
1731
+ `/api/core/contents/${contentTypeUniqueId}`,
1732
+ {
1733
+ params: transferParams,
1734
+ headers: {
1735
+ ...this.managingHeaders,
1736
+ ...options.headers
1737
+ },
1738
+ cache: options.cache,
1739
+ signal: options.signal,
1740
+ next: {
1741
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1742
+ }
1743
+ }
1744
+ );
1745
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1746
+ } catch {
1747
+ return { hasError: true, result: [] };
1748
+ }
1749
+ }
1750
+ /**
1751
+ * Retrieves unpublished content (enable: false).
1752
+ */
1753
+ async getUnpublishedContent(params = {}, options = {}) {
1754
+ return this.getAllContents({ ...params, enable: false }, options);
1755
+ }
1756
+ /**
1757
+ * Retrieves single content by entityId and optional contentTypeUniqueId.
1758
+ * Swagger: GET /api/core/contents/enable/{entityId} OR /api/core/contents/{contentTypeUniqueId}/enable/{entityId}
1759
+ */
1760
+ async getContentByEntityId(params, options = {}) {
1761
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/enable/${params.entityId}` : `/api/core/contents/enable/${params.entityId}`;
1762
+ try {
1763
+ const res = await this.http.get(url, {
1764
+ headers: {
1765
+ ...this.commonHeaders,
1766
+ ...options.headers
1767
+ },
1768
+ cache: options.cache,
1769
+ signal: options.signal,
1770
+ next: {
1771
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1772
+ }
1773
+ });
1774
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1775
+ } catch {
1776
+ return { hasError: true, result: [] };
1777
+ }
1778
+ }
1779
+ /**
1780
+ * Retrieves content by unique identifier.
1781
+ * Swagger: GET /api/core/contents/{contentUniqueId}/byContentUniqueId/enable
1782
+ */
1783
+ async getContentByUniqueId(contentUniqueId, options = {}) {
1784
+ try {
1785
+ const res = await this.http.get(
1786
+ `/api/core/contents/${contentUniqueId}/byContentUniqueId/enable`,
1787
+ {
1788
+ headers: {
1789
+ ...this.commonHeaders,
1790
+ ...options.headers
1791
+ },
1792
+ cache: options.cache,
1793
+ signal: options.signal,
1794
+ next: {
1795
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1796
+ }
1797
+ }
1798
+ );
1799
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1800
+ } catch {
1801
+ return { hasError: true, result: [] };
1802
+ }
1803
+ }
1804
+ /**
1805
+ * Searches published contents by keyword.
1806
+ * Swagger: GET /api/core/contents/search
1807
+ */
1808
+ async searchContent(params = {}, options = {}) {
1809
+ try {
1810
+ const res = await this.http.get("/api/core/contents/search", {
1811
+ params,
1812
+ headers: {
1813
+ ...this.commonHeaders,
1814
+ ...options.headers
1815
+ },
1816
+ cache: options.cache,
1817
+ signal: options.signal,
1818
+ next: {
1819
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1820
+ }
1821
+ });
1822
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1823
+ } catch {
1824
+ return { hasError: true, result: [] };
1825
+ }
1826
+ }
1827
+ /**
1828
+ * Adds and publishes new content to CMS.
1829
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/add-publish
1830
+ */
1831
+ async addContent(params, options = {}) {
1832
+ const res = await this.http.post(
1833
+ `/api/core/contents/${params.contentTypeUniqueId}/add-publish`,
1834
+ params.body,
1835
+ {
1836
+ headers: this.managingHeaders
1837
+ }
1838
+ );
1839
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1840
+ }
1841
+ /**
1842
+ * Creates a new draft/unpublished content.
1843
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}
1844
+ */
1845
+ async createContent(params, options = {}) {
1846
+ const res = await this.http.post(
1847
+ `/api/core/contents/${params.contentTypeUniqueId}`,
1848
+ params.body,
1849
+ {
1850
+ headers: this.managingHeaders
1851
+ }
1852
+ );
1853
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1854
+ }
1855
+ /**
1856
+ * Edits and publishes existing content by entityId.
1857
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}/edit-publish
1858
+ */
1859
+ async editContent(entityId, params, options = {}) {
1860
+ const res = await this.http.post(
1861
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}/edit-publish`,
1862
+ params.body,
1863
+ {
1864
+ headers: this.managingHeaders
1865
+ }
1866
+ );
1867
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1868
+ }
1869
+ /**
1870
+ * Updates existing content.
1871
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}
1872
+ */
1873
+ async updateContent(entityId, params, options = {}) {
1874
+ const res = await this.http.post(
1875
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
1876
+ params.body,
1877
+ {
1878
+ headers: this.managingHeaders
1879
+ }
1880
+ );
1881
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1882
+ }
1883
+ /**
1884
+ * Partially updates existing content.
1885
+ * Swagger: PATCH /api/core/contents/{contentTypeUniqueId}/{entityId}
1886
+ */
1887
+ async patchContent(entityId, params, options = {}) {
1888
+ const res = await this.http.patch(
1889
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
1890
+ params.body,
1891
+ {
1892
+ headers: this.managingHeaders
1893
+ }
1894
+ );
1895
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1896
+ }
1897
+ /**
1898
+ * Publishes existing content.
1899
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/publish/{entityId}
1900
+ */
1901
+ async publishContent(contentTypeUniqueId, entityId) {
1902
+ return this.http.post(
1903
+ `/api/core/contents/${contentTypeUniqueId}/publish/${entityId}`,
1904
+ {},
1905
+ {
1906
+ headers: this.managingHeaders
1907
+ }
1908
+ );
1909
+ }
1910
+ /**
1911
+ * Unpublishes existing content.
1912
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/unpublish/{entityId}
1913
+ */
1914
+ async unpublishContent(contentTypeUniqueId, entityId) {
1915
+ return this.http.post(
1916
+ `/api/core/contents/${contentTypeUniqueId}/unpublish/${entityId}`,
1917
+ {},
1918
+ {
1919
+ headers: this.managingHeaders
1920
+ }
1921
+ );
1922
+ }
1923
+ /**
1924
+ * Batch publishes content items.
1925
+ * Swagger: PUT /api/core/contents/{contentTypeUniqueId}/publish OR /api/core/contents/publish
1926
+ */
1927
+ async batchPublish(params) {
1928
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/publish` : "/api/core/contents/publish";
1929
+ return this.http.put(url, { entityIds: params.entityIds }, {
1930
+ headers: this.managingHeaders
1931
+ });
1932
+ }
1933
+ /**
1934
+ * Batch unpublishes content items.
1935
+ * Swagger: PUT /api/core/contents/{contentTypeUniqueId}/unpublish OR /api/core/contents/unpublish
1936
+ */
1937
+ async batchUnpublish(params) {
1938
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unpublish` : "/api/core/contents/unpublish";
1939
+ return this.http.put(url, { entityIds: params.entityIds }, {
1940
+ headers: this.managingHeaders
1941
+ });
1942
+ }
1943
+ /**
1944
+ * Archives content items.
1945
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/archive
1946
+ */
1947
+ async archiveContent(params) {
1948
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/archive` : "/api/core/contents/archive";
1949
+ return this.http.post(url, { entityIds: params.entityIds }, {
1950
+ headers: this.managingHeaders
1951
+ });
1952
+ }
1953
+ /**
1954
+ * Unarchives content items.
1955
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/unarchive
1956
+ */
1957
+ async unarchiveContent(params) {
1958
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unarchive` : "/api/core/contents/unarchive";
1959
+ return this.http.post(url, { entityIds: params.entityIds }, {
1960
+ headers: this.managingHeaders
1961
+ });
1962
+ }
1963
+ /**
1964
+ * Retrieves list of archived contents.
1965
+ * Swagger: GET /api/core/contents/archive OR /api/core/contents/{contentTypeUniqueId}/archive
1966
+ */
1967
+ async getArchivedContents(params = {}, options = {}) {
1968
+ const { contentTypeUniqueId, ...rest } = params;
1969
+ const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/archive` : "/api/core/contents/archive";
1970
+ try {
1971
+ const res = await this.http.get(url, {
1972
+ params: rest,
1973
+ headers: this.managingHeaders
1974
+ });
1975
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1976
+ } catch {
1977
+ return { hasError: true, result: [] };
1978
+ }
1979
+ }
1980
+ /**
1981
+ * Retrieves drafts.
1982
+ * Swagger: GET /api/core/contents/draft OR /api/core/contents/{contentTypeUniqueId}/draft
1983
+ */
1984
+ async getDrafts(params = {}, options = {}) {
1985
+ const { contentTypeUniqueId, ...rest } = params;
1986
+ const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/draft` : "/api/core/contents/draft";
1987
+ try {
1988
+ const res = await this.http.get(url, {
1989
+ params: rest,
1990
+ headers: this.managingHeaders
1991
+ });
1992
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1993
+ } catch {
1994
+ return { hasError: true, result: [] };
1995
+ }
1996
+ }
1997
+ /**
1998
+ * Creates a draft.
1999
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft
2000
+ */
2001
+ async createDraft(params, options = {}) {
2002
+ const res = await this.http.post(
2003
+ `/api/core/contents/${params.contentTypeUniqueId}/draft`,
2004
+ params.body,
2005
+ {
2006
+ headers: this.managingHeaders
2007
+ }
2008
+ );
2009
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
2010
+ }
2011
+ /**
2012
+ * Gets a specific draft by entityId.
2013
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
2014
+ */
2015
+ async getDraftById(contentTypeUniqueId, entityId, options = {}) {
2016
+ try {
2017
+ const res = await this.http.get(
2018
+ `/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
2019
+ {
2020
+ headers: this.managingHeaders
2021
+ }
2022
+ );
2023
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
2024
+ } catch {
2025
+ return { hasError: true, result: [] };
2026
+ }
2027
+ }
2028
+ /**
2029
+ * Updates a draft.
2030
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
2031
+ */
2032
+ async updateDraft(contentTypeUniqueId, entityId, params, options = {}) {
2033
+ const res = await this.http.post(
2034
+ `/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
2035
+ params.body,
2036
+ {
2037
+ headers: this.managingHeaders
2038
+ }
2039
+ );
2040
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
2041
+ }
2042
+ /**
2043
+ * Undrafts content by entityId.
2044
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/undraft/{entityId}
2045
+ */
2046
+ async undraftContent(contentTypeUniqueId, entityId) {
2047
+ return this.http.post(
2048
+ `/api/core/contents/${contentTypeUniqueId}/undraft/${entityId}`,
2049
+ {},
2050
+ {
2051
+ headers: this.managingHeaders
2052
+ }
2053
+ );
2054
+ }
2055
+ /**
2056
+ * Retrieves comments on content.
2057
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}/comments/{entityId}
2058
+ */
2059
+ async getComments(contentTypeUniqueId, entityId, params = {}) {
2060
+ return this.http.get(
2061
+ `/api/core/contents/${contentTypeUniqueId}/comments/${entityId}`,
2062
+ {
2063
+ params,
2064
+ headers: this.commonHeaders
2065
+ }
2066
+ );
2067
+ }
2068
+ /**
2069
+ * Retrieves list of likes for content.
2070
+ * Swagger: GET /api/core/contents/{contentUniqueId}/like/{entityId}
2071
+ */
2072
+ async getLikes(contentUniqueId, entityId, params = {}) {
2073
+ return this.http.get(
2074
+ `/api/core/contents/${contentUniqueId}/like/${entityId}`,
2075
+ {
2076
+ params,
2077
+ headers: this.commonHeaders
2078
+ }
2079
+ );
2080
+ }
2081
+ /**
2082
+ * Retrieves list of dislikes for content.
2083
+ * Swagger: GET /api/core/contents/{contentUniqueId}/dislike/{entityId}
2084
+ */
2085
+ async getDislikes(contentUniqueId, entityId, params = {}) {
2086
+ return this.http.get(
2087
+ `/api/core/contents/${contentUniqueId}/dislike/${entityId}`,
2088
+ {
2089
+ params,
2090
+ headers: this.commonHeaders
2091
+ }
2092
+ );
2093
+ }
2094
+ /**
2095
+ * Retrieves tag/category tree.
2096
+ * Backward-compatible delegate pointing to `cms.tags.getTagTree('root', params, options)`.
2097
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
2098
+ */
2099
+ async getCategories(params = {}, options = {}) {
2100
+ return this.tags.getTagTree("root", params, options);
2101
+ }
2102
+ /**
2103
+ * Retrieves details of a content type structure.
2104
+ * Swagger: GET /api/core/content-types/{contentTypeUniqueId}
2105
+ */
2106
+ async getContentTypeDetail(contentTypeUniqueId) {
2107
+ try {
2108
+ return await this.http.get(`/api/core/content-types/${contentTypeUniqueId}`, {
2109
+ headers: this.managingHeaders
2110
+ });
2111
+ } catch {
2112
+ return {};
2113
+ }
2114
+ }
2115
+ /**
2116
+ * Performs advanced AI timeline search on content.
2117
+ * Swagger: GET /api/core/contents/ai/timeline-search/enable
2118
+ */
2119
+ async timelineSearch(query) {
2120
+ const params = {};
2121
+ if (query?.advance) {
2122
+ params.advance = JSON.stringify(query.advance);
2123
+ params.newVersion = true;
2124
+ }
2125
+ if (query?.offset) {
2126
+ params.offset = query.offset;
2127
+ }
2128
+ if (query?.size) {
2129
+ params.size = query.size;
2130
+ }
2131
+ return this.http.get(
2132
+ "/api/core/contents/ai/timeline-search/enable",
2133
+ {
2134
+ params,
2135
+ headers: this.commonHeaders
2136
+ }
2137
+ );
2138
+ }
2139
+ // =========================================================================
2140
+ // CONVENIENCE DELEGATES FOR PRODUCTS
2141
+ // =========================================================================
2142
+ /**
2143
+ * Delegate to `cms.products.getProducts(...)`.
2144
+ */
2145
+ async getProducts(params = {}, options = {}) {
2146
+ return this.products.getProducts(params, options);
2147
+ }
2148
+ /**
2149
+ * Delegate to `cms.products.getProductByEntityId(...)`.
2150
+ */
2151
+ async getProductByEntityId(params, options = {}) {
2152
+ return this.products.getProductByEntityId(params, options);
2153
+ }
2154
+ /**
2155
+ * Delegate to `cms.products.addProduct(...)`.
2156
+ */
2157
+ async addProduct(params, options = {}) {
2158
+ return this.products.addProduct(params, options);
2159
+ }
2160
+ /**
2161
+ * Delegate to `cms.products.editProduct(...)`.
2162
+ */
2163
+ async editProduct(entityId, params, options = {}) {
2164
+ return this.products.editProduct(entityId, params, options);
2165
+ }
945
2166
  };
946
2167
  var IumsService = class {
947
2168
  http;
@@ -1021,6 +2242,8 @@ var PodSdk = class {
1021
2242
  notification;
1022
2243
  social;
1023
2244
  cms;
2245
+ product;
2246
+ tags;
1024
2247
  iums;
1025
2248
  constructor(config) {
1026
2249
  const urls = {
@@ -1077,6 +2300,8 @@ var PodSdk = class {
1077
2300
  podspaceUrl: urls.podspace,
1078
2301
  revalidate
1079
2302
  });
2303
+ this.product = this.cms.products;
2304
+ this.tags = this.cms.tags;
1080
2305
  this.iums = new IumsService({
1081
2306
  baseUrl: urls.iums,
1082
2307
  clientId,
@@ -1096,7 +2321,9 @@ function createPodSdk(config) {
1096
2321
  var client_default = PodSdk;
1097
2322
 
1098
2323
  exports.CmsDataFormatter = CmsDataFormatter;
2324
+ exports.CmsProductService = CmsProductService;
1099
2325
  exports.CmsService = CmsService;
2326
+ exports.CmsTagService = CmsTagService;
1100
2327
  exports.CustomPostCrudService = CustomPostCrudService;
1101
2328
  exports.CustomPostService = CustomPostService;
1102
2329
  exports.IumsService = IumsService;