@szymonpiatek/nextwordpress 0.0.14 → 0.0.16

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
@@ -39,6 +39,8 @@ var ErrorCode = {
39
39
  AUTH_JWT_FAILED: "AUTH_JWT_FAILED",
40
40
  AUTH_CREDENTIALS_INVALID: "AUTH_CREDENTIALS_INVALID",
41
41
  AUTH_TOKEN_INVALID: "AUTH_TOKEN_INVALID",
42
+ AUTH_PASSWORD_RESET_REQUESTED: "AUTH_PASSWORD_RESET_REQUESTED",
43
+ AUTH_PASSWORD_RESET_FAILED: "AUTH_PASSWORD_RESET_FAILED",
42
44
  // Contact Form 7
43
45
  CF7_MAIL_SENT: "CF7_MAIL_SENT",
44
46
  CF7_MAIL_FAILED: "CF7_MAIL_FAILED",
@@ -70,6 +72,8 @@ var defaultMessages = {
70
72
  AUTH_JWT_FAILED: "JWT authentication failed",
71
73
  AUTH_CREDENTIALS_INVALID: "Invalid credentials",
72
74
  AUTH_TOKEN_INVALID: "JWT token is invalid or expired",
75
+ AUTH_PASSWORD_RESET_REQUESTED: "Password reset email sent. Check your inbox.",
76
+ AUTH_PASSWORD_RESET_FAILED: "Password reset failed. The link may be invalid or expired.",
73
77
  CF7_MAIL_SENT: "Thank you for your message.",
74
78
  CF7_MAIL_FAILED: "There was an error trying to send your message.",
75
79
  CF7_VALIDATION_FAILED: "One or more fields have an error. Please check and try again.",
@@ -100,6 +104,8 @@ var defaultMessagesPl = {
100
104
  AUTH_JWT_FAILED: "B\u0142\u0105d uwierzytelnienia JWT",
101
105
  AUTH_CREDENTIALS_INVALID: "Nieprawid\u0142owe dane logowania",
102
106
  AUTH_TOKEN_INVALID: "Token JWT jest nieprawid\u0142owy lub wygas\u0142",
107
+ AUTH_PASSWORD_RESET_REQUESTED: "E-mail z resetowaniem has\u0142a zosta\u0142 wys\u0142any. Sprawd\u017A skrzynk\u0119.",
108
+ AUTH_PASSWORD_RESET_FAILED: "Resetowanie has\u0142a nie powiod\u0142o si\u0119. Link mo\u017Ce by\u0107 nieprawid\u0142owy lub wygas\u0142.",
103
109
  CF7_MAIL_SENT: "Dzi\u0119kujemy za wiadomo\u015B\u0107.",
104
110
  CF7_MAIL_FAILED: "Wyst\u0105pi\u0142 b\u0142\u0105d podczas wysy\u0142ania wiadomo\u015Bci.",
105
111
  CF7_VALIDATION_FAILED: "Jedno lub wi\u0119cej p\xF3l zawiera b\u0142\u0105d. Sprawd\u017A i spr\xF3buj ponownie.",
@@ -2135,7 +2141,25 @@ function createWPULikeClient(config) {
2135
2141
  return createWPULikeQueries(fetcher);
2136
2142
  }
2137
2143
 
2144
+ // src/integrations/restApi/contactForm7/types.ts
2145
+ var CF7Error = class extends Error {
2146
+ constructor(code, status, endpoint, message) {
2147
+ super(message);
2148
+ __publicField(this, "code", code);
2149
+ __publicField(this, "status", status);
2150
+ __publicField(this, "endpoint", endpoint);
2151
+ this.name = "CF7Error";
2152
+ }
2153
+ };
2154
+
2138
2155
  // src/integrations/restApi/contactForm7/queries.ts
2156
+ var statusToCode = {
2157
+ mail_sent: ErrorCode.CF7_MAIL_SENT,
2158
+ mail_failed: ErrorCode.CF7_MAIL_FAILED,
2159
+ validation_failed: ErrorCode.CF7_VALIDATION_FAILED,
2160
+ spam: ErrorCode.CF7_SPAM,
2161
+ aborted: ErrorCode.CF7_ABORTED
2162
+ };
2139
2163
  function createCF7Queries(config) {
2140
2164
  async function submitForm(formId, data) {
2141
2165
  const url = buildUrl(config, `/wp-json/contact-form-7/v1/contact-forms/${formId}/feedback`);
@@ -2144,7 +2168,17 @@ function createCF7Queries(config) {
2144
2168
  body.append(key, value);
2145
2169
  }
2146
2170
  const res = await fetch(url, { method: "POST", body, cache: "no-store" });
2147
- return res.json();
2171
+ if (!res.ok) {
2172
+ throw new CF7Error(
2173
+ ErrorCode.CF7_MAIL_FAILED,
2174
+ res.status,
2175
+ url,
2176
+ resolveMessage(ErrorCode.CF7_MAIL_FAILED, config.errorMessages)
2177
+ );
2178
+ }
2179
+ const result = await res.json();
2180
+ const code = statusToCode[result.status];
2181
+ return { ...result, message: resolveMessage(code, config.errorMessages) };
2148
2182
  }
2149
2183
  return { submitForm };
2150
2184
  }
@@ -3360,6 +3394,41 @@ function createMediaMutations2(fetcher) {
3360
3394
  return { createMediaItem, updateMediaItem, deleteMediaItem };
3361
3395
  }
3362
3396
 
3397
+ // src/integrations/wpGraphQL/core/mutations/passwordReset/mutations.ts
3398
+ var GQL_SEND_PASSWORD_RESET_EMAIL = `
3399
+ mutation SendPasswordResetEmail($input: SendPasswordResetEmailInput!) {
3400
+ sendPasswordResetEmail(input: $input) {
3401
+ success
3402
+ user {
3403
+ email
3404
+ }
3405
+ }
3406
+ }
3407
+ `;
3408
+ var GQL_RESET_USER_PASSWORD = `
3409
+ mutation ResetUserPassword($input: ResetUserPasswordInput!) {
3410
+ resetUserPassword(input: $input) {
3411
+ user {
3412
+ id
3413
+ databaseId
3414
+ email
3415
+ }
3416
+ }
3417
+ }
3418
+ `;
3419
+ function createPasswordResetMutations(fetcher) {
3420
+ const { gqlMutate } = fetcher;
3421
+ async function sendPasswordResetEmail(input) {
3422
+ const data = await gqlMutate(GQL_SEND_PASSWORD_RESET_EMAIL, { input });
3423
+ return data.sendPasswordResetEmail;
3424
+ }
3425
+ async function resetUserPassword(input) {
3426
+ const data = await gqlMutate(GQL_RESET_USER_PASSWORD, { input });
3427
+ return data.resetUserPassword;
3428
+ }
3429
+ return { sendPasswordResetEmail, resetUserPassword };
3430
+ }
3431
+
3363
3432
  // src/integrations/wpGraphQL/core/mutations/index.ts
3364
3433
  function createWPGraphQLMutationsClient(config) {
3365
3434
  const fetcher = createWPGraphQLFetcher(config);
@@ -3370,7 +3439,8 @@ function createWPGraphQLMutationsClient(config) {
3370
3439
  ...createCategoriesMutations3(fetcher),
3371
3440
  ...createTagsMutations3(fetcher),
3372
3441
  ...createAuthorsMutations2(fetcher),
3373
- ...createMediaMutations2(fetcher)
3442
+ ...createMediaMutations2(fetcher),
3443
+ ...createPasswordResetMutations(fetcher)
3374
3444
  };
3375
3445
  }
3376
3446
 
@@ -4330,6 +4400,7 @@ async function validateJwtToken(config, token) {
4330
4400
  }
4331
4401
 
4332
4402
  exports.AuthenticationError = AuthenticationError;
4403
+ exports.CF7Error = CF7Error;
4333
4404
  exports.ErrorCode = ErrorCode;
4334
4405
  exports.WPGraphQLError = WPGraphQLError;
4335
4406
  exports.WooCommerceError = WooCommerceError;