@rezamirzapour/pod-sdk 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1176,6 +1176,398 @@ var CmsProductService = class {
1176
1176
  );
1177
1177
  }
1178
1178
  };
1179
+ var CmsTagService = class {
1180
+ http;
1181
+ clientId;
1182
+ apiToken;
1183
+ revalidate;
1184
+ constructor(options) {
1185
+ this.clientId = options.clientId || "";
1186
+ this.apiToken = options.apiToken || "";
1187
+ this.revalidate = Number(options.revalidate) || 0;
1188
+ this.http = options.http || createNextHttp({
1189
+ baseUrl: options.baseUrl || "https://cms.pod.ir",
1190
+ serviceName: "POD-CMS-TAGS"
1191
+ });
1192
+ }
1193
+ get commonHeaders() {
1194
+ return {
1195
+ "Client-Id": this.clientId,
1196
+ "Content-Type": "application/json"
1197
+ };
1198
+ }
1199
+ get managingHeaders() {
1200
+ return {
1201
+ ...this.commonHeaders,
1202
+ "Access-Token": this.apiToken
1203
+ };
1204
+ }
1205
+ // =========================================================================
1206
+ // 1. TAG CATEGORY MANAGEMENT (Swagger: /api/core/tags/category)
1207
+ // =========================================================================
1208
+ /**
1209
+ * Retrieves list of tag categories.
1210
+ * Swagger: GET /api/core/tags/category
1211
+ */
1212
+ async getTagCategories(params = {}, options = {}) {
1213
+ try {
1214
+ return await this.http.get("/api/core/tags/category", {
1215
+ params,
1216
+ headers: {
1217
+ ...this.managingHeaders,
1218
+ ...options.headers
1219
+ },
1220
+ cache: options.cache,
1221
+ signal: options.signal,
1222
+ next: {
1223
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1224
+ }
1225
+ });
1226
+ } catch {
1227
+ return { hasError: true, result: [] };
1228
+ }
1229
+ }
1230
+ /**
1231
+ * Creates a new tag category.
1232
+ * Swagger: POST /api/core/tags/category
1233
+ */
1234
+ async createTagCategory(params, options = {}) {
1235
+ return this.http.post(
1236
+ "/api/core/tags/category",
1237
+ {},
1238
+ {
1239
+ params: {
1240
+ name: params.name,
1241
+ desc: params.desc
1242
+ },
1243
+ headers: {
1244
+ ...this.managingHeaders,
1245
+ ...options.headers
1246
+ }
1247
+ }
1248
+ );
1249
+ }
1250
+ /**
1251
+ * Retrieves single tag category by ID.
1252
+ * Swagger: GET /api/core/tags/category/{id}
1253
+ */
1254
+ async getTagCategory(id, options = {}) {
1255
+ return this.http.get(`/api/core/tags/category/${id}`, {
1256
+ headers: {
1257
+ ...this.managingHeaders,
1258
+ ...options.headers
1259
+ },
1260
+ cache: options.cache,
1261
+ signal: options.signal,
1262
+ next: {
1263
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1264
+ }
1265
+ });
1266
+ }
1267
+ /**
1268
+ * Updates an existing tag category.
1269
+ * Swagger: PUT /api/core/tags/category/{id}
1270
+ */
1271
+ async updateTagCategory(id, params, options = {}) {
1272
+ return this.http.put(
1273
+ `/api/core/tags/category/${id}`,
1274
+ {},
1275
+ {
1276
+ params: {
1277
+ name: params.name,
1278
+ desc: params.desc,
1279
+ enable: params.enable
1280
+ },
1281
+ headers: {
1282
+ ...this.managingHeaders,
1283
+ ...options.headers
1284
+ }
1285
+ }
1286
+ );
1287
+ }
1288
+ /**
1289
+ * Publishes a tag category.
1290
+ * Swagger: PUT /api/core/tags/category/{id}/publish
1291
+ */
1292
+ async publishTagCategory(id, options = {}) {
1293
+ return this.http.put(
1294
+ `/api/core/tags/category/${id}/publish`,
1295
+ {},
1296
+ {
1297
+ headers: {
1298
+ ...this.managingHeaders,
1299
+ ...options.headers
1300
+ }
1301
+ }
1302
+ );
1303
+ }
1304
+ /**
1305
+ * Unpublishes a tag category.
1306
+ * Swagger: PUT /api/core/tags/category/{id}/unpublish
1307
+ */
1308
+ async unpublishTagCategory(id, options = {}) {
1309
+ return this.http.put(
1310
+ `/api/core/tags/category/${id}/unpublish`,
1311
+ {},
1312
+ {
1313
+ headers: {
1314
+ ...this.managingHeaders,
1315
+ ...options.headers
1316
+ }
1317
+ }
1318
+ );
1319
+ }
1320
+ // =========================================================================
1321
+ // 2. TAG TREE & HIERARCHY (Swagger: /api/core/tags/{categoryId}/tree/...)
1322
+ // =========================================================================
1323
+ /**
1324
+ * Retrieves enabled published tag tree for category (defaults to 'root').
1325
+ * End user call (without requiring Access-Token).
1326
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
1327
+ */
1328
+ async getTagTree(categoryId = "root", params = {}, options = {}) {
1329
+ try {
1330
+ return await this.http.get(
1331
+ `/api/core/tags/${categoryId}/tree/enable`,
1332
+ {
1333
+ params,
1334
+ headers: {
1335
+ ...this.commonHeaders,
1336
+ ...options.headers
1337
+ },
1338
+ cache: options.cache,
1339
+ signal: options.signal,
1340
+ next: {
1341
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1342
+ }
1343
+ }
1344
+ );
1345
+ } catch {
1346
+ return { hasError: true, result: [] };
1347
+ }
1348
+ }
1349
+ /**
1350
+ * Retrieves tag tree for category with management credentials.
1351
+ * Swagger: GET /api/core/tags/{categoryId}/tree/manage
1352
+ */
1353
+ async getManageTagTree(categoryId, params = {}, options = {}) {
1354
+ try {
1355
+ return await this.http.get(
1356
+ `/api/core/tags/${categoryId}/tree/manage`,
1357
+ {
1358
+ params,
1359
+ headers: {
1360
+ ...this.managingHeaders,
1361
+ ...options.headers
1362
+ },
1363
+ cache: options.cache,
1364
+ signal: options.signal,
1365
+ next: {
1366
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1367
+ }
1368
+ }
1369
+ );
1370
+ } catch {
1371
+ return { hasError: true, result: [] };
1372
+ }
1373
+ }
1374
+ /**
1375
+ * Creates a new tag tree node for category.
1376
+ * Swagger: POST /api/core/tags/{categoryId}/tree
1377
+ */
1378
+ async createTagTreeItem(categoryId, params, options = {}) {
1379
+ const { relatedContentIds, ...rest } = params;
1380
+ const queryParams = { ...rest };
1381
+ if (Array.isArray(relatedContentIds)) {
1382
+ queryParams["relatedContentIds[]"] = relatedContentIds;
1383
+ }
1384
+ return this.http.post(
1385
+ `/api/core/tags/${categoryId}/tree`,
1386
+ {},
1387
+ {
1388
+ params: queryParams,
1389
+ headers: {
1390
+ ...this.managingHeaders,
1391
+ ...options.headers
1392
+ }
1393
+ }
1394
+ );
1395
+ }
1396
+ /**
1397
+ * Shows a single enabled tag tree item for end users.
1398
+ * Swagger: GET /api/core/tags/{categoryId}/tree/{id}/enable
1399
+ */
1400
+ async getTagTreeItem(categoryId, id, options = {}) {
1401
+ return this.http.get(`/api/core/tags/${categoryId}/tree/${id}/enable`, {
1402
+ headers: {
1403
+ ...this.commonHeaders,
1404
+ ...options.headers
1405
+ },
1406
+ cache: options.cache,
1407
+ signal: options.signal,
1408
+ next: {
1409
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1410
+ }
1411
+ });
1412
+ }
1413
+ /**
1414
+ * Shows a single tag tree item for manager (with token).
1415
+ * Swagger: GET /api/core/tags/{categoryId}/tree/{id}/manage
1416
+ */
1417
+ async getManageTagTreeItem(categoryId, id, options = {}) {
1418
+ return this.http.get(`/api/core/tags/${categoryId}/tree/${id}/manage`, {
1419
+ headers: {
1420
+ ...this.managingHeaders,
1421
+ ...options.headers
1422
+ },
1423
+ cache: options.cache,
1424
+ signal: options.signal,
1425
+ next: {
1426
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1427
+ }
1428
+ });
1429
+ }
1430
+ /**
1431
+ * Updates an existing tag tree node.
1432
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/{id}
1433
+ */
1434
+ async updateTagTreeItem(categoryId, id, params, options = {}) {
1435
+ const { relatedContentIds, ...rest } = params;
1436
+ const queryParams = { ...rest };
1437
+ if (Array.isArray(relatedContentIds)) {
1438
+ queryParams["relatedContentIds[]"] = relatedContentIds;
1439
+ }
1440
+ return this.http.put(
1441
+ `/api/core/tags/${categoryId}/tree/${id}`,
1442
+ {},
1443
+ {
1444
+ params: queryParams,
1445
+ headers: {
1446
+ ...this.managingHeaders,
1447
+ ...options.headers
1448
+ }
1449
+ }
1450
+ );
1451
+ }
1452
+ /**
1453
+ * Publishes a tag tree item.
1454
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/publish/{id}
1455
+ */
1456
+ async publishTagTreeItem(categoryId, id, options = {}) {
1457
+ return this.http.put(
1458
+ `/api/core/tags/${categoryId}/tree/publish/${id}`,
1459
+ {},
1460
+ {
1461
+ headers: {
1462
+ ...this.managingHeaders,
1463
+ ...options.headers
1464
+ }
1465
+ }
1466
+ );
1467
+ }
1468
+ /**
1469
+ * Unpublishes a tag tree item.
1470
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/unpublish/{id}
1471
+ */
1472
+ async unpublishTagTreeItem(categoryId, id, options = {}) {
1473
+ return this.http.put(
1474
+ `/api/core/tags/${categoryId}/tree/unpublish/${id}`,
1475
+ {},
1476
+ {
1477
+ headers: {
1478
+ ...this.managingHeaders,
1479
+ ...options.headers
1480
+ }
1481
+ }
1482
+ );
1483
+ }
1484
+ /**
1485
+ * Updates the parent of a tag tree item.
1486
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/parent/{id}
1487
+ */
1488
+ async updateTagTreeParent(categoryId, id, parentId, options = {}) {
1489
+ return this.http.put(
1490
+ `/api/core/tags/${categoryId}/tree/parent/${id}`,
1491
+ {},
1492
+ {
1493
+ params: {
1494
+ parentId: parentId !== void 0 ? String(parentId) : ""
1495
+ },
1496
+ headers: {
1497
+ ...this.managingHeaders,
1498
+ ...options.headers
1499
+ }
1500
+ }
1501
+ );
1502
+ }
1503
+ /**
1504
+ * Retrieves tag tree ancestors for end user.
1505
+ * Swagger: GET /api/core/tags/{categoryId}/tree/parent/{id}/enable
1506
+ */
1507
+ async getTagTreeAncestors(categoryId, id, params = {}, options = {}) {
1508
+ try {
1509
+ return await this.http.get(
1510
+ `/api/core/tags/${categoryId}/tree/parent/${id}/enable`,
1511
+ {
1512
+ params,
1513
+ headers: {
1514
+ ...this.commonHeaders,
1515
+ ...options.headers
1516
+ },
1517
+ cache: options.cache,
1518
+ signal: options.signal,
1519
+ next: {
1520
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1521
+ }
1522
+ }
1523
+ );
1524
+ } catch {
1525
+ return { hasError: true, result: [] };
1526
+ }
1527
+ }
1528
+ /**
1529
+ * Retrieves tag tree ancestors for manager (with token).
1530
+ * Swagger: GET /api/core/tags/{categoryId}/tree/parent/{id}/manage
1531
+ */
1532
+ async getManageTagTreeAncestors(categoryId, id, params = {}, options = {}) {
1533
+ try {
1534
+ return await this.http.get(
1535
+ `/api/core/tags/${categoryId}/tree/parent/${id}/manage`,
1536
+ {
1537
+ params,
1538
+ headers: {
1539
+ ...this.managingHeaders,
1540
+ ...options.headers
1541
+ },
1542
+ cache: options.cache,
1543
+ signal: options.signal,
1544
+ next: {
1545
+ revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1546
+ }
1547
+ }
1548
+ );
1549
+ } catch {
1550
+ return { hasError: true, result: [] };
1551
+ }
1552
+ }
1553
+ /**
1554
+ * Updates tag tree code for category.
1555
+ * Swagger: PUT /api/core/tags/{categoryId}/tree/code/{id}
1556
+ */
1557
+ async updateTagTreeCode(categoryId, id, code, options = {}) {
1558
+ return this.http.put(
1559
+ `/api/core/tags/${categoryId}/tree/code/${id}`,
1560
+ {},
1561
+ {
1562
+ params: { code },
1563
+ headers: {
1564
+ ...this.managingHeaders,
1565
+ ...options.headers
1566
+ }
1567
+ }
1568
+ );
1569
+ }
1570
+ };
1179
1571
 
