@pelican.ts/sdk 0.2.3 → 0.2.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
@@ -879,7 +879,7 @@ var Client = class {
879
879
  };
880
880
 
881
881
  // src/api/application/users.ts
882
- import z6 from "zod";
882
+ import z7 from "zod";
883
883
 
884
884
  // src/utils/transform.ts
885
885
  var ArrayQueryParams = (p) => {
@@ -896,14 +896,574 @@ var SortParam = (key, p) => {
896
896
  return `${p === "desc" ? "-" : ""}${key}`;
897
897
  };
898
898
 
899
+ // src/api/common/types/enums.ts
900
+ import z6 from "zod";
901
+ var languagesSchema = z6.enum([
902
+ "af",
903
+ "ak",
904
+ "am",
905
+ "ar",
906
+ "as",
907
+ "az",
908
+ "be",
909
+ "bg",
910
+ "bm",
911
+ "bn",
912
+ "bo",
913
+ "br",
914
+ "bs",
915
+ "ca",
916
+ "ce",
917
+ "cs",
918
+ "cv",
919
+ "cy",
920
+ "da",
921
+ "de",
922
+ "dz",
923
+ "ee",
924
+ "el",
925
+ "en",
926
+ "eo",
927
+ "es",
928
+ "et",
929
+ "eu",
930
+ "fa",
931
+ "ff",
932
+ "fi",
933
+ "fo",
934
+ "fr",
935
+ "fy",
936
+ "ga",
937
+ "gd",
938
+ "gl",
939
+ "gu",
940
+ "gv",
941
+ "ha",
942
+ "he",
943
+ "hi",
944
+ "hr",
945
+ "hu",
946
+ "hy",
947
+ "ia",
948
+ "id",
949
+ "ig",
950
+ "ii",
951
+ "is",
952
+ "it",
953
+ "ja",
954
+ "jv",
955
+ "ka",
956
+ "ki",
957
+ "kk",
958
+ "kl",
959
+ "km",
960
+ "kn",
961
+ "ko",
962
+ "ks",
963
+ "ku",
964
+ "kw",
965
+ "ky",
966
+ "lb",
967
+ "lg",
968
+ "ln",
969
+ "lo",
970
+ "lt",
971
+ "lu",
972
+ "lv",
973
+ "mg",
974
+ "mi",
975
+ "mk",
976
+ "ml",
977
+ "mn",
978
+ "mr",
979
+ "ms",
980
+ "mt",
981
+ "my",
982
+ "nb",
983
+ "nd",
984
+ "ne",
985
+ "nl",
986
+ "nn",
987
+ "no",
988
+ "om",
989
+ "or",
990
+ "os",
991
+ "pa",
992
+ "pl",
993
+ "ps",
994
+ "pt",
995
+ "qu",
996
+ "rm",
997
+ "rn",
998
+ "ro",
999
+ "ru",
1000
+ "rw",
1001
+ "sa",
1002
+ "sc",
1003
+ "sd",
1004
+ "se",
1005
+ "sg",
1006
+ "si",
1007
+ "sk",
1008
+ "sl",
1009
+ "sn",
1010
+ "so",
1011
+ "sq",
1012
+ "sr",
1013
+ "su",
1014
+ "sv",
1015
+ "sw",
1016
+ "ta",
1017
+ "te",
1018
+ "tg",
1019
+ "th",
1020
+ "ti",
1021
+ "tk",
1022
+ "to",
1023
+ "tr",
1024
+ "tt",
1025
+ "ug",
1026
+ "uk",
1027
+ "ur",
1028
+ "uz",
1029
+ "vi",
1030
+ "wo",
1031
+ "xh",
1032
+ "yi",
1033
+ "yo",
1034
+ "zh",
1035
+ "zu"
1036
+ ]);
1037
+ var timezonesSchema = z6.enum([
1038
+ "Africa/Abidjan",
1039
+ "Africa/Accra",
1040
+ "Africa/Addis_Ababa",
1041
+ "Africa/Algiers",
1042
+ "Africa/Asmara",
1043
+ "Africa/Bamako",
1044
+ "Africa/Bangui",
1045
+ "Africa/Banjul",
1046
+ "Africa/Bissau",
1047
+ "Africa/Blantyre",
1048
+ "Africa/Brazzaville",
1049
+ "Africa/Bujumbura",
1050
+ "Africa/Cairo",
1051
+ "Africa/Casablanca",
1052
+ "Africa/Ceuta",
1053
+ "Africa/Conakry",
1054
+ "Africa/Dakar",
1055
+ "Africa/Dar_es_Salaam",
1056
+ "Africa/Djibouti",
1057
+ "Africa/Douala",
1058
+ "Africa/El_Aaiun",
1059
+ "Africa/Freetown",
1060
+ "Africa/Gaborone",
1061
+ "Africa/Harare",
1062
+ "Africa/Johannesburg",
1063
+ "Africa/Juba",
1064
+ "Africa/Kampala",
1065
+ "Africa/Khartoum",
1066
+ "Africa/Kigali",
1067
+ "Africa/Kinshasa",
1068
+ "Africa/Lagos",
1069
+ "Africa/Libreville",
1070
+ "Africa/Lome",
1071
+ "Africa/Luanda",
1072
+ "Africa/Lubumbashi",
1073
+ "Africa/Lusaka",
1074
+ "Africa/Malabo",
1075
+ "Africa/Maputo",
1076
+ "Africa/Maseru",
1077
+ "Africa/Mbabane",
1078
+ "Africa/Mogadishu",
1079
+ "Africa/Monrovia",
1080
+ "Africa/Nairobi",
1081
+ "Africa/Ndjamena",
1082
+ "Africa/Niamey",
1083
+ "Africa/Nouakchott",
1084
+ "Africa/Ouagadougou",
1085
+ "Africa/Porto-Novo",
1086
+ "Africa/Sao_Tome",
1087
+ "Africa/Tripoli",
1088
+ "Africa/Tunis",
1089
+ "Africa/Windhoek",
1090
+ "America/Adak",
1091
+ "America/Anchorage",
1092
+ "America/Anguilla",
1093
+ "America/Antigua",
1094
+ "America/Araguaina",
1095
+ "America/Argentina/Buenos_Aires",
1096
+ "America/Argentina/Catamarca",
1097
+ "America/Argentina/Cordoba",
1098
+ "America/Argentina/Jujuy",
1099
+ "America/Argentina/La_Rioja",
1100
+ "America/Argentina/Mendoza",
1101
+ "America/Argentina/Rio_Gallegos",
1102
+ "America/Argentina/Salta",
1103
+ "America/Argentina/San_Juan",
1104
+ "America/Argentina/San_Luis",
1105
+ "America/Argentina/Tucuman",
1106
+ "America/Argentina/Ushuaia",
1107
+ "America/Aruba",
1108
+ "America/Asuncion",
1109
+ "America/Atikokan",
1110
+ "America/Bahia",
1111
+ "America/Bahia_Banderas",
1112
+ "America/Barbados",
1113
+ "America/Belem",
1114
+ "America/Belize",
1115
+ "America/Blanc-Sablon",
1116
+ "America/Boa_Vista",
1117
+ "America/Bogota",
1118
+ "America/Boise",
1119
+ "America/Cambridge_Bay",
1120
+ "America/Campo_Grande",
1121
+ "America/Cancun",
1122
+ "America/Caracas",
1123
+ "America/Cayenne",
1124
+ "America/Cayman",
1125
+ "America/Chicago",
1126
+ "America/Chihuahua",
1127
+ "America/Ciudad_Juarez",
1128
+ "America/Costa_Rica",
1129
+ "America/Coyhaique",
1130
+ "America/Creston",
1131
+ "America/Cuiaba",
1132
+ "America/Curacao",
1133
+ "America/Danmarkshavn",
1134
+ "America/Dawson",
1135
+ "America/Dawson_Creek",
1136
+ "America/Denver",
1137
+ "America/Detroit",
1138
+ "America/Dominica",
1139
+ "America/Edmonton",
1140
+ "America/Eirunepe",
1141
+ "America/El_Salvador",
1142
+ "America/Fort_Nelson",
1143
+ "America/Fortaleza",
1144
+ "America/Glace_Bay",
1145
+ "America/Goose_Bay",
1146
+ "America/Grand_Turk",
1147
+ "America/Grenada",
1148
+ "America/Guadeloupe",
1149
+ "America/Guatemala",
1150
+ "America/Guayaquil",
1151
+ "America/Guyana",
1152
+ "America/Halifax",
1153
+ "America/Havana",
1154
+ "America/Hermosillo",
1155
+ "America/Indiana/Indianapolis",
1156
+ "America/Indiana/Knox",
1157
+ "America/Indiana/Marengo",
1158
+ "America/Indiana/Petersburg",
1159
+ "America/Indiana/Tell_City",
1160
+ "America/Indiana/Vevay",
1161
+ "America/Indiana/Vincennes",
1162
+ "America/Indiana/Winamac",
1163
+ "America/Inuvik",
1164
+ "America/Iqaluit",
1165
+ "America/Jamaica",
1166
+ "America/Juneau",
1167
+ "America/Kentucky/Louisville",
1168
+ "America/Kentucky/Monticello",
1169
+ "America/Kralendijk",
1170
+ "America/La_Paz",
1171
+ "America/Lima",
1172
+ "America/Los_Angeles",
1173
+ "America/Lower_Princes",
1174
+ "America/Maceio",
1175
+ "America/Managua",
1176
+ "America/Manaus",
1177
+ "America/Marigot",
1178
+ "America/Martinique",
1179
+ "America/Matamoros",
1180
+ "America/Mazatlan",
1181
+ "America/Menominee",
1182
+ "America/Merida",
1183
+ "America/Metlakatla",
1184
+ "America/Mexico_City",
1185
+ "America/Miquelon",
1186
+ "America/Moncton",
1187
+ "America/Monterrey",
1188
+ "America/Montevideo",
1189
+ "America/Montserrat",
1190
+ "America/Nassau",
1191
+ "America/New_York",
1192
+ "America/Nome",
1193
+ "America/Noronha",
1194
+ "America/North_Dakota/Beulah",
1195
+ "America/North_Dakota/Center",
1196
+ "America/North_Dakota/New_Salem",
1197
+ "America/Nuuk",
1198
+ "America/Ojinaga",
1199
+ "America/Panama",
1200
+ "America/Paramaribo",
1201
+ "America/Phoenix",
1202
+ "America/Port-au-Prince",
1203
+ "America/Port_of_Spain",
1204
+ "America/Porto_Velho",
1205
+ "America/Puerto_Rico",
1206
+ "America/Punta_Arenas",
1207
+ "America/Rankin_Inlet",
1208
+ "America/Recife",
1209
+ "America/Regina",
1210
+ "America/Resolute",
1211
+ "America/Rio_Branco",
1212
+ "America/Santarem",
1213
+ "America/Santiago",
1214
+ "America/Santo_Domingo",
1215
+ "America/Sao_Paulo",
1216
+ "America/Scoresbysund",
1217
+ "America/Sitka",
1218
+ "America/St_Barthelemy",
1219
+ "America/St_Johns",
1220
+ "America/St_Kitts",
1221
+ "America/St_Lucia",
1222
+ "America/St_Thomas",
1223
+ "America/St_Vincent",
1224
+ "America/Swift_Current",
1225
+ "America/Tegucigalpa",
1226
+ "America/Thule",
1227
+ "America/Tijuana",
1228
+ "America/Toronto",
1229
+ "America/Tortola",
1230
+ "America/Vancouver",
1231
+ "America/Whitehorse",
1232
+ "America/Winnipeg",
1233
+ "America/Yakutat",
1234
+ "Antarctica/Casey",
1235
+ "Antarctica/Davis",
1236
+ "Antarctica/DumontDUrville",
1237
+ "Antarctica/Macquarie",
1238
+ "Antarctica/Mawson",
1239
+ "Antarctica/McMurdo",
1240
+ "Antarctica/Palmer",
1241
+ "Antarctica/Rothera",
1242
+ "Antarctica/Syowa",
1243
+ "Antarctica/Troll",
1244
+ "Antarctica/Vostok",
1245
+ "Arctic/Longyearbyen",
1246
+ "Asia/Aden",
1247
+ "Asia/Almaty",
1248
+ "Asia/Amman",
1249
+ "Asia/Anadyr",
1250
+ "Asia/Aqtau",
1251
+ "Asia/Aqtobe",
1252
+ "Asia/Ashgabat",
1253
+ "Asia/Atyrau",
1254
+ "Asia/Baghdad",
1255
+ "Asia/Bahrain",
1256
+ "Asia/Baku",
1257
+ "Asia/Bangkok",
1258
+ "Asia/Barnaul",
1259
+ "Asia/Beirut",
1260
+ "Asia/Bishkek",
1261
+ "Asia/Brunei",
1262
+ "Asia/Chita",
1263
+ "Asia/Colombo",
1264
+ "Asia/Damascus",
1265
+ "Asia/Dhaka",
1266
+ "Asia/Dili",
1267
+ "Asia/Dubai",
1268
+ "Asia/Dushanbe",
1269
+ "Asia/Famagusta",
1270
+ "Asia/Gaza",
1271
+ "Asia/Hebron",
1272
+ "Asia/Ho_Chi_Minh",
1273
+ "Asia/Hong_Kong",
1274
+ "Asia/Hovd",
1275
+ "Asia/Irkutsk",
1276
+ "Asia/Jakarta",
1277
+ "Asia/Jayapura",
1278
+ "Asia/Jerusalem",
1279
+ "Asia/Kabul",
1280
+ "Asia/Kamchatka",
1281
+ "Asia/Karachi",
1282
+ "Asia/Kathmandu",
1283
+ "Asia/Khandyga",
1284
+ "Asia/Kolkata",
1285
+ "Asia/Krasnoyarsk",
1286
+ "Asia/Kuala_Lumpur",
1287
+ "Asia/Kuching",
1288
+ "Asia/Kuwait",
1289
+ "Asia/Macau",
1290
+ "Asia/Magadan",
1291
+ "Asia/Makassar",
1292
+ "Asia/Manila",
1293
+ "Asia/Muscat",
1294
+ "Asia/Nicosia",
1295
+ "Asia/Novokuznetsk",
1296
+ "Asia/Novosibirsk",
1297
+ "Asia/Omsk",
1298
+ "Asia/Oral",
1299
+ "Asia/Phnom_Penh",
1300
+ "Asia/Pontianak",
1301
+ "Asia/Pyongyang",
1302
+ "Asia/Qatar",
1303
+ "Asia/Qostanay",
1304
+ "Asia/Qyzylorda",
1305
+ "Asia/Riyadh",
1306
+ "Asia/Sakhalin",
1307
+ "Asia/Samarkand",
1308
+ "Asia/Seoul",
1309
+ "Asia/Shanghai",
1310
+ "Asia/Singapore",
1311
+ "Asia/Srednekolymsk",
1312
+ "Asia/Taipei",
1313
+ "Asia/Tashkent",
1314
+ "Asia/Tbilisi",
1315
+ "Asia/Tehran",
1316
+ "Asia/Thimphu",
1317
+ "Asia/Tokyo",
1318
+ "Asia/Tomsk",
1319
+ "Asia/Ulaanbaatar",
1320
+ "Asia/Urumqi",
1321
+ "Asia/Ust-Nera",
1322
+ "Asia/Vientiane",
1323
+ "Asia/Vladivostok",
1324
+ "Asia/Yakutsk",
1325
+ "Asia/Yangon",
1326
+ "Asia/Yekaterinburg",
1327
+ "Asia/Yerevan",
1328
+ "Atlantic/Azores",
1329
+ "Atlantic/Bermuda",
1330
+ "Atlantic/Canary",
1331
+ "Atlantic/Cape_Verde",
1332
+ "Atlantic/Faroe",
1333
+ "Atlantic/Madeira",
1334
+ "Atlantic/Reykjavik",
1335
+ "Atlantic/South_Georgia",
1336
+ "Atlantic/St_Helena",
1337
+ "Atlantic/Stanley",
1338
+ "Australia/Adelaide",
1339
+ "Australia/Brisbane",
1340
+ "Australia/Broken_Hill",
1341
+ "Australia/Darwin",
1342
+ "Australia/Eucla",
1343
+ "Australia/Hobart",
1344
+ "Australia/Lindeman",
1345
+ "Australia/Lord_Howe",
1346
+ "Australia/Melbourne",
1347
+ "Australia/Perth",
1348
+ "Australia/Sydney",
1349
+ "Europe/Amsterdam",
1350
+ "Europe/Andorra",
1351
+ "Europe/Astrakhan",
1352
+ "Europe/Athens",
1353
+ "Europe/Belgrade",
1354
+ "Europe/Berlin",
1355
+ "Europe/Bratislava",
1356
+ "Europe/Brussels",
1357
+ "Europe/Bucharest",
1358
+ "Europe/Budapest",
1359
+ "Europe/Busingen",
1360
+ "Europe/Chisinau",
1361
+ "Europe/Copenhagen",
1362
+ "Europe/Dublin",
1363
+ "Europe/Gibraltar",
1364
+ "Europe/Guernsey",
1365
+ "Europe/Helsinki",
1366
+ "Europe/Isle_of_Man",
1367
+ "Europe/Istanbul",
1368
+ "Europe/Jersey",
1369
+ "Europe/Kaliningrad",
1370
+ "Europe/Kirov",
1371
+ "Europe/Kyiv",
1372
+ "Europe/Lisbon",
1373
+ "Europe/Ljubljana",
1374
+ "Europe/London",
1375
+ "Europe/Luxembourg",
1376
+ "Europe/Madrid",
1377
+ "Europe/Malta",
1378
+ "Europe/Mariehamn",
1379
+ "Europe/Minsk",
1380
+ "Europe/Monaco",
1381
+ "Europe/Moscow",
1382
+ "Europe/Oslo",
1383
+ "Europe/Paris",
1384
+ "Europe/Podgorica",
1385
+ "Europe/Prague",
1386
+ "Europe/Riga",
1387
+ "Europe/Rome",
1388
+ "Europe/Samara",
1389
+ "Europe/San_Marino",
1390
+ "Europe/Sarajevo",
1391
+ "Europe/Saratov",
1392
+ "Europe/Simferopol",
1393
+ "Europe/Skopje",
1394
+ "Europe/Sofia",
1395
+ "Europe/Stockholm",
1396
+ "Europe/Tallinn",
1397
+ "Europe/Tirane",
1398
+ "Europe/Ulyanovsk",
1399
+ "Europe/Vaduz",
1400
+ "Europe/Vatican",
1401
+ "Europe/Vienna",
1402
+ "Europe/Vilnius",
1403
+ "Europe/Volgograd",
1404
+ "Europe/Warsaw",
1405
+ "Europe/Zagreb",
1406
+ "Europe/Zurich",
1407
+ "Indian/Antananarivo",
1408
+ "Indian/Chagos",
1409
+ "Indian/Christmas",
1410
+ "Indian/Cocos",
1411
+ "Indian/Comoro",
1412
+ "Indian/Kerguelen",
1413
+ "Indian/Mahe",
1414
+ "Indian/Maldives",
1415
+ "Indian/Mauritius",
1416
+ "Indian/Mayotte",
1417
+ "Indian/Reunion",
1418
+ "Pacific/Apia",
1419
+ "Pacific/Auckland",
1420
+ "Pacific/Bougainville",
1421
+ "Pacific/Chatham",
1422
+ "Pacific/Chuuk",
1423
+ "Pacific/Easter",
1424
+ "Pacific/Efate",
1425
+ "Pacific/Fakaofo",
1426
+ "Pacific/Fiji",
1427
+ "Pacific/Funafuti",
1428
+ "Pacific/Galapagos",
1429
+ "Pacific/Gambier",
1430
+ "Pacific/Guadalcanal",
1431
+ "Pacific/Guam",
1432
+ "Pacific/Honolulu",
1433
+ "Pacific/Kanton",
1434
+ "Pacific/Kiritimati",
1435
+ "Pacific/Kosrae",
1436
+ "Pacific/Kwajalein",
1437
+ "Pacific/Majuro",
1438
+ "Pacific/Marquesas",
1439
+ "Pacific/Midway",
1440
+ "Pacific/Nauru",
1441
+ "Pacific/Niue",
1442
+ "Pacific/Norfolk",
1443
+ "Pacific/Noumea",
1444
+ "Pacific/Pago_Pago",
1445
+ "Pacific/Palau",
1446
+ "Pacific/Pitcairn",
1447
+ "Pacific/Pohnpei",
1448
+ "Pacific/Port_Moresby",
1449
+ "Pacific/Rarotonga",
1450
+ "Pacific/Saipan",
1451
+ "Pacific/Tahiti",
1452
+ "Pacific/Tarawa",
1453
+ "Pacific/Tongatapu",
1454
+ "Pacific/Wake",
1455
+ "Pacific/Wallis",
1456
+ "UTC"
1457
+ ]);
1458
+
899
1459
  // src/api/application/users.ts
900
1460
  var Users = class {
901
1461
  r;
902
1462
  constructor(requester) {
903
1463
  this.r = requester;
904
1464
  }
905
- list = async ({ ...opts }, page = 1) => {
906
- z6.number().positive().parse(page);
1465
+ list = async (opts, page = 1) => {
1466
+ z7.number().positive().parse(page);
907
1467
  const { data } = await this.r.get("/users", {
908
1468
  params: {
909
1469
  include: opts.include?.join(","),
@@ -915,43 +1475,409 @@ var Users = class {
915
1475
  return data.data.map((d) => d.attributes);
916
1476
  };
917
1477
  info = async (id, { include }) => {
918
- z6.number().positive().parse(id);
1478
+ z7.number().positive().parse(id);
919
1479
  const { data } = await this.r.get(`/users/${id}`, {
920
1480
  params: { include: include?.join(",") }
921
1481
  });
922
1482
  return data.attributes;
923
1483
  };
924
1484
  infoByExternal = async (external_id, { include }) => {
925
- const { data } = await this.r.get(`/users/external/${external_id}`);
1485
+ const { data } = await this.r.get(`/users/external/${external_id}`, {
1486
+ params: { include: include?.join(",") }
1487
+ });
926
1488
  return data.attributes;
927
1489
  };
928
1490
  create = async (user) => {
1491
+ user = CreateSchema.parse(user);
929
1492
  const { data } = await this.r.post("/users", user);
930
1493
  return data.attributes;
931
1494
  };
932
1495
  update = async (id, user) => {
933
- z6.number().positive().parse(id);
934
- const { data } = await this.r.put(`/users/${id}`, user);
1496
+ user = CreateSchema.parse(user);
1497
+ const { data } = await this.r.patch(`/users/${id}`, user);
935
1498
  return data.attributes;
936
1499
  };
937
1500
  delete = async (id) => {
938
- z6.number().positive().parse(id);
1501
+ z7.number().positive().parse(id);
939
1502
  await this.r.delete(`/users/${id}`);
940
1503
  };
1504
+ addRoles = async (id, roles) => {
1505
+ z7.number().positive().parse(id);
1506
+ await this.r.patch(`/users/${id}/roles/assign`, { roles });
1507
+ };
1508
+ removeRoles = async (id, roles) => {
1509
+ z7.number().positive().parse(id);
1510
+ await this.r.patch(`/users/${id}/roles/remove`, { roles });
1511
+ };
1512
+ };
1513
+ var CreateSchema = z7.object({
1514
+ email: z7.email(),
1515
+ external_id: z7.string().max(255).optional(),
1516
+ username: z7.string().min(1).max(255),
1517
+ password: z7.string().optional(),
1518
+ language: languagesSchema,
1519
+ timezone: timezonesSchema
1520
+ });
1521
+
1522
+ // src/api/application/nodes_allocations.ts
1523
+ import z8 from "zod";
1524
+ var NodesAllocations = class {
1525
+ r;
1526
+ id;
1527
+ constructor(requester, id) {
1528
+ this.r = requester;
1529
+ this.id = id;
1530
+ }
1531
+ list = async (include) => {
1532
+ const { data } = await this.r.get(`/nodes/${this.id}/allocations`, {
1533
+ params: { include: include?.join(",") }
1534
+ });
1535
+ return data.data.map((d) => d.attributes);
1536
+ };
1537
+ create = async (ip, ports, alias) => {
1538
+ z8.ipv4().parse(ip);
1539
+ z8.ipv4().or(z8.url().max(255)).optional().parse(alias);
1540
+ z8.array(z8.number()).or(z8.string().regex(/\d+-\d+/)).parse(ports);
1541
+ await this.r.post(`/nodes/${this.id}/allocations`, {
1542
+ ip,
1543
+ ports,
1544
+ alias
1545
+ });
1546
+ };
1547
+ delete = async (alloc_id) => {
1548
+ await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
1549
+ };
1550
+ };
1551
+
1552
+ // src/api/application/nodes.ts
1553
+ import z9 from "zod";
1554
+ var Nodes = class {
1555
+ r;
1556
+ constructor(requester) {
1557
+ this.r = requester;
1558
+ }
1559
+ list = async (include, page = 1) => {
1560
+ z9.number().positive().parse(page);
1561
+ const { data } = await this.r.get("/nodes", {
1562
+ params: { include: include?.join(","), page }
1563
+ });
1564
+ return data.data.map((s) => s.attributes);
1565
+ };
1566
+ listDeployable = async (filters, include, page = 1) => {
1567
+ z9.number().positive().parse(page);
1568
+ const { data } = await this.r.get("/nodes/deployable", {
1569
+ params: {
1570
+ include: include?.join(","),
1571
+ disk: filters.disk,
1572
+ memory: filters.memory,
1573
+ cpu: filters.cpu,
1574
+ location_ids: filters.location_ids,
1575
+ tags: filters.tags,
1576
+ page
1577
+ }
1578
+ });
1579
+ return data.data.map((s) => s.attributes);
1580
+ };
1581
+ info = async (id, include) => {
1582
+ z9.number().positive().parse(id);
1583
+ const { data } = await this.r.get(`/nodes/${id}`, {
1584
+ params: { include: include?.join(",") }
1585
+ });
1586
+ return data.attributes;
1587
+ };
1588
+ create = async (node) => {
1589
+ node = NodeCreateSchema.parse(node);
1590
+ const { data } = await this.r.post("/nodes", node);
1591
+ return data.attributes;
1592
+ };
1593
+ get_configuration = async (id) => {
1594
+ z9.number().positive().parse(id);
1595
+ const { data } = await this.r.get(`/nodes/${id}/configuration`);
1596
+ return data;
1597
+ };
1598
+ update = async (id, node) => {
1599
+ z9.number().positive().parse(id);
1600
+ node = NodeCreateSchema.parse(node);
1601
+ const { data } = await this.r.patch(`/nodes/${id}`, node);
1602
+ return data.attributes;
1603
+ };
1604
+ delete = async (id) => {
1605
+ z9.number().positive().parse(id);
1606
+ await this.r.delete(`/nodes/${id}`);
1607
+ };
1608
+ allocations = (server_id) => new NodesAllocations(this.r, server_id);
1609
+ };
1610
+ var NodeCreateSchema = z9.object({
1611
+ name: z9.string().min(1).max(100),
1612
+ description: z9.string().optional(),
1613
+ public: z9.boolean().optional(),
1614
+ fqdn: z9.string().nonempty(),
1615
+ scheme: z9.enum(["http", "https"]),
1616
+ behind_proxy: z9.boolean().optional(),
1617
+ memory: z9.number().min(0),
1618
+ memory_overallocate: z9.number().min(-1),
1619
+ disk: z9.number().min(0),
1620
+ disk_overallocate: z9.number().min(-1),
1621
+ cpu: z9.number().min(0),
1622
+ cpu_overallocate: z9.number().min(-1),
1623
+ daemon_base: z9.string().nonempty().optional(),
1624
+ daemon_sftp: z9.number().min(1).max(65535),
1625
+ daemon_sftp_alias: z9.string().optional(),
1626
+ daemon_listen: z9.number().min(1).max(65535),
1627
+ daemon_connect: z9.number().min(1).max(65535),
1628
+ maintenance_mode: z9.boolean().optional(),
1629
+ upload_size: z9.number().min(1).max(1024),
1630
+ tags: z9.array(z9.string()).optional()
1631
+ });
1632
+
1633
+ // src/api/application/servers.ts
1634
+ import z11 from "zod";
1635
+
1636
+ // src/api/application/servers_databases.ts
1637
+ import z10 from "zod";
1638
+ var ServersDatabases = class {
1639
+ r;
1640
+ id;
1641
+ constructor(r, server_id) {
1642
+ this.r = r;
1643
+ this.id = server_id;
1644
+ }
1645
+ list = async () => {
1646
+ const { data } = await this.r.get(`/servers/${this.id}/databases`);
1647
+ return data.data.map((d) => d.attributes);
1648
+ };
1649
+ create = async (database, remote, host) => {
1650
+ database = z10.string().min(1).max(48).parse(database);
1651
+ const { data } = await this.r.post(`/servers/${this.id}/databases`, { database, remote, host });
1652
+ return data.attributes;
1653
+ };
1654
+ info = async (database_id) => {
1655
+ const { data } = await this.r.get(`/servers/${this.id}/databases/${database_id}`);
1656
+ return data.attributes;
1657
+ };
1658
+ delete = async (database_id) => {
1659
+ await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
1660
+ };
1661
+ resetPassword = async (database_id) => {
1662
+ await this.r.post(`/servers/${this.id}/databases/${database_id}/reset-password`);
1663
+ };
1664
+ };
1665
+
1666
+ // src/api/application/servers.ts
1667
+ var Servers = class {
1668
+ r;
1669
+ id;
1670
+ databases;
1671
+ constructor(r, server_id) {
1672
+ this.r = r;
1673
+ this.id = server_id;
1674
+ this.databases = new ServersDatabases(this.r, this.id);
1675
+ }
1676
+ info = async (include) => {
1677
+ const { data } = await this.r.get(`/servers/${this.id}`, {
1678
+ params: { include: include?.join(",") }
1679
+ });
1680
+ return data.attributes;
1681
+ };
1682
+ delete = async (force = false) => {
1683
+ await this.r.delete(`/servers/${this.id}${force ? "/force" : ""}`);
1684
+ };
1685
+ updateDetails = async (opts) => {
1686
+ opts = UpdateDetailsSchema.parse(opts);
1687
+ await this.r.patch(`/servers/${this.id}/details`, opts);
1688
+ };
1689
+ updateBuild = async (opts) => {
1690
+ opts = UpdateBuildSchema.parse(opts);
1691
+ await this.r.patch(`/servers/${this.id}/build`, opts);
1692
+ };
1693
+ updateStartup = async (opts) => {
1694
+ opts = UpdateStartupSchema.parse(opts);
1695
+ await this.r.patch(`/servers/${this.id}/startup`, opts);
1696
+ };
1697
+ suspend = async () => {
1698
+ await this.r.post(`/servers/${this.id}/suspend`);
1699
+ };
1700
+ unsuspend = async () => {
1701
+ await this.r.post(`/servers/${this.id}/unsuspend`);
1702
+ };
1703
+ reinstall = async () => {
1704
+ await this.r.post(`/servers/${this.id}/reinstall`);
1705
+ };
1706
+ transferStart = async (node_id, allocation_id, allocation_additional) => {
1707
+ await this.r.post(`/servers/${this.id}/transfer`, {
1708
+ node_id,
1709
+ allocation_id,
1710
+ allocation_additional
1711
+ });
1712
+ };
1713
+ transferCancel = async () => {
1714
+ await this.r.post(`/servers/${this.id}/transfer/cancel`);
1715
+ };
1716
+ };
1717
+ var CreateServerSchema = z11.object({
1718
+ external_id: z11.string().min(1).max(255).optional(),
1719
+ name: z11.string().min(1).max(255),
1720
+ description: z11.string().optional(),
1721
+ user: z11.number(),
1722
+ egg: z11.number(),
1723
+ docker_image: z11.string().optional(),
1724
+ startup: z11.string().optional(),
1725
+ environment: z11.array(z11.string()),
1726
+ skip_scripts: z11.boolean().optional(),
1727
+ oom_killer: z11.boolean().optional(),
1728
+ start_on_completion: z11.boolean().optional(),
1729
+ limits: z11.object({
1730
+ memory: z11.number().min(0),
1731
+ swap: z11.number().min(-1),
1732
+ disk: z11.number().min(0),
1733
+ io: z11.number().min(0),
1734
+ threads: z11.string().optional(),
1735
+ cpu: z11.number().min(0)
1736
+ }),
1737
+ feature_limits: z11.object({
1738
+ databases: z11.number().min(0),
1739
+ allocations: z11.number().min(0),
1740
+ backups: z11.number().min(0)
1741
+ }),
1742
+ allocation: z11.object({
1743
+ default: z11.string(),
1744
+ additional: z11.array(z11.string()).optional()
1745
+ }).optional(),
1746
+ deploy: z11.object({
1747
+ tags: z11.array(z11.string()).optional(),
1748
+ dedicated_ip: z11.boolean().optional(),
1749
+ port_range: z11.array(z11.string()).optional()
1750
+ }).optional()
1751
+ });
1752
+ var UpdateDetailsSchema = CreateServerSchema.pick({
1753
+ external_id: true,
1754
+ name: true,
1755
+ user: true,
1756
+ description: true
1757
+ });
1758
+ var UpdateBuildSchema = CreateServerSchema.pick({
1759
+ oom_killer: true,
1760
+ limits: true,
1761
+ feature_limits: true
1762
+ }).extend({
1763
+ allocation: z11.number().optional(),
1764
+ add_allocations: z11.array(z11.string()).optional(),
1765
+ remove_allocations: z11.array(z11.string()).optional()
1766
+ });
1767
+ var UpdateStartupSchema = CreateServerSchema.pick({
1768
+ startup: true,
1769
+ environment: true,
1770
+ egg: true,
1771
+ skip_scripts: true
1772
+ }).extend({
1773
+ image: z11.string().optional()
1774
+ });
1775
+
1776
+ // src/api/application/database_hosts.ts
1777
+ import z12 from "zod";
1778
+ var DatabaseHosts = class {
1779
+ r;
1780
+ constructor(r) {
1781
+ this.r = r;
1782
+ }
1783
+ list = async (page = 1) => {
1784
+ const { data } = await this.r.get("/database-hosts", {
1785
+ params: { page }
1786
+ });
1787
+ return data.data.map((d) => d.attributes);
1788
+ };
1789
+ info = async (id) => {
1790
+ const { data } = await this.r.get(`/database-hosts/${id}`);
1791
+ return data.attributes;
1792
+ };
1793
+ // TODO: find out why API returns 500
1794
+ create = async (opts) => {
1795
+ opts = CreateDBHostSchema.parse(opts);
1796
+ await this.r.post("/database-hosts", opts).catch((e) => {
1797
+ });
1798
+ };
1799
+ update = async (id, opts) => {
1800
+ opts = CreateDBHostSchema.parse(opts);
1801
+ const { data } = await this.r.patch(`/database-hosts/${id}`, opts);
1802
+ return data.attributes;
1803
+ };
1804
+ delete = async (id) => {
1805
+ await this.r.delete(`/database-hosts/${id}`);
1806
+ };
1807
+ };
1808
+ var CreateDBHostSchema = z12.object({
1809
+ name: z12.string().min(1).max(255),
1810
+ host: z12.string(),
1811
+ port: z12.number().min(1).max(65535),
1812
+ username: z12.string().min(1).max(255),
1813
+ password: z12.string().optional(),
1814
+ node_ids: z12.array(z12.string()).optional(),
1815
+ max_databases: z12.number().optional()
1816
+ });
1817
+
1818
+ // src/api/application/roles.ts
1819
+ var Roles = class {
1820
+ r;
1821
+ constructor(r) {
1822
+ this.r = r;
1823
+ }
1824
+ list = async (page = 1) => {
1825
+ const { data } = await this.r.get(`/roles`, {
1826
+ params: { page }
1827
+ });
1828
+ return data.data.map((r) => r.attributes);
1829
+ };
1830
+ info = async (id) => {
1831
+ const { data } = await this.r.get(`/roles/${id}`);
1832
+ return data.attributes;
1833
+ };
1834
+ create = async (opts) => {
1835
+ await this.r.post(`/roles`, opts);
1836
+ };
1837
+ update = async (id, opts) => {
1838
+ await this.r.patch(`/roles/${id}`, opts);
1839
+ };
1840
+ delete = async (id) => {
1841
+ await this.r.delete(`/roles/${id}`);
1842
+ };
941
1843
  };
942
1844
 
943
1845
  // src/api/application/client.ts
944
1846
  var Client2 = class {
945
1847
  r;
946
1848
  users;
1849
+ nodes;
1850
+ databaseHosts;
1851
+ roles;
947
1852
  constructor(requester) {
948
1853
  this.r = requester;
949
1854
  this.users = new Users(requester);
1855
+ this.nodes = new Nodes(requester);
1856
+ this.databaseHosts = new DatabaseHosts(requester);
1857
+ this.roles = new Roles(requester);
950
1858
  }
1859
+ listServers = async (search, page = 1) => {
1860
+ const { data } = await this.r.get("/servers", {
1861
+ params: { search, page }
1862
+ });
1863
+ return data.data.map((s) => s.attributes);
1864
+ };
1865
+ createServer = async (opts) => {
1866
+ opts = CreateServerSchema.parse(opts);
1867
+ const { data } = await this.r.post("/servers", opts);
1868
+ return data.attributes;
1869
+ };
1870
+ getServerByExternalId = async (external_id, include) => {
1871
+ const { data } = await this.r.get(`/servers/external/${external_id}`, {
1872
+ params: { include: include?.join(",") }
1873
+ });
1874
+ return data.attributes;
1875
+ };
1876
+ servers = (server_id) => new Servers(this.r, server_id);
951
1877
  };
952
1878
 
953
1879
  // src/api/base/request.ts
954
- import z7 from "zod";
1880
+ import z13 from "zod";
955
1881
  import axios3 from "axios";
956
1882
 
957
1883
  // src/api/base/types.ts
@@ -970,11 +1896,11 @@ var Agent = class {
970
1896
  base_url;
971
1897
  token;
972
1898
  requester;
973
- constructor(url, token, type) {
974
- this.base_url = z7.url("Invalid URL Schema").parse(url);
975
- this.token = z7.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
1899
+ constructor(url, token, type, suffix = "/api") {
1900
+ this.base_url = z13.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
1901
+ this.token = z13.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
976
1902
  this.requester = axios3.create({
977
- baseURL: this.base_url.replace(/\/+$/, "") + `/api/${type}`,
1903
+ baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
978
1904
  timeout: 3e3,
979
1905
  headers: {
980
1906
  Authorization: `Bearer ${this.token}`
@@ -995,14 +1921,14 @@ var Agent = class {
995
1921
 
996
1922
  // src/index.ts
997
1923
  var PelicanClient = class extends Client {
998
- constructor(url, token) {
999
- const ax = new Agent(url, token, "client");
1924
+ constructor(url, token, suffix = "/api") {
1925
+ const ax = new Agent(url, token, "client", suffix);
1000
1926
  super(ax.requester);
1001
1927
  }
1002
1928
  };
1003
1929
  var PelicanApplication = class extends Client2 {
1004
- constructor(url, token) {
1005
- const ax = new Agent(url, token, "application");
1930
+ constructor(url, token, suffix = "/api") {
1931
+ const ax = new Agent(url, token, "application", suffix);
1006
1932
  super(ax.requester);
1007
1933
  }
1008
1934
  };