@szymonpiatek/nextwordpress 0.0.16 → 0.0.18

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.
@@ -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, useSendPasswordResetEmail, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } 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, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.cjs';
2
2
  import 'react';
3
- import '../types-CvO7Ijbs.cjs';
3
+ import '../types-CM3v08Fh.cjs';
4
4
  import 'swr/mutation';
5
5
  import 'swr';
@@ -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, useSendPasswordResetEmail, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } 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, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.js';
2
2
  import 'react';
3
- import '../types-CvO7Ijbs.js';
3
+ import '../types-CM3v08Fh.js';
4
4
  import 'swr/mutation';
5
5
  import 'swr';
@@ -305,9 +305,6 @@ var GQL_SEND_PASSWORD_RESET_EMAIL = `
305
305
  mutation SendPasswordResetEmail($input: SendPasswordResetEmailInput!) {
306
306
  sendPasswordResetEmail(input: $input) {
307
307
  success
308
- user {
309
- email
310
- }
311
308
  }
312
309
  }
313
310
  `;
@@ -326,7 +323,11 @@ function createPasswordResetMutations(fetcher) {
326
323
  const { gqlMutate } = fetcher;
327
324
  async function sendPasswordResetEmail(input) {
328
325
  const data = await gqlMutate(GQL_SEND_PASSWORD_RESET_EMAIL, { input });
329
- return data.sendPasswordResetEmail;
326
+ const result = data.sendPasswordResetEmail;
327
+ if (!result.success) {
328
+ throw new WPGraphQLError(ErrorCode.GQL_ERRORS_IN_RESPONSE, 200, "sendPasswordResetEmail", "User not found");
329
+ }
330
+ return result;
330
331
  }
331
332
  async function resetUserPassword(input) {
332
333
  const data = await gqlMutate(GQL_RESET_USER_PASSWORD, { input });
@@ -358,44 +359,6 @@ function useResetUserPassword(config) {
358
359
  }
359
360
  );
360
361
  }
361
- function readConsentFromDocument(cookieName) {
362
- if (typeof document === "undefined") return null;
363
- const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
364
- if (!match) return null;
365
- if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
366
- try {
367
- const parsed = JSON.parse(decodeURIComponent(match[1]));
368
- if (typeof parsed !== "object" || parsed === null) return null;
369
- return parsed;
370
- } catch {
371
- return null;
372
- }
373
- }
374
- function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
375
- const [consent, setConsentState] = useState(null);
376
- const [isLoaded, setIsLoaded] = useState(false);
377
- useEffect(() => {
378
- setConsentState(readConsentFromDocument(cookieName));
379
- setIsLoaded(true);
380
- }, [cookieName]);
381
- const setConsent = useCallback(
382
- async (categories) => {
383
- const res = await fetch(consentPath, {
384
- method: "POST",
385
- headers: { "Content-Type": "application/json" },
386
- body: JSON.stringify(categories)
387
- });
388
- const data = await res.json();
389
- setConsentState(data);
390
- },
391
- [consentPath]
392
- );
393
- const clearConsent = useCallback(async () => {
394
- await fetch(consentPath, { method: "DELETE" });
395
- setConsentState(null);
396
- }, [consentPath]);
397
- return { consent, isLoaded, setConsent, clearConsent };
398
- }
399
362
 
400
363
  // src/integrations/restApi/core/client/types.ts
401
364
  var WordPressAPIError = class extends Error {
@@ -520,6 +483,88 @@ function createFetcher(config) {
520
483
  return { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful, wpMutate, wpUpload };
521
484
  }
522
485
 
486
+ // src/integrations/restApi/core/mutations/passwordReset/mutations.ts
487
+ function createPasswordResetMutations2(fetcher) {
488
+ const { wpMutate } = fetcher;
489
+ async function sendPasswordResetEmail(input) {
490
+ return wpMutate(
491
+ "/wp-json/wp/v2/users/lost-password",
492
+ input,
493
+ "POST"
494
+ );
495
+ }
496
+ async function resetUserPassword(input) {
497
+ return wpMutate(
498
+ "/wp-json/wp/v2/users/reset-password",
499
+ input,
500
+ "POST"
501
+ );
502
+ }
503
+ return { sendPasswordResetEmail, resetUserPassword };
504
+ }
505
+
506
+ // src/hooks/auth/useSendPasswordResetEmailRest.ts
507
+ function useSendPasswordResetEmailRest(config) {
508
+ return useSWRMutation(
509
+ `send-password-reset-rest:${config.serverURL}`,
510
+ async (_, { arg }) => {
511
+ return createPasswordResetMutations2(createFetcher(config)).sendPasswordResetEmail({
512
+ username: arg.username
513
+ });
514
+ }
515
+ );
516
+ }
517
+ function useResetUserPasswordRest(config) {
518
+ return useSWRMutation(
519
+ `reset-user-password-rest:${config.serverURL}`,
520
+ async (_, { arg }) => {
521
+ return createPasswordResetMutations2(createFetcher(config)).resetUserPassword({
522
+ key: arg.key,
523
+ login: arg.login,
524
+ password: arg.password
525
+ });
526
+ }
527
+ );
528
+ }
529
+ function readConsentFromDocument(cookieName) {
530
+ if (typeof document === "undefined") return null;
531
+ const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
532
+ if (!match) return null;
533
+ if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
534
+ try {
535
+ const parsed = JSON.parse(decodeURIComponent(match[1]));
536
+ if (typeof parsed !== "object" || parsed === null) return null;
537
+ return parsed;
538
+ } catch {
539
+ return null;
540
+ }
541
+ }
542
+ function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
543
+ const [consent, setConsentState] = useState(null);
544
+ const [isLoaded, setIsLoaded] = useState(false);
545
+ useEffect(() => {
546
+ setConsentState(readConsentFromDocument(cookieName));
547
+ setIsLoaded(true);
548
+ }, [cookieName]);
549
+ const setConsent = useCallback(
550
+ async (categories) => {
551
+ const res = await fetch(consentPath, {
552
+ method: "POST",
553
+ headers: { "Content-Type": "application/json" },
554
+ body: JSON.stringify(categories)
555
+ });
556
+ const data = await res.json();
557
+ setConsentState(data);
558
+ },
559
+ [consentPath]
560
+ );
561
+ const clearConsent = useCallback(async () => {
562
+ await fetch(consentPath, { method: "DELETE" });
563
+ setConsentState(null);
564
+ }, [consentPath]);
565
+ return { consent, isLoaded, setConsent, clearConsent };
566
+ }
567
+
523
568
  // src/integrations/restApi/core/posts/queries.ts
524
569
  function createPostsQueries(fetcher) {
525
570
  const { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful } = fetcher;
@@ -1576,6 +1621,6 @@ function useCF7Submit(config) {
1576
1621
  );
1577
1622
  }
1578
1623
 
1579
- export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useSendPasswordResetEmail, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats };
1624
+ 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 };
1580
1625
  //# sourceMappingURL=index.js.map
1581
1626
  //# sourceMappingURL=index.js.map