@szymonpiatek/nextwordpress 0.0.12 → 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.
@@ -1,2 +1,2 @@
1
- export { x as AuthenticationError, A as Author, B as BlockType, E as EditorBlock, y as EmbeddedAuthor, z as EmbeddedTerm, C as ErrorCode, F as FeaturedMedia, j as GQLConnection, D as GQLError, H as GQLPageInfo, G as GQLPost, i as GQLPostFilter, J as JwtAuthCredentials, q as JwtAuthResponse, M as MediaDetails, I as MediaSize, N as NextWordpressConfig, P as Post, K as PostEmbedded, s as RenderedContent, R as RenderedTitle, S as SearchResult, T as Taxonomy, L as TemplatePart, U as UpdateCustomerInput, v as WCAddress, e as WCCreateOrderInput, g as WCCustomer, O as WCDimensions, t as WCImage, f as WCOrder, Q as WCOrderLineItem, b as WCProduct, V as WCProductAttribute, X as WCProductDefaultAttribute, c as WCProductFilterParams, u as WCProductVariation, Y as WCShippingLine, r as WPEntity, h as WPGraphQLConfig, Z as WPGraphQLError, o as WPULikeCheckParams, p as WPULikeCheckResponse, _ as WPULikeItemType, l as WPULikeStats, k as WPULikeStatsParams, m as WPULikeStatus, w as WPULikeVoteParams, n as WPULikeVoteResponse, a as WooCommerceConfig, $ as WooCommerceError, a0 as WooCommercePaginationHeaders, d as WooCommerceResponse, a1 as WordPressAPIError, a2 as defaultMessages, a3 as defaultMessagesPl, a4 as resolveMessage } from '../types-WcyioRuq.cjs';
1
+ export { x as AuthenticationError, A as Author, B as BlockType, C as CookieConsentCategories, y as CookieConsentConfig, E as EditorBlock, z as EmbeddedAuthor, D as EmbeddedTerm, H as ErrorCode, F as FeaturedMedia, j as GQLConnection, I as GQLError, K as GQLPageInfo, G as GQLPost, i as GQLPostFilter, J as JwtAuthCredentials, q as JwtAuthResponse, M as MediaDetails, L as MediaSize, N as NextWordpressConfig, P as Post, O as PostEmbedded, s as RenderedContent, R as RenderedTitle, S as SearchResult, T as Taxonomy, Q as TemplatePart, U as UpdateCustomerInput, v as WCAddress, e as WCCreateOrderInput, g as WCCustomer, V as WCDimensions, t as WCImage, f as WCOrder, X as WCOrderLineItem, b as WCProduct, Y as WCProductAttribute, Z as WCProductDefaultAttribute, c as WCProductFilterParams, u as WCProductVariation, _ as WCShippingLine, r as WPEntity, h as WPGraphQLConfig, $ as WPGraphQLError, o as WPULikeCheckParams, p as WPULikeCheckResponse, a0 as WPULikeItemType, l as WPULikeStats, k as WPULikeStatsParams, m as WPULikeStatus, w as WPULikeVoteParams, n as WPULikeVoteResponse, a as WooCommerceConfig, a1 as WooCommerceError, a2 as WooCommercePaginationHeaders, d as WooCommerceResponse, a3 as WordPressAPIError, a4 as createCookieConsentHandler, a5 as defaultMessages, a6 as defaultMessagesPl, a7 as parseCookieConsent, a8 as resolveMessage } from '../types-BELSHjQr.cjs';
2
2
  export { CF7SubmissionResponse, CF7SubmissionStatus, CF7ValidationError, Category, Comment, CommentAuthorAvatar, CreateAttributeTermInput, CreateAuthorInput, CreateCategoryInput, CreateCommentInput, CreateCouponInput, CreateMenuInput, CreateMenuItemInput, CreatePageInput, CreatePostInput, CreateProductAttributeInput, CreateProductCategoryInput, CreateProductInput, CreateProductReviewInput, CreateProductTagInput, CreateShippingClassInput, CreateShippingZoneInput, CreateShippingZoneMethodInput, CreateTagInput, CreateTaxClassInput, CreateTaxRateInput, CreateWebhookInput, FaustConfig, FaustPreviewConfig, FaustPreviewDeps, GQLACFFieldGroup, GQLAuthor, GQLCPTNode, GQLCategory, GQLCreateCommentInput, GQLCreateCommentResult, GQLCreatePostInput, GQLCustomer, GQLDeletePostResult, GQLLineItem, GQLMutatedComment, GQLMutatedPost, GQLOrder, GQLOrderAddress, GQLPage, GQLPageWithSEO, GQLPostStatus, GQLPostWithSEO, GQLProduct, GQLProductFilter, GQLProductVariation, GQLTag, GQLUpdatePostInput, GQLYoastSEO, Menu, MenuItem, MenuLocation, MenuWithItems, OmnibusPriceEntry, OmnibusProductData, Page, RestPageStatus, RestPostStatus, RevalidationConfig, RevalidationPayload, RevalidationResult, Tag, UpdateAttributeTermInput, UpdateAuthorInput, UpdateCategoryInput, UpdateCommentInput, UpdateCouponInput, UpdateMediaInput, UpdateMenuInput, UpdateMenuItemInput, UpdatePageInput, UpdatePostInput, UpdateProductAttributeInput, UpdateProductCategoryInput, UpdateProductInput, UpdateProductReviewInput, UpdateProductTagInput, UpdateShippingClassInput, UpdateShippingZoneInput, UpdateShippingZoneMethodInput, UpdateTagInput, UpdateTaxRateInput, UpdateWebhookInput, UploadMediaInput, WCAttributeTerm, WCContinent, WCCountry, WCCoupon, WCCreateOrderNoteInput, WCCreateOrderRefundInput, WCCurrency, WCGlobalProductAttribute, WCOrderNote, WCOrderRefund, WCPaymentGateway, WCPaymentGatewaySetting, WCProductCategory, WCProductReview, WCProductReviewFilterParams, WCProductStatus, WCProductTag, WCProductVariationWithOmnibus, WCProductWithOmnibus, WCRefundLineItem, WCReviewStatus, WCSalesReport, WCSalesReportParams, WCSettingGroup, WCSettingOption, WCShippingClass, WCShippingMethod, WCShippingZone, WCShippingZoneLocation, WCShippingZoneMethod, WCStatusCount, WCSystemStatus, WCSystemStatusTool, WCTaxClass, WCTaxRate, WCTopSeller, WCTopSellersParams, WCWebhook, WCWebhookStatus, WCWebhookTopic, WPGraphQLFetcher, WooCommerceFetcher, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTagsMutations, createWPGraphQLClient, createWPGraphQLClient as createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYoastQueries, extractOmnibusData, resolveBaseUrl, validateJwtToken, withOmnibus, withOmnibusVariation } from '../index.cjs';
