@szymonpiatek/nextwordpress 0.0.11 → 0.0.13
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 +118 -6
- 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 +115 -7
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +118 -6
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +18 -2
- package/dist/hooks/index.d.ts +18 -2
- package/dist/hooks/index.js +115 -7
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +89 -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 +86 -1
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +89 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +86 -1
- package/dist/server/index.js.map +1 -1
- package/dist/{types-Dxb6tuW_.d.cts → types-BELSHjQr.d.cts} +45 -1
- package/dist/{types-Dxb6tuW_.d.ts → types-BELSHjQr.d.ts} +45 -1
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -2101,6 +2101,38 @@ function createWooCommerceClient(config) {
|
|
|
2101
2101
|
};
|
|
2102
2102
|
}
|
|
2103
2103
|
|
|
2104
|
+
// src/integrations/restApi/wpulike/queries.ts
|
|
2105
|
+
function createWPULikeQueries(fetcher) {
|
|
2106
|
+
const { wpFetch, wpMutate } = fetcher;
|
|
2107
|
+
async function getLikeStats(params, tags) {
|
|
2108
|
+
return wpFetch(
|
|
2109
|
+
"/wp-json/wp-ulike/v1/stats",
|
|
2110
|
+
params,
|
|
2111
|
+
tags ?? ["wpulike", `wpulike-${params.id}`]
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
2114
|
+
async function checkLikeStatus(params, tags) {
|
|
2115
|
+
return wpFetch(
|
|
2116
|
+
"/wp-json/wp-ulike/v1/check",
|
|
2117
|
+
params,
|
|
2118
|
+
tags ?? ["wpulike", `wpulike-${params.id}`]
|
|
2119
|
+
);
|
|
2120
|
+
}
|
|
2121
|
+
async function vote(params, authToken) {
|
|
2122
|
+
return wpMutate(
|
|
2123
|
+
"/wp-json/wp-ulike/v1/vote",
|
|
2124
|
+
params,
|
|
2125
|
+
"POST",
|
|
2126
|
+
authToken
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2129
|
+
return { getLikeStats, checkLikeStatus, vote };
|
|
2130
|
+
}
|
|
2131
|
+
function createWPULikeClient(config) {
|
|
2132
|
+
const fetcher = createFetcher(config);
|
|
2133
|
+
return createWPULikeQueries(fetcher);
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2104
2136
|
// src/integrations/wpGraphQL/client/types.ts
|
|
2105
2137
|
var WPGraphQLError = class extends Error {
|
|
2106
2138
|
constructor(code, status, endpoint, message, gqlErrors) {
|
|
@@ -4177,6 +4209,59 @@ async function resolvePreviewSlug(config, postId, previewPathname) {
|
|
|
4177
4209
|
return data.slug ?? `preview-${postId}`;
|
|
4178
4210
|
}
|
|
4179
4211
|
|
|
4212
|
+
// src/nextjs/cookieConsent.ts
|
|
4213
|
+
function createCookieConsentHandler(config) {
|
|
4214
|
+
const cookieName = config?.cookieName ?? "cookie_notice_accepted";
|
|
4215
|
+
const maxAge = config?.maxAge ?? 31536e3;
|
|
4216
|
+
return async function handler(request) {
|
|
4217
|
+
if (request.method === "GET") {
|
|
4218
|
+
const consent = parseCookieConsent(request, cookieName);
|
|
4219
|
+
return Response.json(consent ?? null);
|
|
4220
|
+
}
|
|
4221
|
+
if (request.method === "POST") {
|
|
4222
|
+
const body = await request.json();
|
|
4223
|
+
const categories = {
|
|
4224
|
+
necessary: true,
|
|
4225
|
+
analytics: body.analytics ?? false,
|
|
4226
|
+
marketing: body.marketing ?? false
|
|
4227
|
+
};
|
|
4228
|
+
return new Response(JSON.stringify(categories), {
|
|
4229
|
+
status: 200,
|
|
4230
|
+
headers: {
|
|
4231
|
+
"Content-Type": "application/json",
|
|
4232
|
+
"Set-Cookie": buildConsentCookie(cookieName, encodeURIComponent(JSON.stringify(categories)), maxAge)
|
|
4233
|
+
}
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
if (request.method === "DELETE") {
|
|
4237
|
+
return new Response(null, {
|
|
4238
|
+
status: 204,
|
|
4239
|
+
headers: {
|
|
4240
|
+
"Set-Cookie": `${cookieName}=; Max-Age=0; Path=/; SameSite=Lax`
|
|
4241
|
+
}
|
|
4242
|
+
});
|
|
4243
|
+
}
|
|
4244
|
+
return Response.json({ error: "Method Not Allowed" }, { status: 405 });
|
|
4245
|
+
};
|
|
4246
|
+
}
|
|
4247
|
+
function parseCookieConsent(request, cookieName = "cookie_notice_accepted") {
|
|
4248
|
+
const header = request.headers.get("cookie") ?? "";
|
|
4249
|
+
const match = header.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
|
|
4250
|
+
if (!match) return null;
|
|
4251
|
+
if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
|
|
4252
|
+
try {
|
|
4253
|
+
const parsed = JSON.parse(decodeURIComponent(match[1]));
|
|
4254
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
4255
|
+
return { necessary: true, analytics: parsed.analytics ?? false, marketing: parsed.marketing ?? false };
|
|
4256
|
+
} catch {
|
|
4257
|
+
return null;
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
function buildConsentCookie(name, value, maxAge) {
|
|
4261
|
+
const secure = process.env.NODE_ENV === "production" ? "; Secure" : "";
|
|
4262
|
+
return `${name}=${value}; Path=/; SameSite=Lax; Max-Age=${maxAge}${secure}`;
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4180
4265
|
// src/auth/applicationPassword.ts
|
|
4181
4266
|
function createApplicationPasswordToken(username, appPassword) {
|
|
4182
4267
|
const encoded = Buffer.from(`${username}:${appPassword}`).toString("base64");
|
|
@@ -4244,6 +4329,7 @@ exports.createCF7Queries = createCF7Queries;
|
|
|
4244
4329
|
exports.createCPTQueries = createCPTQueries;
|
|
4245
4330
|
exports.createCategoriesMutations = createCategoriesMutations;
|
|
4246
4331
|
exports.createCommentsMutations = createCommentsMutations;
|
|
4332
|
+
exports.createCookieConsentHandler = createCookieConsentHandler;
|
|
4247
4333
|
exports.createFaustAuthHandler = createFaustAuthHandler;
|
|
4248
4334
|
exports.createMediaMutations = createMediaMutations;
|
|
4249
4335
|
exports.createMenusMutations = createMenusMutations;
|
|
@@ -4257,6 +4343,8 @@ exports.createWPGraphQLCoreClient = createWPGraphQLCoreClient;
|
|
|
4257
4343
|
exports.createWPGraphQLFetcher = createWPGraphQLFetcher;
|
|
4258
4344
|
exports.createWPGraphQLMutationsClient = createWPGraphQLMutationsClient;
|
|
4259
4345
|
exports.createWPGraphQLWooCommerceClient = createWPGraphQLWooCommerceClient;
|
|
4346
|
+
exports.createWPULikeClient = createWPULikeClient;
|
|
4347
|
+
exports.createWPULikeQueries = createWPULikeQueries;
|
|
4260
4348
|
exports.createWooCommerceClient = createWooCommerceClient;
|
|
4261
4349
|
exports.createWooCommerceFetcher = createWooCommerceFetcher;
|
|
4262
4350
|
exports.createWordPressClient = createWordPressClient;
|
|
@@ -4265,6 +4353,7 @@ exports.createYoastQueries = createYoastQueries;
|
|
|
4265
4353
|
exports.defaultMessages = defaultMessages;
|
|
4266
4354
|
exports.defaultMessagesPl = defaultMessagesPl;
|
|
4267
4355
|
exports.extractOmnibusData = extractOmnibusData;
|
|
4356
|
+
exports.parseCookieConsent = parseCookieConsent;
|
|
4268
4357
|
exports.resolveBaseUrl = resolveBaseUrl;
|
|
4269
4358
|
exports.resolveMessage = resolveMessage;
|
|
4270
4359
|
exports.validateJwtToken = validateJwtToken;
|