@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/client/index.cjs +89 -42
- 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 +88 -43
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +89 -42
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +16 -4
- package/dist/hooks/index.d.ts +16 -4
- package/dist/hooks/index.js +88 -43
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +29 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +29 -7
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +29 -7
- package/dist/server/index.js.map +1 -1
- package/dist/{types-CvO7Ijbs.d.cts → types-CM3v08Fh.d.cts} +31 -19
- package/dist/{types-CvO7Ijbs.d.ts → types-CM3v08Fh.d.ts} +31 -19
- package/package.json +1 -1
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { J as JwtAuthCredentials, N as NextWordpressConfig, W as WPGraphQLConfig, G as GQLSendPasswordResetEmailResult, a as GQLResetUserPasswordResult, C as CookieConsentCategories, P as Post,
|
|
3
|
+
import { J as JwtAuthCredentials, N as NextWordpressConfig, W as WPGraphQLConfig, G as GQLSendPasswordResetEmailResult, a as GQLResetUserPasswordResult, R as RestSendPasswordResetEmailResult, b as RestResetUserPasswordResult, C as CookieConsentCategories, P as Post, c as WordPressResponse, d as WooCommerceConfig, e as WCProduct, f as WCProductFilterParams, g as WooCommerceResponse, h as WCCreateOrderInput, i as WCOrder, j as WCCustomer, U as UpdateCustomerInput, k as GQLPost, l as GQLPostFilter, m as GQLConnection, n as WPULikeStatsParams, o as WPULikeStats, p as WPULikeStatus, q as WPULikeVoteResponse, r as WPULikeCheckParams, s as WPULikeCheckResponse, t as CF7SubmissionResponse } from '../types-CM3v08Fh.cjs';
|
|
4
4
|
import * as swr_mutation from 'swr/mutation';
|
|
5
5
|
import * as swr from 'swr';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
@@ -25,17 +25,29 @@ declare function AuthProvider({ config, children, }: {
|
|
|
25
25
|
}): react.JSX.Element;
|
|
26
26
|
declare function useAuth(): AuthContextValue;
|
|
27
27
|
|
|
28
|
+
type SendPasswordResetEmailArg$1 = {
|
|
29
|
+
username: string;
|
|
30
|
+
};
|
|
31
|
+
declare function useSendPasswordResetEmail(config: WPGraphQLConfig): swr_mutation.SWRMutationResponse<GQLSendPasswordResetEmailResult, Error, string, SendPasswordResetEmailArg$1>;
|
|
32
|
+
|
|
33
|
+
type ResetUserPasswordArg$1 = {
|
|
34
|
+
key: string;
|
|
35
|
+
login: string;
|
|
36
|
+
password: string;
|
|
37
|
+
};
|
|
38
|
+
declare function useResetUserPassword(config: WPGraphQLConfig): swr_mutation.SWRMutationResponse<GQLResetUserPasswordResult, Error, string, ResetUserPasswordArg$1>;
|
|
39
|
+
|
|
28
40
|
type SendPasswordResetEmailArg = {
|
|
29
41
|
username: string;
|
|
30
42
|
};
|
|
31
|
-
declare function
|
|
43
|
+
declare function useSendPasswordResetEmailRest(config: NextWordpressConfig): swr_mutation.SWRMutationResponse<RestSendPasswordResetEmailResult, Error, string, SendPasswordResetEmailArg>;
|
|
32
44
|
|
|
33
45
|
type ResetUserPasswordArg = {
|
|
34
46
|
key: string;
|
|
35
47
|
login: string;
|
|
36
48
|
password: string;
|
|
37
49
|
};
|
|
38
|
-
declare function
|
|
50
|
+
declare function useResetUserPasswordRest(config: NextWordpressConfig): swr_mutation.SWRMutationResponse<RestResetUserPasswordResult, Error, string, ResetUserPasswordArg>;
|
|
39
51
|
|
|
40
52
|
declare function useCookieConsent(consentPath?: string, cookieName?: string): {
|
|
41
53
|
consent: CookieConsentCategories | null;
|
|
@@ -148,4 +160,4 @@ type CF7SubmitArg = {
|
|
|
148
160
|
};
|
|
149
161
|
declare function useCF7Submit(config: NextWordpressConfig): swr_mutation.SWRMutationResponse<CF7SubmissionResponse, Error, string, CF7SubmitArg>;
|
|
150
162
|
|
|
151
|
-
export { type AuthContextValue, AuthProvider, type AuthUser, type CartAction, type CartContextValue, type CartItem, CartProvider, type CheckoutOptions, type 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 };
|
|
163
|
+
export { type AuthContextValue, AuthProvider, type AuthUser, type CartAction, type CartContextValue, type CartItem, CartProvider, type CheckoutOptions, type 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 };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { J as JwtAuthCredentials, N as NextWordpressConfig, W as WPGraphQLConfig, G as GQLSendPasswordResetEmailResult, a as GQLResetUserPasswordResult, C as CookieConsentCategories, P as Post,
|
|
3
|
+
import { J as JwtAuthCredentials, N as NextWordpressConfig, W as WPGraphQLConfig, G as GQLSendPasswordResetEmailResult, a as GQLResetUserPasswordResult, R as RestSendPasswordResetEmailResult, b as RestResetUserPasswordResult, C as CookieConsentCategories, P as Post, c as WordPressResponse, d as WooCommerceConfig, e as WCProduct, f as WCProductFilterParams, g as WooCommerceResponse, h as WCCreateOrderInput, i as WCOrder, j as WCCustomer, U as UpdateCustomerInput, k as GQLPost, l as GQLPostFilter, m as GQLConnection, n as WPULikeStatsParams, o as WPULikeStats, p as WPULikeStatus, q as WPULikeVoteResponse, r as WPULikeCheckParams, s as WPULikeCheckResponse, t as CF7SubmissionResponse } from '../types-CM3v08Fh.js';
|
|
4
4
|
import * as swr_mutation from 'swr/mutation';
|
|
5
5
|
import * as swr from 'swr';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
@@ -25,17 +25,29 @@ declare function AuthProvider({ config, children, }: {
|
|
|
25
25
|
}): react.JSX.Element;
|
|
26
26
|
declare function useAuth(): AuthContextValue;
|
|
27
27
|
|
|
28
|
+
type SendPasswordResetEmailArg$1 = {
|
|
29
|
+
username: string;
|
|
30
|
+
};
|
|
31
|
+
declare function useSendPasswordResetEmail(config: WPGraphQLConfig): swr_mutation.SWRMutationResponse<GQLSendPasswordResetEmailResult, Error, string, SendPasswordResetEmailArg$1>;
|
|
32
|
+
|
|
33
|
+
type ResetUserPasswordArg$1 = {
|
|
34
|
+
key: string;
|
|
35
|
+
login: string;
|
|
36
|
+
password: string;
|
|
37
|
+
};
|
|
38
|
+
declare function useResetUserPassword(config: WPGraphQLConfig): swr_mutation.SWRMutationResponse<GQLResetUserPasswordResult, Error, string, ResetUserPasswordArg$1>;
|
|
39
|
+
|
|
28
40
|
type SendPasswordResetEmailArg = {
|
|
29
41
|
username: string;
|
|
30
42
|
};
|
|
31
|
-
declare function
|
|
43
|
+
declare function useSendPasswordResetEmailRest(config: NextWordpressConfig): swr_mutation.SWRMutationResponse<RestSendPasswordResetEmailResult, Error, string, SendPasswordResetEmailArg>;
|
|
32
44
|
|
|
33
45
|
type ResetUserPasswordArg = {
|
|
34
46
|
key: string;
|
|
35
47
|
login: string;
|
|
36
48
|
password: string;
|
|
37
49
|
};
|
|
38
|
-
declare function
|
|
50
|
+
declare function useResetUserPasswordRest(config: NextWordpressConfig): swr_mutation.SWRMutationResponse<RestResetUserPasswordResult, Error, string, ResetUserPasswordArg>;
|
|
39
51
|
|
|
40
52
|
declare function useCookieConsent(consentPath?: string, cookieName?: string): {
|
|
41
53
|
consent: CookieConsentCategories | null;
|
|
@@ -148,4 +160,4 @@ type CF7SubmitArg = {
|
|
|
148
160
|
};
|
|
149
161
|
declare function useCF7Submit(config: NextWordpressConfig): swr_mutation.SWRMutationResponse<CF7SubmissionResponse, Error, string, CF7SubmitArg>;
|
|
150
162
|
|
|
151
|
-
export { type AuthContextValue, AuthProvider, type AuthUser, type CartAction, type CartContextValue, type CartItem, CartProvider, type CheckoutOptions, type 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 };
|
|
163
|
+
export { type AuthContextValue, AuthProvider, type AuthUser, type CartAction, type CartContextValue, type CartItem, CartProvider, type CheckoutOptions, type 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 };
|
package/dist/hooks/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|