@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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NextWordpressConfig, J as JwtAuthCredentials, t as JwtAuthResponse, W as WPGraphQLConfig, c as WooCommerceConfig, f as WooCommerceResponse, b as WordPressResponse, T as Taxonomy, u as WPEntity, R as RenderedTitle, v as RenderedContent, P as Post, A as Author, F as FeaturedMedia, w as WCImage, x as WCProductVariation, d as WCProduct, i as WCCustomer, y as WCAddress, U as UpdateCustomerInput, g as WCCreateOrderInput, h as WCOrder, e as WCProductFilterParams, m as WPULikeStatsParams, n as WPULikeStats, q as WPULikeCheckParams, r as WPULikeCheckResponse, z as WPULikeVoteParams, p as WPULikeVoteResponse, s as CF7SubmissionResponse, B as GQLSendPasswordResetEmailInput, G as GQLSendPasswordResetEmailResult, D as GQLResetUserPasswordInput, a as GQLResetUserPasswordResult, l as GQLConnection, k as GQLPostFilter, j as GQLPost } from './types-CvO7Ijbs.cjs';
2
- export { E as AuthenticationError, H as BlockType, I as CF7Error, K as CF7SubmissionStatus, L as CF7ValidationError, C as CookieConsentCategories, M as CookieConsentConfig, O as EditorBlock, Q as EmbeddedAuthor, S as EmbeddedTerm, V as ErrorCode, X as GQLError, Y as GQLPageInfo, Z as MediaDetails, _ as MediaSize, $ as PostEmbedded, a0 as SearchResult, a1 as TemplatePart, a2 as WCDimensions, a3 as WCOrderLineItem, a4 as WCProductAttribute, a5 as WCProductDefaultAttribute, a6 as WCShippingLine, a7 as WPGraphQLError, a8 as WPULikeItemType, o as WPULikeStatus, a9 as WooCommerceError, aa as WooCommercePaginationHeaders, ab as WordPressAPIError, ac as createCookieConsentHandler, ad as defaultMessages, ae as defaultMessagesPl, af as parseCookieConsent, ag as resolveMessage } from './types-CvO7Ijbs.cjs';
1
+ import { N as NextWordpressConfig, J as JwtAuthCredentials, u as JwtAuthResponse, W as WPGraphQLConfig, c as WordPressResponse, d as WooCommerceConfig, g as WooCommerceResponse, T as Taxonomy, v as WPEntity, w as RenderedTitle, x as RenderedContent, P as Post, A as Author, F as FeaturedMedia, y as RestSendPasswordResetEmailInput, R as RestSendPasswordResetEmailResult, z as RestResetUserPasswordInput, b as RestResetUserPasswordResult, B as WCImage, D as WCProductVariation, e as WCProduct, j as WCCustomer, E as WCAddress, U as UpdateCustomerInput, h as WCCreateOrderInput, i as WCOrder, f as WCProductFilterParams, n as WPULikeStatsParams, o as WPULikeStats, r as WPULikeCheckParams, s as WPULikeCheckResponse, H as WPULikeVoteParams, q as WPULikeVoteResponse, t as CF7SubmissionResponse, I as GQLSendPasswordResetEmailInput, G as GQLSendPasswordResetEmailResult, K as GQLResetUserPasswordInput, a as GQLResetUserPasswordResult, m as GQLConnection, l as GQLPostFilter, k as GQLPost } from './types-CM3v08Fh.cjs';
2
+ export { L as AuthenticationError, M as BlockType, O as CF7Error, Q as CF7SubmissionStatus, S as CF7ValidationError, C as CookieConsentCategories, V as CookieConsentConfig, X as EditorBlock, Y as EmbeddedAuthor, Z as EmbeddedTerm, _ as ErrorCode, $ as GQLError, a0 as GQLPageInfo, a1 as MediaDetails, a2 as MediaSize, a3 as PostEmbedded, a4 as SearchResult, a5 as TemplatePart, a6 as WCDimensions, a7 as WCOrderLineItem, a8 as WCProductAttribute, a9 as WCProductDefaultAttribute, aa as WCShippingLine, ab as WPGraphQLError, ac as WPULikeItemType, p as WPULikeStatus, ad as WooCommerceError, ae as WooCommercePaginationHeaders, af as WordPressAPIError, ag as createCookieConsentHandler, ah as defaultMessages, ai as defaultMessagesPl, aj as parseCookieConsent, ak as resolveMessage } from './types-CM3v08Fh.cjs';
3
3
 
4
4
  declare function createApplicationPasswordToken(username: string, appPassword: string): string;
