@szymonpiatek/nextwordpress 0.0.17 → 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 +84 -38
- 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 +83 -39
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +84 -38
- 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 +83 -39
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +24 -3
- 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 +24 -3
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +24 -3
- 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 +24 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{types-DVzJO3P-.d.cts → types-CM3v08Fh.d.cts} +31 -16
- package/dist/{types-DVzJO3P-.d.ts → types-CM3v08Fh.d.ts} +31 -16
- 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
|
@@ -359,44 +359,6 @@ function useResetUserPassword(config) {
|
|
|
359
359
|
}
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
|
-
function readConsentFromDocument(cookieName) {
|
|
363
|
-
if (typeof document === "undefined") return null;
|
|
364
|
-
const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
|
|
365
|
-
if (!match) return null;
|
|
366
|
-
if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
|
|
367
|
-
try {
|
|
368
|
-
const parsed = JSON.parse(decodeURIComponent(match[1]));
|
|
369
|
-
if (typeof parsed !== "object" || parsed === null) return null;
|
|
370
|
-
return parsed;
|
|
371
|
-
} catch {
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
|
|
376
|
-
const [consent, setConsentState] = useState(null);
|
|
377
|
-
const [isLoaded, setIsLoaded] = useState(false);
|
|
378
|
-
useEffect(() => {
|
|
379
|
-
setConsentState(readConsentFromDocument(cookieName));
|
|
380
|
-
setIsLoaded(true);
|
|
381
|
-
}, [cookieName]);
|
|
382
|
-
const setConsent = useCallback(
|
|
383
|
-
async (categories) => {
|
|
384
|
-
const res = await fetch(consentPath, {
|
|
385
|
-
method: "POST",
|
|
386
|
-
headers: { "Content-Type": "application/json" },
|
|
387
|
-
body: JSON.stringify(categories)
|
|
388
|
-
});
|
|
389
|
-
const data = await res.json();
|
|
390
|
-
setConsentState(data);
|
|
391
|
-
},
|
|
392
|
-
[consentPath]
|
|
393
|
-
);
|
|
394
|
-
const clearConsent = useCallback(async () => {
|
|
395
|
-
await fetch(consentPath, { method: "DELETE" });
|
|
396
|
-
setConsentState(null);
|
|
397
|
-
}, [consentPath]);
|
|
398
|
-
return { consent, isLoaded, setConsent, clearConsent };
|
|
399
|
-
}
|
|
400
362
|
|
|
401
363
|
// src/integrations/restApi/core/client/types.ts
|
|
402
364
|
var WordPressAPIError = class extends Error {
|
|
@@ -521,6 +483,88 @@ function createFetcher(config) {
|
|
|
521
483
|
return { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful, wpMutate, wpUpload };
|
|
522
484
|
}
|
|
523
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
|
+
|
|
524
568
|
// src/integrations/restApi/core/posts/queries.ts
|
|
525
569
|
function createPostsQueries(fetcher) {
|
|
526
570
|
const { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful } = fetcher;
|
|
@@ -1577,6 +1621,6 @@ function useCF7Submit(config) {
|
|
|
1577
1621
|
);
|
|
1578
1622
|
}
|
|
1579
1623
|
|
|
1580
|
-
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 };
|
|
1581
1625
|
//# sourceMappingURL=index.js.map
|
|
1582
1626
|
//# sourceMappingURL=index.js.map
|