@szymonpiatek/nextwordpress 0.0.19 → 0.0.21
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/client/index.cjs +142 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +140 -1
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +142 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +6 -2
- package/dist/hooks/index.d.ts +6 -2
- package/dist/hooks/index.js +140 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +138 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +135 -9
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +138 -8
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +135 -9
- package/dist/server/index.js.map +1 -1
- package/dist/{types-DUmH-vcl.d.cts → types-DmNIXJNR.d.cts} +45 -1
- package/dist/{types-DUmH-vcl.d.ts → types-DmNIXJNR.d.ts} +45 -1
- package/package.json +1 -1
package/dist/client/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats, useWishlist, useWishlists } from '../hooks/index.cjs';
|
|
1
|
+
export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useTIWishlistByShareKey, useTIWishlistProducts, useTIWishlistsByUser, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats, useWishlist, useWishlists } from '../hooks/index.cjs';
|
|
2
2
|
import 'react';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-DmNIXJNR.cjs';
|
|
4
4
|
import 'swr/mutation';
|
|
5
5
|
import 'swr';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats, useWishlist, useWishlists } from '../hooks/index.js';
|
|
1
|
+
export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useTIWishlistByShareKey, useTIWishlistProducts, useTIWishlistsByUser, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats, useWishlist, useWishlists } from '../hooks/index.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-DmNIXJNR.js';
|
|
4
4
|
import 'swr/mutation';
|
|
5
5
|
import 'swr';
|
package/dist/client/index.js
CHANGED
|
@@ -1428,6 +1428,145 @@ function useWishlist(config, wishlistToken, swrOptions) {
|
|
|
1428
1428
|
);
|
|
1429
1429
|
}
|
|
1430
1430
|
|
|
1431
|
+
// src/integrations/restApi/woocommerce/ti_wishlist/fetcher.ts
|
|
1432
|
+
var USER_AGENT5 = "NextWordpress TI Wishlist Client";
|
|
1433
|
+
var DEFAULT_CACHE_TTL3 = 3600;
|
|
1434
|
+
var TIWishlistError = class extends Error {
|
|
1435
|
+
constructor(code, status, url, message) {
|
|
1436
|
+
super(message);
|
|
1437
|
+
__publicField(this, "code", code);
|
|
1438
|
+
__publicField(this, "status", status);
|
|
1439
|
+
__publicField(this, "url", url);
|
|
1440
|
+
this.name = "TIWishlistError";
|
|
1441
|
+
}
|
|
1442
|
+
};
|
|
1443
|
+
function resolveTIErrorCode(status) {
|
|
1444
|
+
if (status === 401) return ErrorCode.WOO_UNAUTHORIZED;
|
|
1445
|
+
if (status === 403) return ErrorCode.WOO_FORBIDDEN;
|
|
1446
|
+
if (status === 404) return ErrorCode.WOO_WISHLIST_NOT_FOUND;
|
|
1447
|
+
return ErrorCode.WOO_REQUEST_FAILED;
|
|
1448
|
+
}
|
|
1449
|
+
function createTIWishlistFetcher(config) {
|
|
1450
|
+
const cacheTTL = config.cacheTTL ?? DEFAULT_CACHE_TTL3;
|
|
1451
|
+
function buildUrl2(path) {
|
|
1452
|
+
const base = typeof window !== "undefined" && config.clientURL ? config.clientURL : config.serverURL;
|
|
1453
|
+
return `${base}${path}`;
|
|
1454
|
+
}
|
|
1455
|
+
function authHeaders() {
|
|
1456
|
+
return {
|
|
1457
|
+
"User-Agent": USER_AGENT5,
|
|
1458
|
+
"Content-Type": "application/json",
|
|
1459
|
+
Authorization: `Bearer ${config.token}`
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
async function throwTIError(response, url) {
|
|
1463
|
+
const errorCode = resolveTIErrorCode(response.status);
|
|
1464
|
+
throw new TIWishlistError(
|
|
1465
|
+
errorCode,
|
|
1466
|
+
response.status,
|
|
1467
|
+
url,
|
|
1468
|
+
resolveMessage(errorCode, config.errorMessages)
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
async function tiFetch(path, tags = ["ti-wishlist"], options) {
|
|
1472
|
+
const url = buildUrl2(path);
|
|
1473
|
+
const isMutation = options?.method && options.method !== "GET";
|
|
1474
|
+
const response = await fetch(url, {
|
|
1475
|
+
...options,
|
|
1476
|
+
headers: {
|
|
1477
|
+
...authHeaders(),
|
|
1478
|
+
...options?.headers
|
|
1479
|
+
},
|
|
1480
|
+
next: isMutation ? void 0 : { tags, revalidate: cacheTTL }
|
|
1481
|
+
});
|
|
1482
|
+
if (!response.ok) {
|
|
1483
|
+
await throwTIError(response, url);
|
|
1484
|
+
}
|
|
1485
|
+
return response.json();
|
|
1486
|
+
}
|
|
1487
|
+
async function tiFetchGraceful(path, fallback, tags = ["ti-wishlist"]) {
|
|
1488
|
+
try {
|
|
1489
|
+
return await tiFetch(path, tags);
|
|
1490
|
+
} catch (err) {
|
|
1491
|
+
console.warn(`TI Wishlist fetch failed for ${path}`, err);
|
|
1492
|
+
return fallback;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
async function tiMutate(path, body, method = "POST") {
|
|
1496
|
+
return tiFetch(path, ["ti-wishlist"], {
|
|
1497
|
+
method,
|
|
1498
|
+
body: JSON.stringify(body)
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
return { tiFetch, tiFetchGraceful, tiMutate };
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
// src/integrations/restApi/woocommerce/ti_wishlist/queries.ts
|
|
1505
|
+
var BASE2 = "/wp-json/wc/v3/wishlist";
|
|
1506
|
+
function createTIWishlistQueries(fetcher) {
|
|
1507
|
+
const { tiFetch, tiFetchGraceful } = fetcher;
|
|
1508
|
+
async function getWishlistsByUser(userId) {
|
|
1509
|
+
return tiFetchGraceful(
|
|
1510
|
+
`${BASE2}/get_by_user/${userId}`,
|
|
1511
|
+
[],
|
|
1512
|
+
["ti-wishlist", `ti-wishlists-user-${userId}`]
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
async function getWishlistByShareKey(shareKey) {
|
|
1516
|
+
return tiFetch(`${BASE2}/get_by_share_key/${shareKey}`, [
|
|
1517
|
+
"ti-wishlist",
|
|
1518
|
+
`ti-wishlist-${shareKey}`
|
|
1519
|
+
]);
|
|
1520
|
+
}
|
|
1521
|
+
async function getWishlistProducts(shareKey, params) {
|
|
1522
|
+
const query = new URLSearchParams();
|
|
1523
|
+
if (params?.count != null) query.set("count", String(params.count));
|
|
1524
|
+
if (params?.offset != null) query.set("offset", String(params.offset));
|
|
1525
|
+
if (params?.order != null) query.set("order", params.order);
|
|
1526
|
+
const qs = query.toString() ? `?${query.toString()}` : "";
|
|
1527
|
+
return tiFetch(`${BASE2}/${shareKey}/get_products${qs}`, [
|
|
1528
|
+
"ti-wishlist",
|
|
1529
|
+
`ti-wishlist-products-${shareKey}`
|
|
1530
|
+
]);
|
|
1531
|
+
}
|
|
1532
|
+
return { getWishlistsByUser, getWishlistByShareKey, getWishlistProducts };
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// src/hooks/woocommerce/useTIWishlist.ts
|
|
1536
|
+
function useTIWishlistsByUser(config, userId, swrOptions) {
|
|
1537
|
+
const key = ["ti-wishlists", config.serverURL, config.token, userId];
|
|
1538
|
+
return useSWR2(
|
|
1539
|
+
key,
|
|
1540
|
+
() => {
|
|
1541
|
+
const fetcher = createTIWishlistFetcher(config);
|
|
1542
|
+
return createTIWishlistQueries(fetcher).getWishlistsByUser(userId);
|
|
1543
|
+
},
|
|
1544
|
+
swrOptions
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
function useTIWishlistByShareKey(config, shareKey, swrOptions) {
|
|
1548
|
+
const key = shareKey != null ? ["ti-wishlist", config.serverURL, config.token, shareKey] : null;
|
|
1549
|
+
return useSWR2(
|
|
1550
|
+
key,
|
|
1551
|
+
() => {
|
|
1552
|
+
const fetcher = createTIWishlistFetcher(config);
|
|
1553
|
+
return createTIWishlistQueries(fetcher).getWishlistByShareKey(shareKey);
|
|
1554
|
+
},
|
|
1555
|
+
swrOptions
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
function useTIWishlistProducts(config, shareKey, params, swrOptions) {
|
|
1559
|
+
const key = shareKey != null ? ["ti-wishlist-products", config.serverURL, config.token, shareKey, params] : null;
|
|
1560
|
+
return useSWR2(
|
|
1561
|
+
key,
|
|
1562
|
+
() => {
|
|
1563
|
+
const fetcher = createTIWishlistFetcher(config);
|
|
1564
|
+
return createTIWishlistQueries(fetcher).getWishlistProducts(shareKey, params);
|
|
1565
|
+
},
|
|
1566
|
+
swrOptions
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1431
1570
|
// src/integrations/wpGraphQL/core/posts/queries.ts
|
|
1432
1571
|
var DEFAULT_FIRST = 10;
|
|
1433
1572
|
var BATCH_FIRST = 100;
|
|
@@ -1745,6 +1884,6 @@ function useCF7Submit(config) {
|
|
|
1745
1884
|
);
|
|
1746
1885
|
}
|
|
1747
1886
|
|
|
1748
|
-
export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats, useWishlist, useWishlists };
|
|
1887
|
+
export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useTIWishlistByShareKey, useTIWishlistProducts, useTIWishlistsByUser, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats, useWishlist, useWishlists };
|
|
1749
1888
|
//# sourceMappingURL=index.js.map
|
|
1750
1889
|
//# sourceMappingURL=index.js.map
|