5
5
 
@@ -15,15 +15,6 @@ declare function createWPGraphQLFetcher(config: WPGraphQLConfig): {
15
15
  };
16
16
  type WPGraphQLFetcher = ReturnType<typeof createWPGraphQLFetcher>;
17
17
 
18
- declare function createWooCommerceFetcher(config: WooCommerceConfig): {
19
- wcFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[], options?: RequestInit) => Promise<T>;
20
- wcFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
21
- wcFetchPaginated: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
22
- wcFetchPaginatedGraceful: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
23
- wcMutate: <T>(path: string, body: unknown, method?: "POST" | "PUT" | "PATCH" | "DELETE") => Promise<T>;
24
- };
25
- type WooCommerceFetcher = ReturnType<typeof createWooCommerceFetcher>;
26
-
27
18
  declare function createFetcher(config: NextWordpressConfig): {
28
19
  wpFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
29
20
  wpFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
@@ -34,6 +25,15 @@ declare function createFetcher(config: NextWordpressConfig): {
34
25
  };
35
26
  type WordPressFetcher = ReturnType<typeof createFetcher>;
36
27
 
28
+ declare function createWooCommerceFetcher(config: WooCommerceConfig): {
29
+ wcFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[], options?: RequestInit) => Promise<T>;
30
+ wcFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
31
+ wcFetchPaginated: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
32
+ wcFetchPaginatedGraceful: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
33
+ wcMutate: <T>(path: string, body: unknown, method?: "POST" | "PUT" | "PATCH" | "DELETE") => Promise<T>;
34
+ };
35
+ type WooCommerceFetcher = ReturnType<typeof createWooCommerceFetcher>;
36
+
37
37
  interface Category extends Taxonomy {
38
38
  taxonomy: 'category';
39
39
  parent: number;
@@ -337,6 +337,8 @@ declare function createMediaMutations(fetcher: WordPressFetcher): {
337
337
  };
338
338
 
339
339
  declare function createWordPressMutationsClient(config: NextWordpressConfig): {
340
+ sendPasswordResetEmail: (input: RestSendPasswordResetEmailInput) => Promise<RestSendPasswordResetEmailResult>;
341
+ resetUserPassword: (input: RestResetUserPasswordInput) => Promise<RestResetUserPasswordResult>;
340
342
  uploadMedia: (input: UploadMediaInput, authToken: string) => Promise<FeaturedMedia>;
341
343
  updateMedia: (id: number, input: UpdateMediaInput, authToken: string) => Promise<FeaturedMedia>;
342
344
  deleteMedia: (id: number, authToken: string, force?: boolean) => Promise<{
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NextWordpressConfig, J as JwtAuthCredentials, t as JwtAuthResponse, W as WPGraphQLConfig, c as WooCommerceConfig, f as WooCommerceResponse, b as WordPressResponse, T as Taxonomy, u as WPEntity, R as RenderedTitle, v as RenderedContent, P as Post, A as Author, F as FeaturedMedia, w as WCImage, x as WCProductVariation, d as WCProduct, i as WCCustomer, y as WCAddress, U as UpdateCustomerInput, g as WCCreateOrderInput, h as WCOrder, e as WCProductFilterParams, m as WPULikeStatsParams, n as WPULikeStats, q as WPULikeCheckParams, r as WPULikeCheckResponse, z as WPULikeVoteParams, p as WPULikeVoteResponse, s as CF7SubmissionResponse, B as GQLSendPasswordResetEmailInput, G as GQLSendPasswordResetEmailResult, D as GQLResetUserPasswordInput, a as GQLResetUserPasswordResult, l as GQLConnection, k as GQLPostFilter, j as GQLPost } from './types-CvO7Ijbs.js';
2
- export { E as AuthenticationError, H as BlockType, I as CF7Error, K as CF7SubmissionStatus, L as CF7ValidationError, C as CookieConsentCategories, M as CookieConsentConfig, O as EditorBlock, Q as EmbeddedAuthor, S as EmbeddedTerm, V as ErrorCode, X as GQLError, Y as GQLPageInfo, Z as MediaDetails, _ as MediaSize, $ as PostEmbedded, a0 as SearchResult, a1 as TemplatePart, a2 as WCDimensions, a3 as WCOrderLineItem, a4 as WCProductAttribute, a5 as WCProductDefaultAttribute, a6 as WCShippingLine, a7 as WPGraphQLError, a8 as WPULikeItemType, o as WPULikeStatus, a9 as WooCommerceError, aa as WooCommercePaginationHeaders, ab as WordPressAPIError, ac as createCookieConsentHandler, ad as defaultMessages, ae as defaultMessagesPl, af as parseCookieConsent, ag as resolveMessage } from './types-CvO7Ijbs.js';
1
+ import { N as NextWordpressConfig, J as JwtAuthCredentials, u as JwtAuthResponse, W as WPGraphQLConfig, c as WordPressResponse, d as WooCommerceConfig, g as WooCommerceResponse, T as Taxonomy, v as WPEntity, w as RenderedTitle, x as RenderedContent, P as Post, A as Author, F as FeaturedMedia, y as RestSendPasswordResetEmailInput, R as RestSendPasswordResetEmailResult, z as RestResetUserPasswordInput, b as RestResetUserPasswordResult, B as WCImage, D as WCProductVariation, e as WCProduct, j as WCCustomer, E as WCAddress, U as UpdateCustomerInput, h as WCCreateOrderInput, i as WCOrder, f as WCProductFilterParams, n as WPULikeStatsParams, o as WPULikeStats, r as WPULikeCheckParams, s as WPULikeCheckResponse, H as WPULikeVoteParams, q as WPULikeVoteResponse, t as CF7SubmissionResponse, I as GQLSendPasswordResetEmailInput, G as GQLSendPasswordResetEmailResult, K as GQLResetUserPasswordInput, a as GQLResetUserPasswordResult, m as GQLConnection, l as GQLPostFilter, k as GQLPost } from './types-CM3v08Fh.js';
2
+ export { L as AuthenticationError, M as BlockType, O as CF7Error, Q as CF7SubmissionStatus, S as CF7ValidationError, C as CookieConsentCategories, V as CookieConsentConfig, X as EditorBlock, Y as EmbeddedAuthor, Z as EmbeddedTerm, _ as ErrorCode, $ as GQLError, a0 as GQLPageInfo, a1 as MediaDetails, a2 as MediaSize, a3 as PostEmbedded, a4 as SearchResult, a5 as TemplatePart, a6 as WCDimensions, a7 as WCOrderLineItem, a8 as WCProductAttribute, a9 as WCProductDefaultAttribute, aa as WCShippingLine, ab as WPGraphQLError, ac as WPULikeItemType, p as WPULikeStatus, ad as WooCommerceError, ae as WooCommercePaginationHeaders, af as WordPressAPIError, ag as createCookieConsentHandler, ah as defaultMessages, ai as defaultMessagesPl, aj as parseCookieConsent, ak as resolveMessage } from './types-CM3v08Fh.js';
3
3
 
4
4
  declare function createApplicationPasswordToken(username: string, appPassword: string): string;
5
5
 
@@ -15,15 +15,6 @@ declare function createWPGraphQLFetcher(config: WPGraphQLConfig): {
15
15
  };
16
16
  type WPGraphQLFetcher = ReturnType<typeof createWPGraphQLFetcher>;
17
17
 
18
- declare function createWooCommerceFetcher(config: WooCommerceConfig): {
19
- wcFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[], options?: RequestInit) => Promise<T>;
20
- wcFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
21
- wcFetchPaginated: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
22
- wcFetchPaginatedGraceful: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
23
- wcMutate: <T>(path: string, body: unknown, method?: "POST" | "PUT" | "PATCH" | "DELETE") => Promise<T>;
24
- };
25
- type WooCommerceFetcher = ReturnType<typeof createWooCommerceFetcher>;
26
-
27
18
  declare function createFetcher(config: NextWordpressConfig): {
28
19
  wpFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
29
20
  wpFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
@@ -34,6 +25,15 @@ declare function createFetcher(config: NextWordpressConfig): {
34
25
  };
35
26
  type WordPressFetcher = ReturnType<typeof createFetcher>;
36
27
 
28
+ declare function createWooCommerceFetcher(config: WooCommerceConfig): {
29
+ wcFetch: <T>(path: string, query?: Record<string, unknown>, tags?: string[], options?: RequestInit) => Promise<T>;
30
+ wcFetchGraceful: <T>(path: string, fallback: T, query?: Record<string, unknown>, tags?: string[]) => Promise<T>;
31
+ wcFetchPaginated: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
32
+ wcFetchPaginatedGraceful: <T>(path: string, query?: Record<string, unknown>, tags?: string[]) => Promise<WooCommerceResponse<T[]>>;
33
+ wcMutate: <T>(path: string, body: unknown, method?: "POST" | "PUT" | "PATCH" | "DELETE") => Promise<T>;
34
+ };
35
+ type WooCommerceFetcher = ReturnType<typeof createWooCommerceFetcher>;
36
+
37
37
  interface Category extends Taxonomy {
38
38
  taxonomy: 'category';
39
39
  parent: number;
@@ -337,6 +337,8 @@ declare function createMediaMutations(fetcher: WordPressFetcher): {
337
337
  };
338
338
 
339
339
  declare function createWordPressMutationsClient(config: NextWordpressConfig): {
340
+ sendPasswordResetEmail: (input: RestSendPasswordResetEmailInput) => Promise<RestSendPasswordResetEmailResult>;
341
+ resetUserPassword: (input: RestResetUserPasswordInput) => Promise<RestResetUserPasswordResult>;
340
342
  uploadMedia: (input: UploadMediaInput, authToken: string) => Promise<FeaturedMedia>;
341
343
  updateMedia: (id: number, input: UpdateMediaInput, authToken: string) => Promise<FeaturedMedia>;
342
344
  deleteMedia: (id: number, authToken: string, force?: boolean) => Promise<{
package/dist/index.js CHANGED
@@ -307,6 +307,26 @@ function createMediaMutations(fetcher) {
307
307
  return { uploadMedia, updateMedia, deleteMedia };
308
308
  }
309
309
 
310
+ // src/integrations/restApi/core/mutations/passwordReset/mutations.ts
311
+ function createPasswordResetMutations(fetcher) {
312
+ const { wpMutate } = fetcher;
313
+ async function sendPasswordResetEmail(input) {
314
+ return wpMutate(
315
+ "/wp-json/wp/v2/users/lost-password",
316
+ input,
317
+ "POST"
318
+ );
319
+ }
320
+ async function resetUserPassword(input) {
321
+ return wpMutate(
322
+ "/wp-json/wp/v2/users/reset-password",
323
+ input,
324
+ "POST"
325
+ );
326
+ }
327
+ return { sendPasswordResetEmail, resetUserPassword };
328
+ }
329
+
310
330
  // src/integrations/restApi/core/client/types.ts
311
331
  var WordPressAPIError = class extends Error {
312
332
  constructor(code, status, endpoint, message, detail) {
@@ -441,7 +461,8 @@ function createWordPressMutationsClient(config) {
441
461
  ...createTagsMutations(fetcher),
442
462
  ...createAuthorsMutations(fetcher),
443
463
  ...createMenusMutations(fetcher),
444
- ...createMediaMutations(fetcher)
464
+ ...createMediaMutations(fetcher),
465
+ ...createPasswordResetMutations(fetcher)
445
466
  };
446
467
  }
447
468
 
@@ -3397,9 +3418,6 @@ var GQL_SEND_PASSWORD_RESET_EMAIL = `
3397
3418
  mutation SendPasswordResetEmail($input: SendPasswordResetEmailInput!) {
3398
3419
  sendPasswordResetEmail(input: $input) {
3399
3420
  success
3400
- user {
3401
- email
3402
- }
3403
3421
  }
3404
3422
  }
3405
3423
  `;
@@ -3414,11 +3432,15 @@ var GQL_RESET_USER_PASSWORD = `
3414
3432
  }
3415
3433
  }
3416
3434
  `;
3417
- function createPasswordResetMutations(fetcher) {
3435
+ function createPasswordResetMutations2(fetcher) {
3418
3436
  const { gqlMutate } = fetcher;
3419
3437
  async function sendPasswordResetEmail(input) {
3420
3438
  const data = await gqlMutate(GQL_SEND_PASSWORD_RESET_EMAIL, { input });
3421
- return data.sendPasswordResetEmail;
3439
+ const result = data.sendPasswordResetEmail;
3440
+ if (!result.success) {
3441
+ throw new WPGraphQLError(ErrorCode.GQL_ERRORS_IN_RESPONSE, 200, "sendPasswordResetEmail", "User not found");
3442
+ }
3443
+ return result;
3422
3444
  }
3423
3445
  async function resetUserPassword(input) {
3424
3446
  const data = await gqlMutate(GQL_RESET_USER_PASSWORD, { input });
@@ -3438,7 +3460,7 @@ function createWPGraphQLMutationsClient(config) {
3438
3460
  ...createTagsMutations3(fetcher),
3439
3461
  ...createAuthorsMutations2(fetcher),
3440
3462
  ...createMediaMutations2(fetcher),
3441
- ...createPasswordResetMutations(fetcher)
3463
+ ...createPasswordResetMutations2(fetcher)
3442
3464
  };
3443
3465
  }
3444
3466