@szymonpiatek/nextwordpress 0.0.5 → 0.0.7
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/hooks/index.cjs +373 -12
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +92 -2
- package/dist/hooks/index.d.ts +92 -2
- package/dist/hooks/index.js +367 -13
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +737 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +549 -130
- package/dist/index.d.ts +549 -130
- package/dist/index.js +737 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-EjYH-eZp.d.cts → types-Be60n09c.d.cts} +159 -1
- package/dist/{types-EjYH-eZp.d.ts → types-Be60n09c.d.ts} +159 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ async function doFetch(url, init = {}) {
|
|
|
45
45
|
return response;
|
|
46
46
|
}
|
|
47
47
|
function createFetcher(config) {
|
|
48
|
-
const cacheTtl = 300;
|
|
48
|
+
const cacheTtl = config.cacheTTL ?? 300;
|
|
49
49
|
async function wpFetch(path, query, tags = ["wordpress"]) {
|
|
50
50
|
const url = buildUrl(config, path, query);
|
|
51
51
|
const res = await doFetch(url, {
|
|
@@ -725,7 +725,8 @@ function createWooCommerceFetcher(config) {
|
|
|
725
725
|
return { ...query, consumer_key: config.consumerKey, consumer_secret: config.consumerSecret };
|
|
726
726
|
}
|
|
727
727
|
function buildUrl2(path, query) {
|
|
728
|
-
|
|
728
|
+
const base = typeof window !== "undefined" && config.clientURL ? config.clientURL : config.serverURL;
|
|
729
|
+
return `${base}${path}?${toQueryString(withAuth(query))}`;
|
|
729
730
|
}
|
|
730
731
|
async function wcFetch(path, query, tags = ["woocommerce"], options) {
|
|
731
732
|
const url = buildUrl2(path, query);
|
|
@@ -1209,6 +1210,725 @@ function createCustomersQueries(fetcher) {
|
|
|
1209
1210
|
};
|
|
1210
1211
|
}
|
|
1211
1212
|
|
|
1213
|
+
// src/integrations/restApi/woocommerce/payment_gateways/queries.ts
|
|
1214
|
+
function createPaymentGatewaysQueries(fetcher) {
|
|
1215
|
+
const { wcFetch, wcFetchGraceful } = fetcher;
|
|
1216
|
+
async function getPaymentGateways() {
|
|
1217
|
+
return wcFetchGraceful(
|
|
1218
|
+
"/wp-json/wc/v3/payment_gateways",
|
|
1219
|
+
[],
|
|
1220
|
+
void 0,
|
|
1221
|
+
["woocommerce", "payment_gateways"]
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
async function getEnabledPaymentGateways() {
|
|
1225
|
+
const gateways = await wcFetchGraceful(
|
|
1226
|
+
"/wp-json/wc/v3/payment_gateways",
|
|
1227
|
+
[],
|
|
1228
|
+
void 0,
|
|
1229
|
+
["woocommerce", "payment_gateways"]
|
|
1230
|
+
);
|
|
1231
|
+
return gateways.filter((g) => g.enabled);
|
|
1232
|
+
}
|
|
1233
|
+
async function getPaymentGatewayById(id) {
|
|
1234
|
+
return wcFetch(
|
|
1235
|
+
`/wp-json/wc/v3/payment_gateways/${id}`,
|
|
1236
|
+
void 0,
|
|
1237
|
+
["woocommerce", "payment_gateways", `payment_gateway-${id}`]
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
return {
|
|
1241
|
+
getPaymentGateways,
|
|
1242
|
+
getEnabledPaymentGateways,
|
|
1243
|
+
getPaymentGatewayById
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
// src/integrations/restApi/woocommerce/order_notes/queries.ts
|
|
1248
|
+
function createOrderNotesQueries(fetcher) {
|
|
1249
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1250
|
+
async function getNotesByOrderId(orderId) {
|
|
1251
|
+
return wcFetchGraceful(
|
|
1252
|
+
`/wp-json/wc/v3/orders/${orderId}/notes`,
|
|
1253
|
+
[],
|
|
1254
|
+
void 0,
|
|
1255
|
+
["woocommerce", "order_notes", `order-${orderId}-notes`]
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
async function getOrderNoteById(orderId, noteId) {
|
|
1259
|
+
return wcFetch(
|
|
1260
|
+
`/wp-json/wc/v3/orders/${orderId}/notes/${noteId}`,
|
|
1261
|
+
void 0,
|
|
1262
|
+
["woocommerce", "order_notes", `order-${orderId}-note-${noteId}`]
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
async function createOrderNote(orderId, input) {
|
|
1266
|
+
return wcMutate(
|
|
1267
|
+
`/wp-json/wc/v3/orders/${orderId}/notes`,
|
|
1268
|
+
input,
|
|
1269
|
+
"POST"
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
async function deleteOrderNote(orderId, noteId, force = true) {
|
|
1273
|
+
return wcMutate(
|
|
1274
|
+
`/wp-json/wc/v3/orders/${orderId}/notes/${noteId}`,
|
|
1275
|
+
{ force },
|
|
1276
|
+
"DELETE"
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
return {
|
|
1280
|
+
getNotesByOrderId,
|
|
1281
|
+
getOrderNoteById,
|
|
1282
|
+
createOrderNote,
|
|
1283
|
+
deleteOrderNote
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// src/integrations/restApi/woocommerce/order_refunds/queries.ts
|
|
1288
|
+
function createOrderRefundsQueries(fetcher) {
|
|
1289
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1290
|
+
async function getRefundsByOrderId(orderId) {
|
|
1291
|
+
return wcFetchGraceful(
|
|
1292
|
+
`/wp-json/wc/v3/orders/${orderId}/refunds`,
|
|
1293
|
+
[],
|
|
1294
|
+
void 0,
|
|
1295
|
+
["woocommerce", "order_refunds", `order-${orderId}-refunds`]
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
async function getOrderRefundById(orderId, refundId) {
|
|
1299
|
+
return wcFetch(
|
|
1300
|
+
`/wp-json/wc/v3/orders/${orderId}/refunds/${refundId}`,
|
|
1301
|
+
void 0,
|
|
1302
|
+
["woocommerce", "order_refunds", `order-${orderId}-refund-${refundId}`]
|
|
1303
|
+
);
|
|
1304
|
+
}
|
|
1305
|
+
async function createOrderRefund(orderId, input) {
|
|
1306
|
+
return wcMutate(
|
|
1307
|
+
`/wp-json/wc/v3/orders/${orderId}/refunds`,
|
|
1308
|
+
input,
|
|
1309
|
+
"POST"
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
async function deleteOrderRefund(orderId, refundId, force = true) {
|
|
1313
|
+
return wcMutate(
|
|
1314
|
+
`/wp-json/wc/v3/orders/${orderId}/refunds/${refundId}`,
|
|
1315
|
+
{ force },
|
|
1316
|
+
"DELETE"
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
return {
|
|
1320
|
+
getRefundsByOrderId,
|
|
1321
|
+
getOrderRefundById,
|
|
1322
|
+
createOrderRefund,
|
|
1323
|
+
deleteOrderRefund
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// src/integrations/restApi/woocommerce/product_attributes/queries.ts
|
|
1328
|
+
function createProductAttributesQueries(fetcher) {
|
|
1329
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1330
|
+
async function getProductAttributes() {
|
|
1331
|
+
return wcFetchGraceful(
|
|
1332
|
+
"/wp-json/wc/v3/products/attributes",
|
|
1333
|
+
[],
|
|
1334
|
+
void 0,
|
|
1335
|
+
["woocommerce", "product_attributes"]
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
async function getProductAttributeById(id) {
|
|
1339
|
+
return wcFetch(
|
|
1340
|
+
`/wp-json/wc/v3/products/attributes/${id}`,
|
|
1341
|
+
void 0,
|
|
1342
|
+
["woocommerce", "product_attributes", `attribute-${id}`]
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1345
|
+
async function createProductAttribute(input) {
|
|
1346
|
+
return wcMutate("/wp-json/wc/v3/products/attributes", input, "POST");
|
|
1347
|
+
}
|
|
1348
|
+
async function updateProductAttribute(id, input) {
|
|
1349
|
+
return wcMutate(
|
|
1350
|
+
`/wp-json/wc/v3/products/attributes/${id}`,
|
|
1351
|
+
input,
|
|
1352
|
+
"PUT"
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
async function deleteProductAttribute(id, force = true) {
|
|
1356
|
+
return wcMutate(
|
|
1357
|
+
`/wp-json/wc/v3/products/attributes/${id}`,
|
|
1358
|
+
{ force },
|
|
1359
|
+
"DELETE"
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
async function getAttributeTerms(attributeId) {
|
|
1363
|
+
return wcFetchGraceful(
|
|
1364
|
+
`/wp-json/wc/v3/products/attributes/${attributeId}/terms`,
|
|
1365
|
+
[],
|
|
1366
|
+
void 0,
|
|
1367
|
+
["woocommerce", "attribute_terms", `attribute-${attributeId}-terms`]
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
async function getAttributeTermById(attributeId, termId) {
|
|
1371
|
+
return wcFetch(
|
|
1372
|
+
`/wp-json/wc/v3/products/attributes/${attributeId}/terms/${termId}`,
|
|
1373
|
+
void 0,
|
|
1374
|
+
["woocommerce", "attribute_terms", `attribute-${attributeId}-term-${termId}`]
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
async function createAttributeTerm(attributeId, input) {
|
|
1378
|
+
return wcMutate(
|
|
1379
|
+
`/wp-json/wc/v3/products/attributes/${attributeId}/terms`,
|
|
1380
|
+
input,
|
|
1381
|
+
"POST"
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
async function updateAttributeTerm(attributeId, termId, input) {
|
|
1385
|
+
return wcMutate(
|
|
1386
|
+
`/wp-json/wc/v3/products/attributes/${attributeId}/terms/${termId}`,
|
|
1387
|
+
input,
|
|
1388
|
+
"PUT"
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
async function deleteAttributeTerm(attributeId, termId, force = true) {
|
|
1392
|
+
return wcMutate(
|
|
1393
|
+
`/wp-json/wc/v3/products/attributes/${attributeId}/terms/${termId}`,
|
|
1394
|
+
{ force },
|
|
1395
|
+
"DELETE"
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1398
|
+
return {
|
|
1399
|
+
getProductAttributes,
|
|
1400
|
+
getProductAttributeById,
|
|
1401
|
+
createProductAttribute,
|
|
1402
|
+
updateProductAttribute,
|
|
1403
|
+
deleteProductAttribute,
|
|
1404
|
+
getAttributeTerms,
|
|
1405
|
+
getAttributeTermById,
|
|
1406
|
+
createAttributeTerm,
|
|
1407
|
+
updateAttributeTerm,
|
|
1408
|
+
deleteAttributeTerm
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// src/integrations/restApi/woocommerce/product_reviews/queries.ts
|
|
1413
|
+
function createProductReviewsQueries(fetcher) {
|
|
1414
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1415
|
+
async function getProductReviews(params) {
|
|
1416
|
+
return wcFetchGraceful(
|
|
1417
|
+
"/wp-json/wc/v3/products/reviews",
|
|
1418
|
+
[],
|
|
1419
|
+
params,
|
|
1420
|
+
["woocommerce", "product_reviews"]
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
1423
|
+
async function getProductReviewsByProductId(productId) {
|
|
1424
|
+
return wcFetchGraceful(
|
|
1425
|
+
"/wp-json/wc/v3/products/reviews",
|
|
1426
|
+
[],
|
|
1427
|
+
{ product: [productId] },
|
|
1428
|
+
["woocommerce", "product_reviews", `reviews-product-${productId}`]
|
|
1429
|
+
);
|
|
1430
|
+
}
|
|
1431
|
+
async function getProductReviewById(id) {
|
|
1432
|
+
return wcFetch(
|
|
1433
|
+
`/wp-json/wc/v3/products/reviews/${id}`,
|
|
1434
|
+
void 0,
|
|
1435
|
+
["woocommerce", "product_reviews", `review-${id}`]
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
async function createProductReview(input) {
|
|
1439
|
+
return wcMutate("/wp-json/wc/v3/products/reviews", input, "POST");
|
|
1440
|
+
}
|
|
1441
|
+
async function updateProductReview(id, input) {
|
|
1442
|
+
return wcMutate(`/wp-json/wc/v3/products/reviews/${id}`, input, "PUT");
|
|
1443
|
+
}
|
|
1444
|
+
async function deleteProductReview(id, force = true) {
|
|
1445
|
+
return wcMutate(
|
|
1446
|
+
`/wp-json/wc/v3/products/reviews/${id}`,
|
|
1447
|
+
{ force },
|
|
1448
|
+
"DELETE"
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
return {
|
|
1452
|
+
getProductReviews,
|
|
1453
|
+
getProductReviewsByProductId,
|
|
1454
|
+
getProductReviewById,
|
|
1455
|
+
createProductReview,
|
|
1456
|
+
updateProductReview,
|
|
1457
|
+
deleteProductReview
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// src/integrations/restApi/woocommerce/shipping_classes/queries.ts
|
|
1462
|
+
function createShippingClassesQueries(fetcher) {
|
|
1463
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1464
|
+
async function getShippingClasses() {
|
|
1465
|
+
return wcFetchGraceful(
|
|
1466
|
+
"/wp-json/wc/v3/products/shipping_classes",
|
|
1467
|
+
[],
|
|
1468
|
+
void 0,
|
|
1469
|
+
["woocommerce", "shipping_classes"]
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
async function getShippingClassById(id) {
|
|
1473
|
+
return wcFetch(
|
|
1474
|
+
`/wp-json/wc/v3/products/shipping_classes/${id}`,
|
|
1475
|
+
void 0,
|
|
1476
|
+
["woocommerce", "shipping_classes", `shipping-class-${id}`]
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
async function createShippingClass(input) {
|
|
1480
|
+
return wcMutate("/wp-json/wc/v3/products/shipping_classes", input, "POST");
|
|
1481
|
+
}
|
|
1482
|
+
async function updateShippingClass(id, input) {
|
|
1483
|
+
return wcMutate(
|
|
1484
|
+
`/wp-json/wc/v3/products/shipping_classes/${id}`,
|
|
1485
|
+
input,
|
|
1486
|
+
"PUT"
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
async function deleteShippingClass(id, force = true) {
|
|
1490
|
+
return wcMutate(
|
|
1491
|
+
`/wp-json/wc/v3/products/shipping_classes/${id}`,
|
|
1492
|
+
{ force },
|
|
1493
|
+
"DELETE"
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
return {
|
|
1497
|
+
getShippingClasses,
|
|
1498
|
+
getShippingClassById,
|
|
1499
|
+
createShippingClass,
|
|
1500
|
+
updateShippingClass,
|
|
1501
|
+
deleteShippingClass
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// src/integrations/restApi/woocommerce/taxes/queries.ts
|
|
1506
|
+
function createTaxesQueries(fetcher) {
|
|
1507
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1508
|
+
async function getTaxRates(params) {
|
|
1509
|
+
return wcFetchGraceful(
|
|
1510
|
+
"/wp-json/wc/v3/taxes",
|
|
1511
|
+
[],
|
|
1512
|
+
params,
|
|
1513
|
+
["woocommerce", "tax_rates"]
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
async function getTaxRateById(id) {
|
|
1517
|
+
return wcFetch(
|
|
1518
|
+
`/wp-json/wc/v3/taxes/${id}`,
|
|
1519
|
+
void 0,
|
|
1520
|
+
["woocommerce", "tax_rates", `tax-rate-${id}`]
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
async function createTaxRate(input) {
|
|
1524
|
+
return wcMutate("/wp-json/wc/v3/taxes", input, "POST");
|
|
1525
|
+
}
|
|
1526
|
+
async function updateTaxRate(id, input) {
|
|
1527
|
+
return wcMutate(`/wp-json/wc/v3/taxes/${id}`, input, "PUT");
|
|
1528
|
+
}
|
|
1529
|
+
async function deleteTaxRate(id, force = true) {
|
|
1530
|
+
return wcMutate(
|
|
1531
|
+
`/wp-json/wc/v3/taxes/${id}`,
|
|
1532
|
+
{ force },
|
|
1533
|
+
"DELETE"
|
|
1534
|
+
);
|
|
1535
|
+
}
|
|
1536
|
+
async function getTaxClasses() {
|
|
1537
|
+
return wcFetchGraceful(
|
|
1538
|
+
"/wp-json/wc/v3/taxes/classes",
|
|
1539
|
+
[],
|
|
1540
|
+
void 0,
|
|
1541
|
+
["woocommerce", "tax_classes"]
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
async function createTaxClass(input) {
|
|
1545
|
+
return wcMutate("/wp-json/wc/v3/taxes/classes", input, "POST");
|
|
1546
|
+
}
|
|
1547
|
+
async function deleteTaxClass(slug, force = true) {
|
|
1548
|
+
return wcMutate(
|
|
1549
|
+
`/wp-json/wc/v3/taxes/classes/${slug}`,
|
|
1550
|
+
{ force },
|
|
1551
|
+
"DELETE"
|
|
1552
|
+
);
|
|
1553
|
+
}
|
|
1554
|
+
return {
|
|
1555
|
+
getTaxRates,
|
|
1556
|
+
getTaxRateById,
|
|
1557
|
+
createTaxRate,
|
|
1558
|
+
updateTaxRate,
|
|
1559
|
+
deleteTaxRate,
|
|
1560
|
+
getTaxClasses,
|
|
1561
|
+
createTaxClass,
|
|
1562
|
+
deleteTaxClass
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// src/integrations/restApi/woocommerce/shipping/queries.ts
|
|
1567
|
+
function createShippingQueries(fetcher) {
|
|
1568
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1569
|
+
async function getShippingZones() {
|
|
1570
|
+
return wcFetchGraceful(
|
|
1571
|
+
"/wp-json/wc/v3/shipping/zones",
|
|
1572
|
+
[],
|
|
1573
|
+
void 0,
|
|
1574
|
+
["woocommerce", "shipping_zones"]
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
async function getShippingZoneById(id) {
|
|
1578
|
+
return wcFetch(
|
|
1579
|
+
`/wp-json/wc/v3/shipping/zones/${id}`,
|
|
1580
|
+
void 0,
|
|
1581
|
+
["woocommerce", "shipping_zones", `zone-${id}`]
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
async function createShippingZone(input) {
|
|
1585
|
+
return wcMutate("/wp-json/wc/v3/shipping/zones", input, "POST");
|
|
1586
|
+
}
|
|
1587
|
+
async function updateShippingZone(id, input) {
|
|
1588
|
+
return wcMutate(`/wp-json/wc/v3/shipping/zones/${id}`, input, "PUT");
|
|
1589
|
+
}
|
|
1590
|
+
async function deleteShippingZone(id, force = true) {
|
|
1591
|
+
return wcMutate(
|
|
1592
|
+
`/wp-json/wc/v3/shipping/zones/${id}`,
|
|
1593
|
+
{ force },
|
|
1594
|
+
"DELETE"
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
async function getShippingZoneLocations(zoneId) {
|
|
1598
|
+
return wcFetchGraceful(
|
|
1599
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/locations`,
|
|
1600
|
+
[],
|
|
1601
|
+
void 0,
|
|
1602
|
+
["woocommerce", "shipping_zone_locations", `zone-${zoneId}-locations`]
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
async function updateShippingZoneLocations(zoneId, locations) {
|
|
1606
|
+
return wcMutate(
|
|
1607
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/locations`,
|
|
1608
|
+
locations,
|
|
1609
|
+
"PUT"
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
async function getShippingZoneMethods(zoneId) {
|
|
1613
|
+
return wcFetchGraceful(
|
|
1614
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/methods`,
|
|
1615
|
+
[],
|
|
1616
|
+
void 0,
|
|
1617
|
+
["woocommerce", "shipping_zone_methods", `zone-${zoneId}-methods`]
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
async function getShippingZoneMethodById(zoneId, instanceId) {
|
|
1621
|
+
return wcFetch(
|
|
1622
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/methods/${instanceId}`,
|
|
1623
|
+
void 0,
|
|
1624
|
+
["woocommerce", "shipping_zone_methods", `zone-${zoneId}-method-${instanceId}`]
|
|
1625
|
+
);
|
|
1626
|
+
}
|
|
1627
|
+
async function createShippingZoneMethod(zoneId, input) {
|
|
1628
|
+
return wcMutate(
|
|
1629
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/methods`,
|
|
1630
|
+
input,
|
|
1631
|
+
"POST"
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
async function updateShippingZoneMethod(zoneId, instanceId, input) {
|
|
1635
|
+
return wcMutate(
|
|
1636
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/methods/${instanceId}`,
|
|
1637
|
+
input,
|
|
1638
|
+
"PUT"
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
async function deleteShippingZoneMethod(zoneId, instanceId, force = true) {
|
|
1642
|
+
return wcMutate(
|
|
1643
|
+
`/wp-json/wc/v3/shipping/zones/${zoneId}/methods/${instanceId}`,
|
|
1644
|
+
{ force },
|
|
1645
|
+
"DELETE"
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
async function getShippingMethods() {
|
|
1649
|
+
return wcFetchGraceful(
|
|
1650
|
+
"/wp-json/wc/v3/shipping_methods",
|
|
1651
|
+
[],
|
|
1652
|
+
void 0,
|
|
1653
|
+
["woocommerce", "shipping_methods"]
|
|
1654
|
+
);
|
|
1655
|
+
}
|
|
1656
|
+
async function getShippingMethodById(id) {
|
|
1657
|
+
return wcFetch(
|
|
1658
|
+
`/wp-json/wc/v3/shipping_methods/${id}`,
|
|
1659
|
+
void 0,
|
|
1660
|
+
["woocommerce", "shipping_methods", `shipping-method-${id}`]
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
return {
|
|
1664
|
+
getShippingZones,
|
|
1665
|
+
getShippingZoneById,
|
|
1666
|
+
createShippingZone,
|
|
1667
|
+
updateShippingZone,
|
|
1668
|
+
deleteShippingZone,
|
|
1669
|
+
getShippingZoneLocations,
|
|
1670
|
+
updateShippingZoneLocations,
|
|
1671
|
+
getShippingZoneMethods,
|
|
1672
|
+
getShippingZoneMethodById,
|
|
1673
|
+
createShippingZoneMethod,
|
|
1674
|
+
updateShippingZoneMethod,
|
|
1675
|
+
deleteShippingZoneMethod,
|
|
1676
|
+
getShippingMethods,
|
|
1677
|
+
getShippingMethodById
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
// src/integrations/restApi/woocommerce/webhooks/queries.ts
|
|
1682
|
+
function createWebhooksQueries(fetcher) {
|
|
1683
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1684
|
+
async function getWebhooks(params) {
|
|
1685
|
+
return wcFetchGraceful(
|
|
1686
|
+
"/wp-json/wc/v3/webhooks",
|
|
1687
|
+
[],
|
|
1688
|
+
params,
|
|
1689
|
+
["woocommerce", "webhooks"]
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
async function getWebhookById(id) {
|
|
1693
|
+
return wcFetch(
|
|
1694
|
+
`/wp-json/wc/v3/webhooks/${id}`,
|
|
1695
|
+
void 0,
|
|
1696
|
+
["woocommerce", "webhooks", `webhook-${id}`]
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1699
|
+
async function createWebhook(input) {
|
|
1700
|
+
return wcMutate("/wp-json/wc/v3/webhooks", input, "POST");
|
|
1701
|
+
}
|
|
1702
|
+
async function updateWebhook(id, input) {
|
|
1703
|
+
return wcMutate(`/wp-json/wc/v3/webhooks/${id}`, input, "PUT");
|
|
1704
|
+
}
|
|
1705
|
+
async function deleteWebhook(id, force = true) {
|
|
1706
|
+
return wcMutate(
|
|
1707
|
+
`/wp-json/wc/v3/webhooks/${id}`,
|
|
1708
|
+
{ force },
|
|
1709
|
+
"DELETE"
|
|
1710
|
+
);
|
|
1711
|
+
}
|
|
1712
|
+
return {
|
|
1713
|
+
getWebhooks,
|
|
1714
|
+
getWebhookById,
|
|
1715
|
+
createWebhook,
|
|
1716
|
+
updateWebhook,
|
|
1717
|
+
deleteWebhook
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// src/integrations/restApi/woocommerce/settings/queries.ts
|
|
1722
|
+
function createSettingsQueries(fetcher) {
|
|
1723
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1724
|
+
async function getSettingGroups() {
|
|
1725
|
+
return wcFetchGraceful(
|
|
1726
|
+
"/wp-json/wc/v3/settings",
|
|
1727
|
+
[],
|
|
1728
|
+
void 0,
|
|
1729
|
+
["woocommerce", "settings"]
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
async function getSettingOptions(groupId) {
|
|
1733
|
+
return wcFetchGraceful(
|
|
1734
|
+
`/wp-json/wc/v3/settings/${groupId}`,
|
|
1735
|
+
[],
|
|
1736
|
+
void 0,
|
|
1737
|
+
["woocommerce", "settings", `settings-${groupId}`]
|
|
1738
|
+
);
|
|
1739
|
+
}
|
|
1740
|
+
async function getSettingOption(groupId, optionId) {
|
|
1741
|
+
return wcFetch(
|
|
1742
|
+
`/wp-json/wc/v3/settings/${groupId}/${optionId}`,
|
|
1743
|
+
void 0,
|
|
1744
|
+
["woocommerce", "settings", `settings-${groupId}-${optionId}`]
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1747
|
+
async function updateSettingOption(groupId, optionId, value) {
|
|
1748
|
+
return wcMutate(
|
|
1749
|
+
`/wp-json/wc/v3/settings/${groupId}/${optionId}`,
|
|
1750
|
+
{ value },
|
|
1751
|
+
"PUT"
|
|
1752
|
+
);
|
|
1753
|
+
}
|
|
1754
|
+
return {
|
|
1755
|
+
getSettingGroups,
|
|
1756
|
+
getSettingOptions,
|
|
1757
|
+
getSettingOption,
|
|
1758
|
+
updateSettingOption
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
// src/integrations/restApi/woocommerce/reports/queries.ts
|
|
1763
|
+
function createReportsQueries(fetcher) {
|
|
1764
|
+
const { wcFetchGraceful } = fetcher;
|
|
1765
|
+
async function getSalesReport(params) {
|
|
1766
|
+
return wcFetchGraceful(
|
|
1767
|
+
"/wp-json/wc/v3/reports/sales",
|
|
1768
|
+
[],
|
|
1769
|
+
params,
|
|
1770
|
+
["woocommerce", "reports", "sales"]
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
async function getTopSellers(params) {
|
|
1774
|
+
return wcFetchGraceful(
|
|
1775
|
+
"/wp-json/wc/v3/reports/top_sellers",
|
|
1776
|
+
[],
|
|
1777
|
+
params,
|
|
1778
|
+
["woocommerce", "reports", "top_sellers"]
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
async function getOrdersTotals() {
|
|
1782
|
+
return wcFetchGraceful(
|
|
1783
|
+
"/wp-json/wc/v3/reports/orders/totals",
|
|
1784
|
+
[],
|
|
1785
|
+
void 0,
|
|
1786
|
+
["woocommerce", "reports", "orders_totals"]
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1789
|
+
async function getProductsTotals() {
|
|
1790
|
+
return wcFetchGraceful(
|
|
1791
|
+
"/wp-json/wc/v3/reports/products/totals",
|
|
1792
|
+
[],
|
|
1793
|
+
void 0,
|
|
1794
|
+
["woocommerce", "reports", "products_totals"]
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
async function getCustomersTotals() {
|
|
1798
|
+
return wcFetchGraceful(
|
|
1799
|
+
"/wp-json/wc/v3/reports/customers/totals",
|
|
1800
|
+
[],
|
|
1801
|
+
void 0,
|
|
1802
|
+
["woocommerce", "reports", "customers_totals"]
|
|
1803
|
+
);
|
|
1804
|
+
}
|
|
1805
|
+
async function getCouponsTotals() {
|
|
1806
|
+
return wcFetchGraceful(
|
|
1807
|
+
"/wp-json/wc/v3/reports/coupons/totals",
|
|
1808
|
+
[],
|
|
1809
|
+
void 0,
|
|
1810
|
+
["woocommerce", "reports", "coupons_totals"]
|
|
1811
|
+
);
|
|
1812
|
+
}
|
|
1813
|
+
async function getReviewsTotals() {
|
|
1814
|
+
return wcFetchGraceful(
|
|
1815
|
+
"/wp-json/wc/v3/reports/reviews/totals",
|
|
1816
|
+
[],
|
|
1817
|
+
void 0,
|
|
1818
|
+
["woocommerce", "reports", "reviews_totals"]
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
return {
|
|
1822
|
+
getSalesReport,
|
|
1823
|
+
getTopSellers,
|
|
1824
|
+
getOrdersTotals,
|
|
1825
|
+
getProductsTotals,
|
|
1826
|
+
getCustomersTotals,
|
|
1827
|
+
getCouponsTotals,
|
|
1828
|
+
getReviewsTotals
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// src/integrations/restApi/woocommerce/data/queries.ts
|
|
1833
|
+
function createDataQueries(fetcher) {
|
|
1834
|
+
const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
|
|
1835
|
+
async function getCurrencies() {
|
|
1836
|
+
return wcFetchGraceful(
|
|
1837
|
+
"/wp-json/wc/v3/data/currencies",
|
|
1838
|
+
[],
|
|
1839
|
+
void 0,
|
|
1840
|
+
["woocommerce", "data", "currencies"]
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
async function getCurrentCurrency() {
|
|
1844
|
+
return wcFetch(
|
|
1845
|
+
"/wp-json/wc/v3/data/currencies/current",
|
|
1846
|
+
void 0,
|
|
1847
|
+
["woocommerce", "data", "currency_current"]
|
|
1848
|
+
);
|
|
1849
|
+
}
|
|
1850
|
+
async function getCurrencyByCode(code) {
|
|
1851
|
+
return wcFetch(
|
|
1852
|
+
`/wp-json/wc/v3/data/currencies/${code.toUpperCase()}`,
|
|
1853
|
+
void 0,
|
|
1854
|
+
["woocommerce", "data", `currency-${code}`]
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
async function getContinents() {
|
|
1858
|
+
return wcFetchGraceful(
|
|
1859
|
+
"/wp-json/wc/v3/data/continents",
|
|
1860
|
+
[],
|
|
1861
|
+
void 0,
|
|
1862
|
+
["woocommerce", "data", "continents"]
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
async function getContinentByCode(code) {
|
|
1866
|
+
return wcFetch(
|
|
1867
|
+
`/wp-json/wc/v3/data/continents/${code.toUpperCase()}`,
|
|
1868
|
+
void 0,
|
|
1869
|
+
["woocommerce", "data", `continent-${code}`]
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1872
|
+
async function getCountries() {
|
|
1873
|
+
return wcFetchGraceful(
|
|
1874
|
+
"/wp-json/wc/v3/data/countries",
|
|
1875
|
+
[],
|
|
1876
|
+
void 0,
|
|
1877
|
+
["woocommerce", "data", "countries"]
|
|
1878
|
+
);
|
|
1879
|
+
}
|
|
1880
|
+
async function getCountryByCode(code) {
|
|
1881
|
+
return wcFetch(
|
|
1882
|
+
`/wp-json/wc/v3/data/countries/${code.toUpperCase()}`,
|
|
1883
|
+
void 0,
|
|
1884
|
+
["woocommerce", "data", `country-${code}`]
|
|
1885
|
+
);
|
|
1886
|
+
}
|
|
1887
|
+
async function getTimeZones() {
|
|
1888
|
+
return wcFetchGraceful(
|
|
1889
|
+
"/wp-json/wc/v3/data/time_zones",
|
|
1890
|
+
{},
|
|
1891
|
+
void 0,
|
|
1892
|
+
["woocommerce", "data", "time_zones"]
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
async function getSystemStatus() {
|
|
1896
|
+
return wcFetch(
|
|
1897
|
+
"/wp-json/wc/v3/system_status",
|
|
1898
|
+
void 0,
|
|
1899
|
+
["woocommerce", "system_status"]
|
|
1900
|
+
);
|
|
1901
|
+
}
|
|
1902
|
+
async function getSystemStatusTools() {
|
|
1903
|
+
return wcFetchGraceful(
|
|
1904
|
+
"/wp-json/wc/v3/system_status/tools",
|
|
1905
|
+
[],
|
|
1906
|
+
void 0,
|
|
1907
|
+
["woocommerce", "system_status_tools"]
|
|
1908
|
+
);
|
|
1909
|
+
}
|
|
1910
|
+
async function runSystemStatusTool(toolId) {
|
|
1911
|
+
return wcMutate(
|
|
1912
|
+
`/wp-json/wc/v3/system_status/tools/${toolId}`,
|
|
1913
|
+
{},
|
|
1914
|
+
"PUT"
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1917
|
+
return {
|
|
1918
|
+
getCurrencies,
|
|
1919
|
+
getCurrentCurrency,
|
|
1920
|
+
getCurrencyByCode,
|
|
1921
|
+
getContinents,
|
|
1922
|
+
getContinentByCode,
|
|
1923
|
+
getCountries,
|
|
1924
|
+
getCountryByCode,
|
|
1925
|
+
getTimeZones,
|
|
1926
|
+
getSystemStatus,
|
|
1927
|
+
getSystemStatusTools,
|
|
1928
|
+
runSystemStatusTool
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1212
1932
|
// src/integrations/restApi/woocommerce/index.ts
|
|
1213
1933
|
function createWooCommerceClient(config) {
|
|
1214
1934
|
const fetcher = createWooCommerceFetcher(config);
|
|
@@ -1220,9 +1940,21 @@ function createWooCommerceClient(config) {
|
|
|
1220
1940
|
...createTagsQueries2(fetcher),
|
|
1221
1941
|
...createTagsMutations2(fetcher),
|
|
1222
1942
|
...createOrdersQueries(fetcher),
|
|
1943
|
+
...createOrderNotesQueries(fetcher),
|
|
1944
|
+
...createOrderRefundsQueries(fetcher),
|
|
1945
|
+
...createProductAttributesQueries(fetcher),
|
|
1946
|
+
...createProductReviewsQueries(fetcher),
|
|
1947
|
+
...createShippingClassesQueries(fetcher),
|
|
1948
|
+
...createTaxesQueries(fetcher),
|
|
1949
|
+
...createShippingQueries(fetcher),
|
|
1950
|
+
...createWebhooksQueries(fetcher),
|
|
1951
|
+
...createSettingsQueries(fetcher),
|
|
1952
|
+
...createReportsQueries(fetcher),
|
|
1953
|
+
...createDataQueries(fetcher),
|
|
1223
1954
|
...createCouponsQueries(fetcher),
|
|
1224
1955
|
...createCouponsMutations(fetcher),
|
|
1225
|
-
...createCustomersQueries(fetcher)
|
|
1956
|
+
...createCustomersQueries(fetcher),
|
|
1957
|
+
...createPaymentGatewaysQueries(fetcher)
|
|
1226
1958
|
};
|
|
1227
1959
|
}
|
|
1228
1960
|
|
|
@@ -1239,9 +1971,9 @@ var WPGraphQLError = class extends Error {
|
|
|
1239
1971
|
|
|
1240
1972
|
// src/integrations/wpGraphQL/client/fetcher.ts
|
|
1241
1973
|
var USER_AGENT3 = "NextWordpress WPGraphQL Client";
|
|
1242
|
-
var CACHE_TTL = 300;
|
|
1243
1974
|
function createWPGraphQLFetcher(config) {
|
|
1244
1975
|
const url = `${resolveBaseUrl(config)}/graphql`;
|
|
1976
|
+
const cacheTTL = config.cacheTTL ?? 300;
|
|
1245
1977
|
async function gqlFetch(document, variables, tags = ["wpgraphql"]) {
|
|
1246
1978
|
const response = await fetch(url, {
|
|
1247
1979
|
method: "POST",
|
|
@@ -1250,7 +1982,7 @@ function createWPGraphQLFetcher(config) {
|
|
|
1250
1982
|
"User-Agent": USER_AGENT3
|
|
1251
1983
|
},
|
|
1252
1984
|
body: JSON.stringify({ query: document, variables }),
|
|
1253
|
-
next: { tags, revalidate:
|
|
1985
|
+
next: { tags, revalidate: cacheTTL }
|
|
1254
1986
|
});
|
|
1255
1987
|
if (!response.ok) {
|
|
1256
1988
|
throw new WPGraphQLError(
|