@rezamirzapour/pod-sdk 1.0.3 → 1.0.5
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/README.md +742 -656
- package/dist/index.d.mts +306 -14
- package/dist/index.d.ts +306 -14
- package/dist/index.js +488 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +485 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +60 -60
package/dist/index.js
CHANGED
|
@@ -597,7 +597,7 @@ var NotificationService = class {
|
|
|
597
597
|
constructor(options) {
|
|
598
598
|
this.apiToken = options.apiToken || "";
|
|
599
599
|
this.http = http.createNextHttp({
|
|
600
|
-
baseUrl: options.baseUrl,
|
|
600
|
+
baseUrl: options.baseUrl || "https://api.pod.ir/srv/notification",
|
|
601
601
|
serviceName: "POD-Notification",
|
|
602
602
|
headers: {
|
|
603
603
|
apiToken: this.apiToken
|
|
@@ -767,7 +767,7 @@ var CmsProductService = class {
|
|
|
767
767
|
this.revalidate = Number(options.revalidate) || 0;
|
|
768
768
|
this.formatter = options.formatter || new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
|
|
769
769
|
this.http = options.http || http.createNextHttp({
|
|
770
|
-
baseUrl: options.baseUrl || "https://
|
|
770
|
+
baseUrl: options.baseUrl || "https://api.pod.ir/srv/cms-server",
|
|
771
771
|
serviceName: "POD-CMS-PRODUCT"
|
|
772
772
|
});
|
|
773
773
|
}
|
|
@@ -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://api.pod.ir/srv/cms-server",
|
|
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
|
-
*
|
|
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
|
-
|
|
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.
|
|
@@ -1777,13 +2166,15 @@ var CmsService = class {
|
|
|
1777
2166
|
};
|
|
1778
2167
|
var IumsService = class {
|
|
1779
2168
|
http;
|
|
2169
|
+
baseUrl;
|
|
1780
2170
|
clientId;
|
|
1781
2171
|
revalidate;
|
|
1782
2172
|
constructor(options) {
|
|
1783
2173
|
this.clientId = options.clientId || "";
|
|
1784
2174
|
this.revalidate = Number(options.revalidate) || 0;
|
|
2175
|
+
this.baseUrl = options.baseUrl || "https://indra.khatam.ac.ir/srv";
|
|
1785
2176
|
this.http = http.createNextHttp({
|
|
1786
|
-
baseUrl:
|
|
2177
|
+
baseUrl: this.baseUrl,
|
|
1787
2178
|
serviceName: "POD-IUMS",
|
|
1788
2179
|
headers: {
|
|
1789
2180
|
"Client-Id": this.clientId
|
|
@@ -1812,7 +2203,8 @@ var IumsService = class {
|
|
|
1812
2203
|
}
|
|
1813
2204
|
async request(serviceMethod, params = [], options) {
|
|
1814
2205
|
const dataPayload = this.generateIumsDataPayload(serviceMethod, params);
|
|
1815
|
-
const
|
|
2206
|
+
const endpoint = this.baseUrl.replace(/\/+$/, "").endsWith("/srv") ? "" : "/srv";
|
|
2207
|
+
const response = await this.http.get(endpoint, {
|
|
1816
2208
|
...options,
|
|
1817
2209
|
params: { data: dataPayload },
|
|
1818
2210
|
next: this.revalidate ? { revalidate: this.revalidate, ...options?.next || {} } : options?.next
|
|
@@ -1844,6 +2236,71 @@ var IumsService = class {
|
|
|
1844
2236
|
}
|
|
1845
2237
|
};
|
|
1846
2238
|
|
|
2239
|
+
// src/constants.ts
|
|
2240
|
+
var DEFAULT_POD_URLS = {
|
|
2241
|
+
accounts: "https://accounts.pod.ir",
|
|
2242
|
+
apiPod: "https://api.pod.ir",
|
|
2243
|
+
apiPodSandbox: "https://api.sandpod.ir",
|
|
2244
|
+
cms: "https://api.pod.ir/srv/cms-server",
|
|
2245
|
+
iums: "https://indra.khatam.ac.ir/srv",
|
|
2246
|
+
notification: "https://api.pod.ir/srv/notification",
|
|
2247
|
+
podreport: "https://reporting.pod.ir",
|
|
2248
|
+
podspace: "https://podspace.pod.ir",
|
|
2249
|
+
podform: "https://podform.pod.ir",
|
|
2250
|
+
sandboxCms: "http://api.sandpod.ir/srv/cms-sandbox",
|
|
2251
|
+
sandboxCmsClient: "https://api.sandpod.ir/srv/cms-sandbox",
|
|
2252
|
+
sandboxPodspace: "http://podspace.sandpod.ir",
|
|
2253
|
+
sandboxStream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2254
|
+
stream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2255
|
+
website: ""
|
|
2256
|
+
};
|
|
2257
|
+
var SANDBOX_POD_URLS = {
|
|
2258
|
+
accounts: "https://accounts.pod.ir",
|
|
2259
|
+
apiPod: "https://api.sandpod.ir",
|
|
2260
|
+
apiPodSandbox: "https://api.sandpod.ir",
|
|
2261
|
+
cms: "https://api.sandpod.ir/srv/cms-sandbox",
|
|
2262
|
+
iums: "https://indra.khatam.ac.ir/srv",
|
|
2263
|
+
notification: "https://api.pod.ir/srv/notification",
|
|
2264
|
+
podreport: "https://reporting.pod.ir",
|
|
2265
|
+
podspace: "http://podspace.sandpod.ir",
|
|
2266
|
+
podform: "https://podform.pod.ir",
|
|
2267
|
+
sandboxCms: "http://api.sandpod.ir/srv/cms-sandbox",
|
|
2268
|
+
sandboxCmsClient: "https://api.sandpod.ir/srv/cms-sandbox",
|
|
2269
|
+
sandboxPodspace: "http://podspace.sandpod.ir",
|
|
2270
|
+
sandboxStream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2271
|
+
stream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2272
|
+
website: ""
|
|
2273
|
+
};
|
|
2274
|
+
function getEnv(key) {
|
|
2275
|
+
if (typeof process !== "undefined" && process?.env && process.env[key]) {
|
|
2276
|
+
const val = process.env[key]?.trim();
|
|
2277
|
+
if (val && val.length > 0) {
|
|
2278
|
+
return val;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
return void 0;
|
|
2282
|
+
}
|
|
2283
|
+
function resolvePodUrls(urls, sandbox = false) {
|
|
2284
|
+
const defaults = sandbox ? SANDBOX_POD_URLS : DEFAULT_POD_URLS;
|
|
2285
|
+
return {
|
|
2286
|
+
accounts: urls?.accounts || getEnv("NEXT_PUBLIC_ACCOUNTS_URL") || defaults.accounts,
|
|
2287
|
+
apiPod: urls?.apiPod || (sandbox ? getEnv("NEXT_PUBLIC_API_POD_SANDBOX_URL") || defaults.apiPod : getEnv("NEXT_PUBLIC_API_POD_URL") || defaults.apiPod),
|
|
2288
|
+
apiPodSandbox: urls?.apiPodSandbox || getEnv("NEXT_PUBLIC_API_POD_SANDBOX_URL") || defaults.apiPodSandbox,
|
|
2289
|
+
cms: urls?.cms || (sandbox ? getEnv("NEXT_PUBLIC_SANDBOX_CMS_CLIENT_URL") || getEnv("NEXT_PUBLIC_SANDBOX_CMS_URL") || defaults.cms : getEnv("NEXT_PUBLIC_CMS_URL") || defaults.cms),
|
|
2290
|
+
iums: urls?.iums || getEnv("NEXT_PUBLIC_IUMS_URL") || defaults.iums,
|
|
2291
|
+
notification: urls?.notification || getEnv("NEXT_PUBLIC_NOTIFICATION_URL") || defaults.notification,
|
|
2292
|
+
podreport: urls?.podreport || getEnv("NEXT_PUBLIC_PODREPORT_URL") || defaults.podreport,
|
|
2293
|
+
podspace: urls?.podspace || (sandbox ? getEnv("NEXT_PUBLIC_SANDBOX_PODSPACE_URL") || defaults.podspace : getEnv("NEXT_PUBLIC_PODSPACE_URL") || defaults.podspace),
|
|
2294
|
+
podform: urls?.podform || getEnv("NEXT_PUBLIC_PODFORM_URL") || defaults.podform,
|
|
2295
|
+
sandboxCms: urls?.sandboxCms || getEnv("NEXT_PUBLIC_SANDBOX_CMS_URL") || defaults.sandboxCms,
|
|
2296
|
+
sandboxCmsClient: urls?.sandboxCmsClient || getEnv("NEXT_PUBLIC_SANDBOX_CMS_CLIENT_URL") || defaults.sandboxCmsClient,
|
|
2297
|
+
sandboxPodspace: urls?.sandboxPodspace || getEnv("NEXT_PUBLIC_SANDBOX_PODSPACE_URL") || defaults.sandboxPodspace,
|
|
2298
|
+
sandboxStream: urls?.sandboxStream || urls?.stream || getEnv("NEXT_PUBLIC_SANDBOX_STREAM_URL") || defaults.sandboxStream,
|
|
2299
|
+
stream: urls?.stream || urls?.sandboxStream || getEnv("NEXT_PUBLIC_SANDBOX_STREAM_URL") || defaults.stream,
|
|
2300
|
+
website: urls?.website || getEnv("NEXT_PUBLIC_WEBSITE_URL") || defaults.website
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
|
|
1847
2304
|
// src/client.ts
|
|
1848
2305
|
var PodSdk = class {
|
|
1849
2306
|
sso;
|
|
@@ -1854,18 +2311,12 @@ var PodSdk = class {
|
|
|
1854
2311
|
social;
|
|
1855
2312
|
cms;
|
|
1856
2313
|
product;
|
|
2314
|
+
tags;
|
|
1857
2315
|
iums;
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
cms: "https://cms.pod.ir",
|
|
1863
|
-
podspace: "https://podspace.pod.ir",
|
|
1864
|
-
podform: "https://podform.pod.ir",
|
|
1865
|
-
notification: "https://notification.pod.ir",
|
|
1866
|
-
iums: "https://iums.pod.ir",
|
|
1867
|
-
...config.urls
|
|
1868
|
-
};
|
|
2316
|
+
urls;
|
|
2317
|
+
constructor(config = {}) {
|
|
2318
|
+
const urls = resolvePodUrls(config.urls, config.sandbox);
|
|
2319
|
+
this.urls = urls;
|
|
1869
2320
|
const apiToken = config.apiToken || "";
|
|
1870
2321
|
const clientId = config.clientId || "";
|
|
1871
2322
|
const clientSecret = config.clientSecret || "";
|
|
@@ -1911,6 +2362,7 @@ var PodSdk = class {
|
|
|
1911
2362
|
revalidate
|
|
1912
2363
|
});
|
|
1913
2364
|
this.product = this.cms.products;
|
|
2365
|
+
this.tags = this.cms.tags;
|
|
1914
2366
|
this.iums = new IumsService({
|
|
1915
2367
|
baseUrl: urls.iums,
|
|
1916
2368
|
clientId,
|
|
@@ -1932,18 +2384,22 @@ var client_default = PodSdk;
|
|
|
1932
2384
|
exports.CmsDataFormatter = CmsDataFormatter;
|
|
1933
2385
|
exports.CmsProductService = CmsProductService;
|
|
1934
2386
|
exports.CmsService = CmsService;
|
|
2387
|
+
exports.CmsTagService = CmsTagService;
|
|
1935
2388
|
exports.CustomPostCrudService = CustomPostCrudService;
|
|
1936
2389
|
exports.CustomPostService = CustomPostService;
|
|
2390
|
+
exports.DEFAULT_POD_URLS = DEFAULT_POD_URLS;
|
|
1937
2391
|
exports.IumsService = IumsService;
|
|
1938
2392
|
exports.NotificationService = NotificationService;
|
|
1939
2393
|
exports.PodFormService = PodFormService;
|
|
1940
2394
|
exports.PodSdk = PodSdk;
|
|
1941
2395
|
exports.PodspaceService = PodspaceService;
|
|
2396
|
+
exports.SANDBOX_POD_URLS = SANDBOX_POD_URLS;
|
|
1942
2397
|
exports.SocialService = SocialService;
|
|
1943
2398
|
exports.SsoService = SsoService;
|
|
1944
2399
|
exports.createPodSdk = createPodSdk;
|
|
1945
2400
|
exports.default = client_default;
|
|
1946
2401
|
exports.encodeBase64 = encodeBase64;
|
|
1947
2402
|
exports.generatePodSignatureHeader = generatePodSignatureHeader;
|
|
2403
|
+
exports.resolvePodUrls = resolvePodUrls;
|
|
1948
2404
|
//# sourceMappingURL=index.js.map
|
|
1949
2405
|
//# sourceMappingURL=index.js.map
|