@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.
package/dist/index.cjs CHANGED
@@ -309,6 +309,26 @@ function createMediaMutations(fetcher) {
309
309
  return { uploadMedia, updateMedia, deleteMedia };
310
310
  }
311
311
 
312
+ // src/integrations/restApi/core/mutations/passwordReset/mutations.ts
313
+ function createPasswordResetMutations(fetcher) {
314
+ const { wpMutate } = fetcher;
315
+ async function sendPasswordResetEmail(input) {
316
+ return wpMutate(
317
+ "/wp-json/wp/v2/users/lost-password",
318
+ input,
319
+ "POST"
320
+ );
321
+ }
322
+ async function resetUserPassword(input) {
323
+ return wpMutate(
324
+ "/wp-json/wp/v2/users/reset-password",
325
+ input,
326
+ "POST"
327
+ );
328
+ }
329
+ return { sendPasswordResetEmail, resetUserPassword };
330
+ }
331
+
312
332
  // src/integrations/restApi/core/client/types.ts
313
333
  var WordPressAPIError = class extends Error {
314
334
  constructor(code, status, endpoint, message, detail) {
@@ -443,7 +463,8 @@ function createWordPressMutationsClient(config) {
443
463
  ...createTagsMutations(fetcher),
444
464
  ...createAuthorsMutations(fetcher),
445
465
  ...createMenusMutations(fetcher),
446
- ...createMediaMutations(fetcher)
466
+ ...createMediaMutations(fetcher),
467
+ ...createPasswordResetMutations(fetcher)
447
468
  };
448
469
  }
449
470
 
@@ -3399,9 +3420,6 @@ var GQL_SEND_PASSWORD_RESET_EMAIL = `
3399
3420
  mutation SendPasswordResetEmail($input: SendPasswordResetEmailInput!) {
3400
3421
  sendPasswordResetEmail(input: $input) {
3401
3422
  success
3402
- user {
3403
- email
3404
- }
3405
3423
  }
3406
3424
  }
3407
3425
  `;
@@ -3416,11 +3434,15 @@ var GQL_RESET_USER_PASSWORD = `
3416
3434
  }
3417
3435
  }
3418
3436
  `;
3419
- function createPasswordResetMutations(fetcher) {
3437
+ function createPasswordResetMutations2(fetcher) {
3420
3438
  const { gqlMutate } = fetcher;
3421
3439
  async function sendPasswordResetEmail(input) {
3422
3440
  const data = await gqlMutate(GQL_SEND_PASSWORD_RESET_EMAIL, { input });
3423
- return data.sendPasswordResetEmail;
3441
+ const result = data.sendPasswordResetEmail;
3442
+ if (!result.success) {
3443
+ throw new WPGraphQLError(ErrorCode.GQL_ERRORS_IN_RESPONSE, 200, "sendPasswordResetEmail", "User not found");
3444
+ }
3445
+ return result;
3424
3446
  }
3425
3447
  async function resetUserPassword(input) {
3426
3448
  const data = await gqlMutate(GQL_RESET_USER_PASSWORD, { input });
@@ -3440,7 +3462,7 @@ function createWPGraphQLMutationsClient(config) {
3440
3462
  ...createTagsMutations3(fetcher),
3441
3463
  ...createAuthorsMutations2(fetcher),
3442
3464
  ...createMediaMutations2(fetcher),
3443
- ...createPasswordResetMutations(fetcher)
3465
+ ...createPasswordResetMutations2(fetcher)
3444
3466
  };
3445
3467
  }
3446
3468