@@ -1,2 +1,2 @@
1
- export { x as AuthenticationError, A as Author, B as BlockType, E as EditorBlock, y as EmbeddedAuthor, z as EmbeddedTerm, C as ErrorCode, F as FeaturedMedia, j as GQLConnection, D as GQLError, H as GQLPageInfo, G as GQLPost, i as GQLPostFilter, J as JwtAuthCredentials, q as JwtAuthResponse, M as MediaDetails, I as MediaSize, N as NextWordpressConfig, P as Post, K as PostEmbedded, s as RenderedContent, R as RenderedTitle, S as SearchResult, T as Taxonomy, L as TemplatePart, U as UpdateCustomerInput, v as WCAddress, e as WCCreateOrderInput, g as WCCustomer, O as WCDimensions, t as WCImage, f as WCOrder, Q as WCOrderLineItem, b as WCProduct, V as WCProductAttribute, X as WCProductDefaultAttribute, c as WCProductFilterParams, u as WCProductVariation, Y as WCShippingLine, r as WPEntity, h as WPGraphQLConfig, Z as WPGraphQLError, o as WPULikeCheckParams, p as WPULikeCheckResponse, _ as WPULikeItemType, l as WPULikeStats, k as WPULikeStatsParams, m as WPULikeStatus, w as WPULikeVoteParams, n as WPULikeVoteResponse, a as WooCommerceConfig, $ as WooCommerceError, a0 as WooCommercePaginationHeaders, d as WooCommerceResponse, a1 as WordPressAPIError, a2 as defaultMessages, a3 as defaultMessagesPl, a4 as resolveMessage } from '../types-WcyioRuq.js';
1
+ export { x as AuthenticationError, A as Author, B as BlockType, C as CookieConsentCategories, y as CookieConsentConfig, E as EditorBlock, z as EmbeddedAuthor, D as EmbeddedTerm, H as ErrorCode, F as FeaturedMedia, j as GQLConnection, I as GQLError, K as GQLPageInfo, G as GQLPost, i as GQLPostFilter, J as JwtAuthCredentials, q as JwtAuthResponse, M as MediaDetails, L as MediaSize, N as NextWordpressConfig, P as Post, O as PostEmbedded, s as RenderedContent, R as RenderedTitle, S as SearchResult, T as Taxonomy, Q as TemplatePart, U as UpdateCustomerInput, v as WCAddress, e as WCCreateOrderInput, g as WCCustomer, V as WCDimensions, t as WCImage, f as WCOrder, X as WCOrderLineItem, b as WCProduct, Y as WCProductAttribute, Z as WCProductDefaultAttribute, c as WCProductFilterParams, u as WCProductVariation, _ as WCShippingLine, r as WPEntity, h as WPGraphQLConfig, $ as WPGraphQLError, o as WPULikeCheckParams, p as WPULikeCheckResponse, a0 as WPULikeItemType, l as WPULikeStats, k as WPULikeStatsParams, m as WPULikeStatus, w as WPULikeVoteParams, n as WPULikeVoteResponse, a as WooCommerceConfig, a1 as WooCommerceError, a2 as WooCommercePaginationHeaders, d as WooCommerceResponse, a3 as WordPressAPIError, a4 as createCookieConsentHandler, a5 as defaultMessages, a6 as defaultMessagesPl, a7 as parseCookieConsent, a8 as resolveMessage } from '../types-BELSHjQr.js';
2
2
  export { CF7SubmissionResponse, CF7SubmissionStatus, CF7ValidationError, Category, Comment, CommentAuthorAvatar, CreateAttributeTermInput, CreateAuthorInput, CreateCategoryInput, CreateCommentInput, CreateCouponInput, CreateMenuInput, CreateMenuItemInput, CreatePageInput, CreatePostInput, CreateProductAttributeInput, CreateProductCategoryInput, CreateProductInput, CreateProductReviewInput, CreateProductTagInput, CreateShippingClassInput, CreateShippingZoneInput, CreateShippingZoneMethodInput, CreateTagInput, CreateTaxClassInput, CreateTaxRateInput, CreateWebhookInput, FaustConfig, FaustPreviewConfig, FaustPreviewDeps, GQLACFFieldGroup, GQLAuthor, GQLCPTNode, GQLCategory, GQLCreateCommentInput, GQLCreateCommentResult, GQLCreatePostInput, GQLCustomer, GQLDeletePostResult, GQLLineItem, GQLMutatedComment, GQLMutatedPost, GQLOrder, GQLOrderAddress, GQLPage, GQLPageWithSEO, GQLPostStatus, GQLPostWithSEO, GQLProduct, GQLProductFilter, GQLProductVariation, GQLTag, GQLUpdatePostInput, GQLYoastSEO, Menu, MenuItem, MenuLocation, MenuWithItems, OmnibusPriceEntry, OmnibusProductData, Page, RestPageStatus, RestPostStatus, RevalidationConfig, RevalidationPayload, RevalidationResult, Tag, UpdateAttributeTermInput, UpdateAuthorInput, UpdateCategoryInput, UpdateCommentInput, UpdateCouponInput, UpdateMediaInput, UpdateMenuInput, UpdateMenuItemInput, UpdatePageInput, UpdatePostInput, UpdateProductAttributeInput, UpdateProductCategoryInput, UpdateProductInput, UpdateProductReviewInput, UpdateProductTagInput, UpdateShippingClassInput, UpdateShippingZoneInput, UpdateShippingZoneMethodInput, UpdateTagInput, UpdateTaxRateInput, UpdateWebhookInput, UploadMediaInput, WCAttributeTerm, WCContinent, WCCountry, WCCoupon, WCCreateOrderNoteInput, WCCreateOrderRefundInput, WCCurrency, WCGlobalProductAttribute, WCOrderNote, WCOrderRefund, WCPaymentGateway, WCPaymentGatewaySetting, WCProductCategory, WCProductReview, WCProductReviewFilterParams, WCProductStatus, WCProductTag, WCProductVariationWithOmnibus, WCProductWithOmnibus, WCRefundLineItem, WCReviewStatus, WCSalesReport, WCSalesReportParams, WCSettingGroup, WCSettingOption, WCShippingClass, WCShippingMethod, WCShippingZone, WCShippingZoneLocation, WCShippingZoneMethod, WCStatusCount, WCSystemStatus, WCSystemStatusTool, WCTaxClass, WCTaxRate, WCTopSeller, WCTopSellersParams, WCWebhook, WCWebhookStatus, WCWebhookTopic, WPGraphQLFetcher, WooCommerceFetcher, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTagsMutations, createWPGraphQLClient, createWPGraphQLClient as createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYoastQueries, extractOmnibusData, resolveBaseUrl, validateJwtToken, withOmnibus, withOmnibusVariation } from '../index.js';
