@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.mjs
CHANGED
|
@@ -593,7 +593,7 @@ var NotificationService = class {
|
|
|
593
593
|
constructor(options) {
|
|
594
594
|
this.apiToken = options.apiToken || "";
|
|
595
595
|
this.http = createNextHttp({
|
|
596
|
-
baseUrl: options.baseUrl,
|
|
596
|
+
baseUrl: options.baseUrl || "https://api.pod.ir/srv/notification",
|
|
597
597
|
serviceName: "POD-Notification",
|
|
598
598
|
headers: {
|
|
599
599
|
apiToken: this.apiToken
|
|
@@ -763,7 +763,7 @@ var CmsProductService = class {
|
|
|
763
763
|
this.revalidate = Number(options.revalidate) || 0;
|
|
764
764
|
this.formatter = options.formatter || new CmsDataFormatter(options.podspaceUrl || "https://podspace.pod.ir");
|
|
765
765
|
this.http = options.http || createNextHttp({
|
|
766
|
-
baseUrl: options.baseUrl || "https://
|
|
766
|
+
baseUrl: options.baseUrl || "https://api.pod.ir/srv/cms-server",
|
|
767
767
|
serviceName: "POD-CMS-PRODUCT"
|
|
768
768
|
});
|
|
769
769
|
}
|
|
@@ -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://api.pod.ir/srv/cms-server",
|
|
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
|
-
*
|
|
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
|
-
|
|
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.
|
|
@@ -1773,13 +2162,15 @@ var CmsService = class {
|
|
|
1773
2162
|
};
|
|
1774
2163
|
var IumsService = class {
|
|
1775
2164
|
http;
|
|
2165
|
+
baseUrl;
|
|
1776
2166
|
clientId;
|
|
1777
2167
|
revalidate;
|
|
1778
2168
|
constructor(options) {
|
|
1779
2169
|
this.clientId = options.clientId || "";
|
|
1780
2170
|
this.revalidate = Number(options.revalidate) || 0;
|
|
2171
|
+
this.baseUrl = options.baseUrl || "https://indra.khatam.ac.ir/srv";
|
|
1781
2172
|
this.http = createNextHttp({
|
|
1782
|
-
baseUrl:
|
|
2173
|
+
baseUrl: this.baseUrl,
|
|
1783
2174
|
serviceName: "POD-IUMS",
|
|
1784
2175
|
headers: {
|
|
1785
2176
|
"Client-Id": this.clientId
|
|
@@ -1808,7 +2199,8 @@ var IumsService = class {
|
|
|
1808
2199
|
}
|
|
1809
2200
|
async request(serviceMethod, params = [], options) {
|
|
1810
2201
|
const dataPayload = this.generateIumsDataPayload(serviceMethod, params);
|
|
1811
|
-
const
|
|
2202
|
+
const endpoint = this.baseUrl.replace(/\/+$/, "").endsWith("/srv") ? "" : "/srv";
|
|
2203
|
+
const response = await this.http.get(endpoint, {
|
|
1812
2204
|
...options,
|
|
1813
2205
|
params: { data: dataPayload },
|
|
1814
2206
|
next: this.revalidate ? { revalidate: this.revalidate, ...options?.next || {} } : options?.next
|
|
@@ -1840,6 +2232,71 @@ var IumsService = class {
|
|
|
1840
2232
|
}
|
|
1841
2233
|
};
|
|
1842
2234
|
|
|
2235
|
+
// src/constants.ts
|
|
2236
|
+
var DEFAULT_POD_URLS = {
|
|
2237
|
+
accounts: "https://accounts.pod.ir",
|
|
2238
|
+
apiPod: "https://api.pod.ir",
|
|
2239
|
+
apiPodSandbox: "https://api.sandpod.ir",
|
|
2240
|
+
cms: "https://api.pod.ir/srv/cms-server",
|
|
2241
|
+
iums: "https://indra.khatam.ac.ir/srv",
|
|
2242
|
+
notification: "https://api.pod.ir/srv/notification",
|
|
2243
|
+
podreport: "https://reporting.pod.ir",
|
|
2244
|
+
podspace: "https://podspace.pod.ir",
|
|
2245
|
+
podform: "https://podform.pod.ir",
|
|
2246
|
+
sandboxCms: "http://api.sandpod.ir/srv/cms-sandbox",
|
|
2247
|
+
sandboxCmsClient: "https://api.sandpod.ir/srv/cms-sandbox",
|
|
2248
|
+
sandboxPodspace: "http://podspace.sandpod.ir",
|
|
2249
|
+
sandboxStream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2250
|
+
stream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2251
|
+
website: ""
|
|
2252
|
+
};
|
|
2253
|
+
var SANDBOX_POD_URLS = {
|
|
2254
|
+
accounts: "https://accounts.pod.ir",
|
|
2255
|
+
apiPod: "https://api.sandpod.ir",
|
|
2256
|
+
apiPodSandbox: "https://api.sandpod.ir",
|
|
2257
|
+
cms: "https://api.sandpod.ir/srv/cms-sandbox",
|
|
2258
|
+
iums: "https://indra.khatam.ac.ir/srv",
|
|
2259
|
+
notification: "https://api.pod.ir/srv/notification",
|
|
2260
|
+
podreport: "https://reporting.pod.ir",
|
|
2261
|
+
podspace: "http://podspace.sandpod.ir",
|
|
2262
|
+
podform: "https://podform.pod.ir",
|
|
2263
|
+
sandboxCms: "http://api.sandpod.ir/srv/cms-sandbox",
|
|
2264
|
+
sandboxCmsClient: "https://api.sandpod.ir/srv/cms-sandbox",
|
|
2265
|
+
sandboxPodspace: "http://podspace.sandpod.ir",
|
|
2266
|
+
sandboxStream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2267
|
+
stream: "https://sandbox-offline-stream.sandpod.ir",
|
|
2268
|
+
website: ""
|
|
2269
|
+
};
|
|
2270
|
+
function getEnv(key) {
|
|
2271
|
+
if (typeof process !== "undefined" && process?.env && process.env[key]) {
|
|
2272
|
+
const val = process.env[key]?.trim();
|
|
2273
|
+
if (val && val.length > 0) {
|
|
2274
|
+
return val;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
return void 0;
|
|
2278
|
+
}
|
|
2279
|
+
function resolvePodUrls(urls, sandbox = false) {
|
|
2280
|
+
const defaults = sandbox ? SANDBOX_POD_URLS : DEFAULT_POD_URLS;
|
|
2281
|
+
return {
|
|
2282
|
+
accounts: urls?.accounts || getEnv("NEXT_PUBLIC_ACCOUNTS_URL") || defaults.accounts,
|
|
2283
|
+
apiPod: urls?.apiPod || (sandbox ? getEnv("NEXT_PUBLIC_API_POD_SANDBOX_URL") || defaults.apiPod : getEnv("NEXT_PUBLIC_API_POD_URL") || defaults.apiPod),
|
|
2284
|
+
apiPodSandbox: urls?.apiPodSandbox || getEnv("NEXT_PUBLIC_API_POD_SANDBOX_URL") || defaults.apiPodSandbox,
|
|
2285
|
+
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),
|
|
2286
|
+
iums: urls?.iums || getEnv("NEXT_PUBLIC_IUMS_URL") || defaults.iums,
|
|
2287
|
+
notification: urls?.notification || getEnv("NEXT_PUBLIC_NOTIFICATION_URL") || defaults.notification,
|
|
2288
|
+
podreport: urls?.podreport || getEnv("NEXT_PUBLIC_PODREPORT_URL") || defaults.podreport,
|
|
2289
|
+
podspace: urls?.podspace || (sandbox ? getEnv("NEXT_PUBLIC_SANDBOX_PODSPACE_URL") || defaults.podspace : getEnv("NEXT_PUBLIC_PODSPACE_URL") || defaults.podspace),
|
|
2290
|
+
podform: urls?.podform || getEnv("NEXT_PUBLIC_PODFORM_URL") || defaults.podform,
|
|
2291
|
+
sandboxCms: urls?.sandboxCms || getEnv("NEXT_PUBLIC_SANDBOX_CMS_URL") || defaults.sandboxCms,
|
|
2292
|
+
sandboxCmsClient: urls?.sandboxCmsClient || getEnv("NEXT_PUBLIC_SANDBOX_CMS_CLIENT_URL") || defaults.sandboxCmsClient,
|
|
2293
|
+
sandboxPodspace: urls?.sandboxPodspace || getEnv("NEXT_PUBLIC_SANDBOX_PODSPACE_URL") || defaults.sandboxPodspace,
|
|
2294
|
+
sandboxStream: urls?.sandboxStream || urls?.stream || getEnv("NEXT_PUBLIC_SANDBOX_STREAM_URL") || defaults.sandboxStream,
|
|
2295
|
+
stream: urls?.stream || urls?.sandboxStream || getEnv("NEXT_PUBLIC_SANDBOX_STREAM_URL") || defaults.stream,
|
|
2296
|
+
website: urls?.website || getEnv("NEXT_PUBLIC_WEBSITE_URL") || defaults.website
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
|
|
1843
2300
|
// src/client.ts
|
|
1844
2301
|
var PodSdk = class {
|
|
1845
2302
|
sso;
|
|
@@ -1850,18 +2307,12 @@ var PodSdk = class {
|
|
|
1850
2307
|
social;
|
|
1851
2308
|
cms;
|
|
1852
2309
|
product;
|
|
2310
|
+
tags;
|
|
1853
2311
|
iums;
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
cms: "https://cms.pod.ir",
|
|
1859
|
-
podspace: "https://podspace.pod.ir",
|
|
1860
|
-
podform: "https://podform.pod.ir",
|
|
1861
|
-
notification: "https://notification.pod.ir",
|
|
1862
|
-
iums: "https://iums.pod.ir",
|
|
1863
|
-
...config.urls
|
|
1864
|
-
};
|
|
2312
|
+
urls;
|
|
2313
|
+
constructor(config = {}) {
|
|
2314
|
+
const urls = resolvePodUrls(config.urls, config.sandbox);
|
|
2315
|
+
this.urls = urls;
|
|
1865
2316
|
const apiToken = config.apiToken || "";
|
|
1866
2317
|
const clientId = config.clientId || "";
|
|
1867
2318
|
const clientSecret = config.clientSecret || "";
|
|
@@ -1907,6 +2358,7 @@ var PodSdk = class {
|
|
|
1907
2358
|
revalidate
|
|
1908
2359
|
});
|
|
1909
2360
|
this.product = this.cms.products;
|
|
2361
|
+
this.tags = this.cms.tags;
|
|
1910
2362
|
this.iums = new IumsService({
|
|
1911
2363
|
baseUrl: urls.iums,
|
|
1912
2364
|
clientId,
|
|
@@ -1925,6 +2377,6 @@ function createPodSdk(config) {
|
|
|
1925
2377
|
}
|
|
1926
2378
|
var client_default = PodSdk;
|
|
1927
2379
|
|
|
1928
|
-
export { CmsDataFormatter, CmsProductService, CmsService, CustomPostCrudService, CustomPostService, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader };
|
|
2380
|
+
export { CmsDataFormatter, CmsProductService, CmsService, CmsTagService, CustomPostCrudService, CustomPostService, DEFAULT_POD_URLS, IumsService, NotificationService, PodFormService, PodSdk, PodspaceService, SANDBOX_POD_URLS, SocialService, SsoService, createPodSdk, client_default as default, encodeBase64, generatePodSignatureHeader, resolvePodUrls };
|
|
1929
2381
|
//# sourceMappingURL=index.mjs.map
|
|
1930
2382
|
//# sourceMappingURL=index.mjs.map
|