@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.js CHANGED
@@ -1180,6 +1180,398 @@ var CmsProductService = class {
1180
1180
  );
1181
1181
  }
1182
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
+ }
1269
+ });
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
+ };
1183
1575
 
1184
1576
  // src/services/cms/index.ts
1185
1577
  var CmsService = class {
@@ -1193,6 +1585,11 @@ var CmsService = class {
1193
1585
  * Swagger: tag=product
1194
1586
  */
1195
1587
  products;
1588
+ /**
1589
+ * Dedicated CMS Tags & Tag Categories sub-service.
1590
+ * Swagger: tag=tags
1591
+ */
1592
+ tags;
1196
1593
  constructor(options) {
1197
1594
  this.clientId = options.clientId || "";
1198
1595
  this.apiToken = options.apiToken || "";
@@ -1209,6 +1606,12 @@ var CmsService = class {
1209
1606
  apiToken: this.apiToken,
1210
1607
  revalidate: this.revalidate
1211
1608
  });
1609
+ this.tags = new CmsTagService({
1610
+ http: this.http,
1611
+ clientId: this.clientId,
1612
+ apiToken: this.apiToken,
1613
+ revalidate: this.revalidate
1614
+ });
1212
1615
  }
1213
1616
  get commonHeaders() {
1214
1617
  return {
@@ -1690,25 +2093,11 @@ var CmsService = class {
1690
2093
  }
1691
2094
  /**
1692
2095
  * Retrieves tag/category tree.
1693
- * Swagger: GET /api/core/tags/root/tree/enable
2096
+ * Backward-compatible delegate pointing to `cms.tags.getTagTree('root', params, options)`.
2097
+ * Swagger: GET /api/core/tags/{categoryId}/tree/enable
1694
2098
  */
1695
2099
  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
- }
2100
+ return this.tags.getTagTree("root", params, options);
1712
2101
  }
1713
2102
  /**
1714
2103
  * Retrieves details of a content type structure.
@@ -1854,6 +2243,7 @@ var PodSdk = class {
1854
2243
  social;
1855
2244
  cms;
1856
2245
  product;
2246
+ tags;
1857
2247
  iums;
1858
2248
  constructor(config) {
1859
2249
  const urls = {
@@ -1911,6 +2301,7 @@ var PodSdk = class {
1911
2301
  revalidate
1912
2302
  });
1913
2303
  this.product = this.cms.products;
2304
+ this.tags = this.cms.tags;
1914
2305
  this.iums = new IumsService({
1915
2306
  baseUrl: urls.iums,
1916
2307
  clientId,
@@ -1932,6 +2323,7 @@ var client_default = PodSdk;
1932
2323
  exports.CmsDataFormatter = CmsDataFormatter;
1933
2324
  exports.CmsProductService = CmsProductService;
1934
2325
  exports.CmsService = CmsService;
2326
+ exports.CmsTagService = CmsTagService;
1935
2327
  exports.CustomPostCrudService = CustomPostCrudService;
1936
2328
  exports.CustomPostService = CustomPostService;
1937
2329
  exports.IumsService = IumsService;