@@ -4207,6 +4207,59 @@ async function resolvePreviewSlug(config, postId, previewPathname) {
4207
4207
  return data.slug ?? `preview-${postId}`;
4208
4208
  }
4209
4209
 
4210
+ // src/nextjs/cookieConsent.ts
4211
+ function createCookieConsentHandler(config) {
4212
+ const cookieName = config?.cookieName ?? "cookie_notice_accepted";
4213
+ const maxAge = config?.maxAge ?? 31536e3;
4214
+ return async function handler(request) {
4215
+ if (request.method === "GET") {
4216
+ const consent = parseCookieConsent(request, cookieName);
4217
+ return Response.json(consent ?? null);
4218
+ }
4219
+ if (request.method === "POST") {
4220
+ const body = await request.json();
4221
+ const categories = {
4222
+ necessary: true,
4223
+ analytics: body.analytics ?? false,
4224
+ marketing: body.marketing ?? false
4225
+ };
4226
+ return new Response(JSON.stringify(categories), {
4227
+ status: 200,
4228
+ headers: {
4229
+ "Content-Type": "application/json",
4230
+ "Set-Cookie": buildConsentCookie(cookieName, encodeURIComponent(JSON.stringify(categories)), maxAge)
4231
+ }
4232
+ });
4233
+ }
4234
+ if (request.method === "DELETE") {
4235
+ return new Response(null, {
4236
+ status: 204,
4237
+ headers: {
4238
+ "Set-Cookie": `${cookieName}=; Max-Age=0; Path=/; SameSite=Lax`
4239
+ }
4240
+ });
4241
+ }
4242
+ return Response.json({ error: "Method Not Allowed" }, { status: 405 });
4243
+ };
4244
+ }
4245
+ function parseCookieConsent(request, cookieName = "cookie_notice_accepted") {
4246
+ const header = request.headers.get("cookie") ?? "";
4247
+ const match = header.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
4248
+ if (!match) return null;
4249
+ if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
4250
+ try {
4251
+ const parsed = JSON.parse(decodeURIComponent(match[1]));
4252
+ if (typeof parsed !== "object" || parsed === null) return null;
4253
+ return { necessary: true, analytics: parsed.analytics ?? false, marketing: parsed.marketing ?? false };
4254
+ } catch {
4255
+ return null;
4256
+ }
4257
+ }
4258
+ function buildConsentCookie(name, value, maxAge) {
4259
+ const secure = process.env.NODE_ENV === "production" ? "; Secure" : "";
4260
+ return `${name}=${value}; Path=/; SameSite=Lax; Max-Age=${maxAge}${secure}`;
4261
+ }
4262
+
4210
4263
  // src/auth/applicationPassword.ts
4211
4264
  function createApplicationPasswordToken(username, appPassword) {
4212
4265
  const encoded = Buffer.from(`${username}:${appPassword}`).toString("base64");
@@ -4258,6 +4311,6 @@ async function validateJwtToken(config, token) {
4258
4311
  return response.ok;
4259
4312
  }
4260
4313
 
4261
- export { AuthenticationError, ErrorCode, WPGraphQLError, WooCommerceError, WordPressAPIError, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYoastQueries, defaultMessages, defaultMessagesPl, extractOmnibusData, resolveBaseUrl, resolveMessage, validateJwtToken, withOmnibus, withOmnibusVariation };
4314
+ export { AuthenticationError, ErrorCode, WPGraphQLError, WooCommerceError, WordPressAPIError, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createCookieConsentHandler, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYoastQueries, defaultMessages, defaultMessagesPl, extractOmnibusData, parseCookieConsent, resolveBaseUrl, resolveMessage, validateJwtToken, withOmnibus, withOmnibusVariation };
4262
4315
  //# sourceMappingURL=index.js.map
4263
4316
  //# sourceMappingURL=index.js.map