1180
1572
  // src/services/cms/index.ts
1181
1573
  var CmsService = class {
@@ -1189,6 +1581,11 @@ var CmsService = class {
1189
1581
  * Swagger: tag=product
1190
1582
  */
1191
1583
  products;
1584
+ /**
1585
+ * Dedicated CMS Tags & Tag Categories sub-service.
1586
+ * Swagger: tag=tags
1587
+ */
1588
+ tags;
1192
1589
  constructor(options) {
1193
1590
  this.clientId = options.clientId || "";
1194
1591
  this.apiToken = options.apiToken || "";
@@ -1205,6 +1602,12 @@ var CmsService = class {
1205
1602
  apiToken: this.apiToken,
1206
1603
  revalidate: this.revalidate
1207
1604
  });
1605
+ this.tags = new CmsTagService({
1606
+ http: this.http,
1607
+ clientId: this.clientId,
1608
+ apiToken: this.apiToken,
1609
+ revalidate: this.revalidate
1610
+ });
1208
1611
  }
1209
1612
  get commonHeaders() {
1210
1613
  return {
@@ -1686,25 +2089,11 @@ var CmsService = class {
1686
2089
  }
1687
2090
  /**
1688
2091
  * Retrieves tag/category tree.
1689
- * Swagger: GET /api/core/tags/root/tree/enable
2092
+ * Backward-compatible delegate pointing to `cms.tags.getTagTree('root', params, options)`.
2093
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
1690
2094
  */
1691
2095
  async getCategories(params = {}, options = {}) {
1692
- try {
1693
- return await this.http.get("/api/core/tags/root/tree/enable", {
1694
- params,
1695
- headers: {
1696
- ...this.commonHeaders,
1697
- ...options.headers
1698
- },
1699
- cache: options.cache,
1700
- signal: options.signal,
1701
- next: {
1702
- revalidate: options.revalidate !== void 0 ? options.revalidate === false ? 0 : options.revalidate : this.revalidate
1703
- }
1704
- });
1705
- } catch {
1706
- return { hasError: true, result: [] };
1707
- }
2096
+ return this.tags.getTagTree("root", params, options);
1708
2097
  }
1709
2098
  /**
1710
2099
  * Retrieves details of a content type structure.
@@ -1850,6 +2239,7 @@ var PodSdk = class {
1850
2239
  social;
1851
2240
  cms;
1852
2241
  product;
2242
+ tags;
1853
2243
  iums;
1854
2244
  constructor(config) {
1855
2245
  const urls = {
@@ -1907,6 +2297,7 @@ var PodSdk = class {
1907
2297
  revalidate
1908
2298
  });
1909
2299
  this.product = this.cms.products;
2300
+ this.tags = this.cms.tags;
1910
2301
  this.iums = new IumsService({
1911
2302
  baseUrl: urls.iums,
1912
2303
  clientId,
@@ -1925,6 +2316,6 @@ function createPodSdk(config) {
1925
2316
  }
1926
2317
  var client_default = PodSdk;
1927
2318
 
1928
- export { CmsDataFormatter, CmsProductService, CmsService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
2319
+ export { CmsDataFormatter, CmsProductService, CmsService, CmsTagService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
1929
2320
  //# sourceMappingURL=index.mjs.map
1930
2321
  //# sourceMappingURL=index.mjs.map