@rezamirzapour/pod-sdk 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,612 @@ 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
+
1184
+ // src/services/cms/index.ts
1185
+ var CmsService = class {
1186
+ http;
1187
+ formatter;
1188
+ clientId;
1189
+ apiToken;
1190
+ revalidate;
1191
+ /**
1192
+ * Dedicated CMS Product sub-service.
1193
+ * Swagger: tag=product
1194
+ */
1195
+ products;
1196
+ constructor(options) {
1197
+ this.clientId = options.clientId || "";
1198
+ this.apiToken = options.apiToken || "";
1199
+ this.revalidate = Number(options.revalidate) || 0;
1200
+ this.formatter = new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
1201
+ this.http = http.createNextHttp({
1202
+ baseUrl: options.baseUrl,
1203
+ serviceName: "POD-CMS"
1204
+ });
1205
+ this.products = new CmsProductService({
1206
+ http: this.http,
1207
+ formatter: this.formatter,
1208
+ clientId: this.clientId,
1209
+ apiToken: this.apiToken,
1210
+ revalidate: this.revalidate
943
1211
  });
944
1212
  }
1213
+ get commonHeaders() {
1214
+ return {
1215
+ "Client-Id": this.clientId,
1216
+ "Content-Type": "application/json"
1217
+ };
1218
+ }
1219
+ get managingHeaders() {
1220
+ return {
1221
+ ...this.commonHeaders,
1222
+ "Access-Token": this.apiToken
1223
+ };
1224
+ }
1225
+ // =========================================================================
1226
+ // CONTENT METHODS (Swagger: tag=content)
1227
+ // =========================================================================
1228
+ /**
1229
+ * Retrieves enabled published content from CMS, formatted with generic metadata type T and optional normalized type P.
1230
+ * Swagger: GET /api/core/contents/enable
1231
+ */
1232
+ async getContent(params = {}, options = {}) {
1233
+ const transferParams = {
1234
+ size: 50,
1235
+ offset: 0,
1236
+ showDetail: true,
1237
+ ...params
1238
+ };
1239
+ try {
1240
+ const res = await this.http.get("/api/core/contents/enable", {
1241
+ params: transferParams,
1242
+ headers: {
1243
+ ...this.commonHeaders,
1244
+ ...options.headers
1245
+ },
1246
+ cache: options.cache,
1247
+ signal: options.signal,
1248
+ next: {
1249
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1250
+ }
1251
+ });
1252
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1253
+ } catch {
1254
+ return { hasError: true, result: [] };
1255
+ }
1256
+ }
1257
+ /**
1258
+ * Retrieves all contents using managing credentials (Access-Token).
1259
+ * Swagger: GET /api/core/contents
1260
+ */
1261
+ async getAllContents(params = {}, options = {}) {
1262
+ const transferParams = {
1263
+ size: 50,
1264
+ offset: 0,
1265
+ showDetail: true,
1266
+ ...params
1267
+ };
1268
+ try {
1269
+ const res = await this.http.get("/api/core/contents", {
1270
+ params: transferParams,
1271
+ headers: {
1272
+ ...this.managingHeaders,
1273
+ ...options.headers
1274
+ },
1275
+ cache: options.cache,
1276
+ signal: options.signal,
1277
+ next: {
1278
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1279
+ }
1280
+ });
1281
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1282
+ } catch {
1283
+ return { hasError: true, result: [] };
1284
+ }
1285
+ }
1286
+ /**
1287
+ * Retrieves current user/client contents.
1288
+ * Swagger: GET /api/core/contents/my
1289
+ */
1290
+ async getMyContents(params = {}, options = {}) {
1291
+ const transferParams = {
1292
+ size: 50,
1293
+ offset: 0,
1294
+ showDetail: true,
1295
+ ...params
1296
+ };
1297
+ try {
1298
+ const res = await this.http.get("/api/core/contents/my", {
1299
+ params: transferParams,
1300
+ headers: {
1301
+ ...this.managingHeaders,
1302
+ ...options.headers
1303
+ },
1304
+ cache: options.cache,
1305
+ signal: options.signal,
1306
+ next: {
1307
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1308
+ }
1309
+ });
1310
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1311
+ } catch {
1312
+ return { hasError: true, result: [] };
1313
+ }
1314
+ }
1315
+ /**
1316
+ * Retrieves contents by ContentType unique identifier.
1317
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}
1318
+ */
1319
+ async getContentsByType(contentTypeUniqueId, params = {}, options = {}) {
1320
+ const transferParams = {
1321
+ size: 50,
1322
+ offset: 0,
1323
+ showDetail: true,
1324
+ ...params
1325
+ };
1326
+ try {
1327
+ const res = await this.http.get(
1328
+ `/api/core/contents/${contentTypeUniqueId}`,
1329
+ {
1330
+ params: transferParams,
1331
+ headers: {
1332
+ ...this.managingHeaders,
1333
+ ...options.headers
1334
+ },
1335
+ cache: options.cache,
1336
+ signal: options.signal,
1337
+ next: {
1338
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1339
+ }
1340
+ }
1341
+ );
1342
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1343
+ } catch {
1344
+ return { hasError: true, result: [] };
1345
+ }
1346
+ }
1347
+ /**
1348
+ * Retrieves unpublished content (enable: false).
1349
+ */
1350
+ async getUnpublishedContent(params = {}, options = {}) {
1351
+ return this.getAllContents({ ...params, enable: false }, options);
1352
+ }
1353
+ /**
1354
+ * Retrieves single content by entityId and optional contentTypeUniqueId.
1355
+ * Swagger: GET /api/core/contents/enable/{entityId} OR /api/core/contents/{contentTypeUniqueId}/enable/{entityId}
1356
+ */
1357
+ async getContentByEntityId(params, options = {}) {
1358
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/enable/${params.entityId}` : `/api/core/contents/enable/${params.entityId}`;
1359
+ try {
1360
+ const res = await this.http.get(url, {
1361
+ headers: {
1362
+ ...this.commonHeaders,
1363
+ ...options.headers
1364
+ },
1365
+ cache: options.cache,
1366
+ signal: options.signal,
1367
+ next: {
1368
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1369
+ }
1370
+ });
1371
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1372
+ } catch {
1373
+ return { hasError: true, result: [] };
1374
+ }
1375
+ }
1376
+ /**
1377
+ * Retrieves content by unique identifier.
1378
+ * Swagger: GET /api/core/contents/{contentUniqueId}/byContentUniqueId/enable
1379
+ */
1380
+ async getContentByUniqueId(contentUniqueId, options = {}) {
1381
+ try {
1382
+ const res = await this.http.get(
1383
+ `/api/core/contents/${contentUniqueId}/byContentUniqueId/enable`,
1384
+ {
1385
+ headers: {
1386
+ ...this.commonHeaders,
1387
+ ...options.headers
1388
+ },
1389
+ cache: options.cache,
1390
+ signal: options.signal,
1391
+ next: {
1392
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1393
+ }
1394
+ }
1395
+ );
1396
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1397
+ } catch {
1398
+ return { hasError: true, result: [] };
1399
+ }
1400
+ }
1401
+ /**
1402
+ * Searches published contents by keyword.
1403
+ * Swagger: GET /api/core/contents/search
1404
+ */
1405
+ async searchContent(params = {}, options = {}) {
1406
+ try {
1407
+ const res = await this.http.get("/api/core/contents/search", {
1408
+ params,
1409
+ headers: {
1410
+ ...this.commonHeaders,
1411
+ ...options.headers
1412
+ },
1413
+ cache: options.cache,
1414
+ signal: options.signal,
1415
+ next: {
1416
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1417
+ }
1418
+ });
1419
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1420
+ } catch {
1421
+ return { hasError: true, result: [] };
1422
+ }
1423
+ }
1424
+ /**
1425
+ * Adds and publishes new content to CMS.
1426
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/add-publish
1427
+ */
1428
+ async addContent(params, options = {}) {
1429
+ const res = await this.http.post(
1430
+ `/api/core/contents/${params.contentTypeUniqueId}/add-publish`,
1431
+ params.body,
1432
+ {
1433
+ headers: this.managingHeaders
1434
+ }
1435
+ );
1436
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1437
+ }
1438
+ /**
1439
+ * Creates a new draft/unpublished content.
1440
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}
1441
+ */
1442
+ async createContent(params, options = {}) {
1443
+ const res = await this.http.post(
1444
+ `/api/core/contents/${params.contentTypeUniqueId}`,
1445
+ params.body,
1446
+ {
1447
+ headers: this.managingHeaders
1448
+ }
1449
+ );
1450
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1451
+ }
1452
+ /**
1453
+ * Edits and publishes existing content by entityId.
1454
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}/edit-publish
1455
+ */
1456
+ async editContent(entityId, params, options = {}) {
1457
+ const res = await this.http.post(
1458
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}/edit-publish`,
1459
+ params.body,
1460
+ {
1461
+ headers: this.managingHeaders
1462
+ }
1463
+ );
1464
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1465
+ }
1466
+ /**
1467
+ * Updates existing content.
1468
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/{entityId}
1469
+ */
1470
+ async updateContent(entityId, params, options = {}) {
1471
+ const res = await this.http.post(
1472
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
1473
+ params.body,
1474
+ {
1475
+ headers: this.managingHeaders
1476
+ }
1477
+ );
1478
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1479
+ }
1480
+ /**
1481
+ * Partially updates existing content.
1482
+ * Swagger: PATCH /api/core/contents/{contentTypeUniqueId}/{entityId}
1483
+ */
1484
+ async patchContent(entityId, params, options = {}) {
1485
+ const res = await this.http.patch(
1486
+ `/api/core/contents/${params.contentTypeUniqueId}/${entityId}`,
1487
+ params.body,
1488
+ {
1489
+ headers: this.managingHeaders
1490
+ }
1491
+ );
1492
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1493
+ }
1494
+ /**
1495
+ * Publishes existing content.
1496
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/publish/{entityId}
1497
+ */
1498
+ async publishContent(contentTypeUniqueId, entityId) {
1499
+ return this.http.post(
1500
+ `/api/core/contents/${contentTypeUniqueId}/publish/${entityId}`,
1501
+ {},
1502
+ {
1503
+ headers: this.managingHeaders
1504
+ }
1505
+ );
1506
+ }
1507
+ /**
1508
+ * Unpublishes existing content.
1509
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/unpublish/{entityId}
1510
+ */
1511
+ async unpublishContent(contentTypeUniqueId, entityId) {
1512
+ return this.http.post(
1513
+ `/api/core/contents/${contentTypeUniqueId}/unpublish/${entityId}`,
1514
+ {},
1515
+ {
1516
+ headers: this.managingHeaders
1517
+ }
1518
+ );
1519
+ }
1520
+ /**
1521
+ * Batch publishes content items.
1522
+ * Swagger: PUT /api/core/contents/{contentTypeUniqueId}/publish OR /api/core/contents/publish
1523
+ */
1524
+ async batchPublish(params) {
1525
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/publish` : "/api/core/contents/publish";
1526
+ return this.http.put(url, { entityIds: params.entityIds }, {
1527
+ headers: this.managingHeaders
1528
+ });
1529
+ }
1530
+ /**
1531
+ * Batch unpublishes content items.
1532
+ * Swagger: PUT /api/core/contents/{contentTypeUniqueId}/unpublish OR /api/core/contents/unpublish
1533
+ */
1534
+ async batchUnpublish(params) {
1535
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unpublish` : "/api/core/contents/unpublish";
1536
+ return this.http.put(url, { entityIds: params.entityIds }, {
1537
+ headers: this.managingHeaders
1538
+ });
1539
+ }
1540
+ /**
1541
+ * Archives content items.
1542
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/archive
1543
+ */
1544
+ async archiveContent(params) {
1545
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/archive` : "/api/core/contents/archive";
1546
+ return this.http.post(url, { entityIds: params.entityIds }, {
1547
+ headers: this.managingHeaders
1548
+ });
1549
+ }
1550
+ /**
1551
+ * Unarchives content items.
1552
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/unarchive
1553
+ */
1554
+ async unarchiveContent(params) {
1555
+ const url = params.contentTypeUniqueId ? `/api/core/contents/${params.contentTypeUniqueId}/unarchive` : "/api/core/contents/unarchive";
1556
+ return this.http.post(url, { entityIds: params.entityIds }, {
1557
+ headers: this.managingHeaders
1558
+ });
1559
+ }
1560
+ /**
1561
+ * Retrieves list of archived contents.
1562
+ * Swagger: GET /api/core/contents/archive OR /api/core/contents/{contentTypeUniqueId}/archive
1563
+ */
1564
+ async getArchivedContents(params = {}, options = {}) {
1565
+ const { contentTypeUniqueId, ...rest } = params;
1566
+ const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/archive` : "/api/core/contents/archive";
1567
+ try {
1568
+ const res = await this.http.get(url, {
1569
+ params: rest,
1570
+ headers: this.managingHeaders
1571
+ });
1572
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1573
+ } catch {
1574
+ return { hasError: true, result: [] };
1575
+ }
1576
+ }
1577
+ /**
1578
+ * Retrieves drafts.
1579
+ * Swagger: GET /api/core/contents/draft OR /api/core/contents/{contentTypeUniqueId}/draft
1580
+ */
1581
+ async getDrafts(params = {}, options = {}) {
1582
+ const { contentTypeUniqueId, ...rest } = params;
1583
+ const url = contentTypeUniqueId ? `/api/core/contents/${contentTypeUniqueId}/draft` : "/api/core/contents/draft";
1584
+ try {
1585
+ const res = await this.http.get(url, {
1586
+ params: rest,
1587
+ headers: this.managingHeaders
1588
+ });
1589
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1590
+ } catch {
1591
+ return { hasError: true, result: [] };
1592
+ }
1593
+ }
1594
+ /**
1595
+ * Creates a draft.
1596
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft
1597
+ */
1598
+ async createDraft(params, options = {}) {
1599
+ const res = await this.http.post(
1600
+ `/api/core/contents/${params.contentTypeUniqueId}/draft`,
1601
+ params.body,
1602
+ {
1603
+ headers: this.managingHeaders
1604
+ }
1605
+ );
1606
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1607
+ }
1608
+ /**
1609
+ * Gets a specific draft by entityId.
1610
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
1611
+ */
1612
+ async getDraftById(contentTypeUniqueId, entityId, options = {}) {
1613
+ try {
1614
+ const res = await this.http.get(
1615
+ `/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
1616
+ {
1617
+ headers: this.managingHeaders
1618
+ }
1619
+ );
1620
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1621
+ } catch {
1622
+ return { hasError: true, result: [] };
1623
+ }
1624
+ }
1625
+ /**
1626
+ * Updates a draft.
1627
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/draft/{entityId}
1628
+ */
1629
+ async updateDraft(contentTypeUniqueId, entityId, params, options = {}) {
1630
+ const res = await this.http.post(
1631
+ `/api/core/contents/${contentTypeUniqueId}/draft/${entityId}`,
1632
+ params.body,
1633
+ {
1634
+ headers: this.managingHeaders
1635
+ }
1636
+ );
1637
+ return this.formatter.formatGetContentResponse(res, options.normalizer);
1638
+ }
1639
+ /**
1640
+ * Undrafts content by entityId.
1641
+ * Swagger: POST /api/core/contents/{contentTypeUniqueId}/undraft/{entityId}
1642
+ */
1643
+ async undraftContent(contentTypeUniqueId, entityId) {
1644
+ return this.http.post(
1645
+ `/api/core/contents/${contentTypeUniqueId}/undraft/${entityId}`,
1646
+ {},
1647
+ {
1648
+ headers: this.managingHeaders
1649
+ }
1650
+ );
1651
+ }
1652
+ /**
1653
+ * Retrieves comments on content.
1654
+ * Swagger: GET /api/core/contents/{contentTypeUniqueId}/comments/{entityId}
1655
+ */
1656
+ async getComments(contentTypeUniqueId, entityId, params = {}) {
1657
+ return this.http.get(
1658
+ `/api/core/contents/${contentTypeUniqueId}/comments/${entityId}`,
1659
+ {
1660
+ params,
1661
+ headers: this.commonHeaders
1662
+ }
1663
+ );
1664
+ }
1665
+ /**
1666
+ * Retrieves list of likes for content.
1667
+ * Swagger: GET /api/core/contents/{contentUniqueId}/like/{entityId}
1668
+ */
1669
+ async getLikes(contentUniqueId, entityId, params = {}) {
1670
+ return this.http.get(
1671
+ `/api/core/contents/${contentUniqueId}/like/${entityId}`,
1672
+ {
1673
+ params,
1674
+ headers: this.commonHeaders
1675
+ }
1676
+ );
1677
+ }
1678
+ /**
1679
+ * Retrieves list of dislikes for content.
1680
+ * Swagger: GET /api/core/contents/{contentUniqueId}/dislike/{entityId}
1681
+ */
1682
+ async getDislikes(contentUniqueId, entityId, params = {}) {
1683
+ return this.http.get(
1684
+ `/api/core/contents/${contentUniqueId}/dislike/${entityId}`,
1685
+ {
1686
+ params,
1687
+ headers: this.commonHeaders
1688
+ }
1689
+ );
1690
+ }
1691
+ /**
1692
+ * Retrieves tag/category tree.
1693
+ * Swagger: GET /api/core/tags/root/tree/enable
1694
+ */
1695
+ async getCategories(params = {}, options = {}) {
1696
+ try {
1697
+ return await this.http.get("/api/core/tags/root/tree/enable", {
1698
+ params,
1699
+ headers: {
1700
+ ...this.commonHeaders,
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
+ } catch {
1710
+ return { hasError: true, result: [] };
1711
+ }
1712
+ }
1713
+ /**
1714
+ * Retrieves details of a content type structure.
1715
+ * Swagger: GET /api/core/content-types/{contentTypeUniqueId}
1716
+ */
1717
+ async getContentTypeDetail(contentTypeUniqueId) {
1718
+ try {
1719
+ return await this.http.get(`/api/core/content-types/${contentTypeUniqueId}`, {
1720
+ headers: this.managingHeaders
1721
+ });
1722
+ } catch {
1723
+ return {};
1724
+ }
1725
+ }
1726
+ /**
1727
+ * Performs advanced AI timeline search on content.
1728
+ * Swagger: GET /api/core/contents/ai/timeline-search/enable
1729
+ */
1730
+ async timelineSearch(query) {
1731
+ const params = {};
1732
+ if (query?.advance) {
1733
+ params.advance = JSON.stringify(query.advance);
1734
+ params.newVersion = true;
1735
+ }
1736
+ if (query?.offset) {
1737
+ params.offset = query.offset;
1738
+ }
1739
+ if (query?.size) {
1740
+ params.size = query.size;
1741
+ }
1742
+ return this.http.get(
1743
+ "/api/core/contents/ai/timeline-search/enable",
1744
+ {
1745
+ params,
1746
+ headers: this.commonHeaders
1747
+ }
1748
+ );
1749
+ }
1750
+ // =========================================================================
1751
+ // CONVENIENCE DELEGATES FOR PRODUCTS
1752
+ // =========================================================================
1753
+ /**
1754
+ * Delegate to `cms.products.getProducts(...)`.
1755
+ */
1756
+ async getProducts(params = {}, options = {}) {
1757
+ return this.products.getProducts(params, options);
1758
+ }
1759
+ /**
1760
+ * Delegate to `cms.products.getProductByEntityId(...)`.
1761
+ */
1762
+ async getProductByEntityId(params, options = {}) {
1763
+ return this.products.getProductByEntityId(params, options);
1764
+ }
1765
+ /**
1766
+ * Delegate to `cms.products.addProduct(...)`.
1767
+ */
1768
+ async addProduct(params, options = {}) {
1769
+ return this.products.addProduct(params, options);
1770
+ }
1771
+ /**
1772
+ * Delegate to `cms.products.editProduct(...)`.
1773
+ */
1774
+ async editProduct(entityId, params, options = {}) {
1775
+ return this.products.editProduct(entityId, params, options);
1776
+ }
945
1777
  };
946
1778
  var IumsService = class {
947
1779
  http;
@@ -1021,6 +1853,7 @@ var PodSdk = class {
1021
1853
  notification;
1022
1854
  social;
1023
1855
  cms;
1856
+ product;
1024
1857
  iums;
1025
1858
  constructor(config) {
1026
1859
  const urls = {
@@ -1077,6 +1910,7 @@ var PodSdk = class {
1077
1910
  podspaceUrl: urls.podspace,
1078
1911
  revalidate
1079
1912
  });
1913
+ this.product = this.cms.products;
1080
1914
  this.iums = new IumsService({
1081
1915
  baseUrl: urls.iums,
1082
1916
  clientId,
@@ -1096,6 +1930,7 @@ function createPodSdk(config) {
1096
1930
  var client_default = PodSdk;
1097
1931
 
1098
1932
  exports.CmsDataFormatter = CmsDataFormatter;
1933
+ exports.CmsProductService = CmsProductService;
1099
1934
  exports.CmsService = CmsService;
1100
1935
  exports.CustomPostCrudService = CustomPostCrudService;
1101
1936
  exports.CustomPostService = CustomPostService;