@szymonpiatek/nextwordpress 0.0.10 → 0.0.12
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 +1445 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +4 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +1418 -0
- package/dist/client/index.js.map +1 -0
- package/dist/hooks/index.cjs +73 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +11 -2
- package/dist/hooks/index.d.ts +11 -2
- package/dist/hooks/index.js +71 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +4308 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +4263 -0
- package/dist/server/index.js.map +1 -0
- package/dist/{types-Dxb6tuW_.d.cts → types-WcyioRuq.d.cts} +33 -1
- package/dist/{types-Dxb6tuW_.d.ts → types-WcyioRuq.d.ts} +33 -1
- package/package.json +11 -1
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, P as Post, W as WordPressResponse, a as WooCommerceConfig, b as WCProduct, c as WCProductFilterParams, d as WooCommerceResponse, e as WCCreateOrderInput, f as WCOrder, g as WCCustomer, U as UpdateCustomerInput, h as WPGraphQLConfig, G as GQLPost, i as GQLPostFilter, j as GQLConnection } from '../types-
|
|
3
|
+
import { J as JwtAuthCredentials, N as NextWordpressConfig, P as Post, W as WordPressResponse, a as WooCommerceConfig, b as WCProduct, c as WCProductFilterParams, d as WooCommerceResponse, e as WCCreateOrderInput, f as WCOrder, g as WCCustomer, U as UpdateCustomerInput, h as WPGraphQLConfig, G as GQLPost, i as GQLPostFilter, j as GQLConnection, k as WPULikeStatsParams, l as WPULikeStats, m as WPULikeStatus, n as WPULikeVoteResponse, o as WPULikeCheckParams, p as WPULikeCheckResponse } from '../types-WcyioRuq.js';
|
|
4
4
|
import * as swr from 'swr';
|
|
5
5
|
import { SWRConfiguration } from 'swr';
|
|
6
6
|
|
|
@@ -113,4 +113,13 @@ declare function useWPGraphQL<TData>(config: WPGraphQLConfig, query: string, var
|
|
|
113
113
|
declare function useGQLPosts(config: WPGraphQLConfig, first?: number, after?: string, filter?: GQLPostFilter, swrOptions?: SWRConfiguration<GQLConnection<GQLPost>>): swr.SWRResponse<GQLConnection<GQLPost>, any, SWRConfiguration<GQLConnection<GQLPost>, any, swr.BareFetcher<GQLConnection<GQLPost>>> | undefined>;
|
|
114
114
|
declare function useGQLPostBySlug(config: WPGraphQLConfig, slug: string | null | undefined, swrOptions?: SWRConfiguration<GQLPost | null>): swr.SWRResponse<GQLPost | null, any, SWRConfiguration<GQLPost | null, any, swr.BareFetcher<GQLPost | null>> | undefined>;
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
declare function useWPULikeStats(config: NextWordpressConfig, params: WPULikeStatsParams | null | undefined, swrOptions?: SWRConfiguration<WPULikeStats>): swr.SWRResponse<WPULikeStats, any, SWRConfiguration<WPULikeStats, any, swr.BareFetcher<WPULikeStats>> | undefined>;
|
|
117
|
+
declare function useWPULikeCheck(config: NextWordpressConfig, params: WPULikeCheckParams | null | undefined, swrOptions?: SWRConfiguration<WPULikeCheckResponse>): swr.SWRResponse<WPULikeCheckResponse, any, SWRConfiguration<WPULikeCheckResponse, any, swr.BareFetcher<WPULikeCheckResponse>> | undefined>;
|
|
118
|
+
declare function useWPULike(config: NextWordpressConfig, params: WPULikeStatsParams | null | undefined, swrOptions?: SWRConfiguration<WPULikeStats>): {
|
|
119
|
+
data: WPULikeStats | undefined;
|
|
120
|
+
error: any;
|
|
121
|
+
isLoading: boolean;
|
|
122
|
+
vote: (status: WPULikeStatus, authToken?: string) => Promise<WPULikeVoteResponse>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { type AuthContextValue, AuthProvider, type AuthUser, type CartAction, type CartContextValue, type CartItem, CartProvider, type CheckoutOptions, type CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCart, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats };
|
package/dist/hooks/index.js
CHANGED
|
@@ -1343,6 +1343,76 @@ function useGQLPostBySlug(config, slug, swrOptions) {
|
|
|
1343
1343
|
);
|
|
1344
1344
|
}
|
|
1345
1345
|
|
|
1346
|
-
|
|
1346
|
+
// src/integrations/restApi/wpulike/queries.ts
|
|
1347
|
+
function createWPULikeQueries(fetcher) {
|
|
1348
|
+
const { wpFetch, wpMutate } = fetcher;
|
|
1349
|
+
async function getLikeStats(params, tags) {
|
|
1350
|
+
return wpFetch(
|
|
1351
|
+
"/wp-json/wp-ulike/v1/stats",
|
|
1352
|
+
params,
|
|
1353
|
+
tags ?? ["wpulike", `wpulike-${params.id}`]
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
async function checkLikeStatus(params, tags) {
|
|
1357
|
+
return wpFetch(
|
|
1358
|
+
"/wp-json/wp-ulike/v1/check",
|
|
1359
|
+
params,
|
|
1360
|
+
tags ?? ["wpulike", `wpulike-${params.id}`]
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
async function vote(params, authToken) {
|
|
1364
|
+
return wpMutate(
|
|
1365
|
+
"/wp-json/wp-ulike/v1/vote",
|
|
1366
|
+
params,
|
|
1367
|
+
"POST",
|
|
1368
|
+
authToken
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
return { getLikeStats, checkLikeStatus, vote };
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// src/hooks/wpulike/useWPULike.ts
|
|
1375
|
+
function useWPULikeStats(config, params, swrOptions) {
|
|
1376
|
+
const key = params ? ["wpulike-stats", config.clientURL, params.id, params.type ?? "post"] : null;
|
|
1377
|
+
return useSWR2(
|
|
1378
|
+
key,
|
|
1379
|
+
() => {
|
|
1380
|
+
const fetcher = createFetcher(config);
|
|
1381
|
+
return createWPULikeQueries(fetcher).getLikeStats(params);
|
|
1382
|
+
},
|
|
1383
|
+
swrOptions
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
function useWPULikeCheck(config, params, swrOptions) {
|
|
1387
|
+
const key = params ? ["wpulike-check", config.clientURL, params.id, params.type ?? "post"] : null;
|
|
1388
|
+
return useSWR2(
|
|
1389
|
+
key,
|
|
1390
|
+
() => {
|
|
1391
|
+
const fetcher = createFetcher(config);
|
|
1392
|
+
return createWPULikeQueries(fetcher).checkLikeStatus(params);
|
|
1393
|
+
},
|
|
1394
|
+
swrOptions
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
function useWPULike(config, params, swrOptions) {
|
|
1398
|
+
const key = params ? ["wpulike-stats", config.clientURL, params.id, params.type ?? "post"] : null;
|
|
1399
|
+
const { data, error, isLoading, mutate } = useSWR2(
|
|
1400
|
+
key,
|
|
1401
|
+
() => {
|
|
1402
|
+
const fetcher = createFetcher(config);
|
|
1403
|
+
return createWPULikeQueries(fetcher).getLikeStats(params);
|
|
1404
|
+
},
|
|
1405
|
+
swrOptions
|
|
1406
|
+
);
|
|
1407
|
+
async function vote(status, authToken) {
|
|
1408
|
+
const fetcher = createFetcher(config);
|
|
1409
|
+
const result = await createWPULikeQueries(fetcher).vote({ ...params, status }, authToken);
|
|
1410
|
+
await mutate();
|
|
1411
|
+
return result;
|
|
1412
|
+
}
|
|
1413
|
+
return { data, error, isLoading, vote };
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCart, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats };
|
|
1347
1417
|
//# sourceMappingURL=index.js.map
|
|
1348
1418
|
//# sourceMappingURL=index.js.map
|