@szymonpiatek/nextwordpress 0.0.18 → 0.0.20
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 +268 -0
- 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 +264 -1
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +268 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +9 -2
- package/dist/hooks/index.d.ts +9 -2
- package/dist/hooks/index.js +264 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +280 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -3
- package/dist/index.d.ts +61 -3
- package/dist/index.js +273 -9
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +280 -8
- 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 +273 -9
- package/dist/server/index.js.map +1 -1
- package/dist/{types-CM3v08Fh.d.cts → types-DmNIXJNR.d.cts} +85 -1
- package/dist/{types-CM3v08Fh.d.ts → types-DmNIXJNR.d.ts} +85 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NextWordpressConfig, J as JwtAuthCredentials,
|
|
2
|
-
export {
|
|
1
|
+
import { N as NextWordpressConfig, J as JwtAuthCredentials, y as JwtAuthResponse, W as WPGraphQLConfig, c as WordPressResponse, d as WooCommerceConfig, g as WooCommerceResponse, z as Taxonomy, A as WPEntity, B as RenderedTitle, D as RenderedContent, P as Post, E as Author, F as FeaturedMedia, H as RestSendPasswordResetEmailInput, R as RestSendPasswordResetEmailResult, I as RestResetUserPasswordInput, b as RestResetUserPasswordResult, K as WCImage, L as ErrorCode, Y as YithWishlistConfig, k as WCWishlist, M as CreateWishlistInput, O as UpdateWishlistInput, Q as AddProductToWishlistInput, T as TIWishlistConfig, l as TIWishlist, m as GetTIWishlistProductsParams, n as TIWishlistItem, S as CreateTIWishlistInput, V as UpdateTIWishlistInput, X as AddProductToTIWishlistInput, Z as WCProductVariation, e as WCProduct, j as WCCustomer, _ as WCAddress, U as UpdateCustomerInput, h as WCCreateOrderInput, i as WCOrder, f as WCProductFilterParams, r as WPULikeStatsParams, s as WPULikeStats, v as WPULikeCheckParams, w as WPULikeCheckResponse, $ as WPULikeVoteParams, u as WPULikeVoteResponse, x as CF7SubmissionResponse, a0 as GQLSendPasswordResetEmailInput, G as GQLSendPasswordResetEmailResult, a1 as GQLResetUserPasswordInput, a as GQLResetUserPasswordResult, q as GQLConnection, p as GQLPostFilter, o as GQLPost } from './types-DmNIXJNR.cjs';
|
|
2
|
+
export { a2 as AuthenticationError, a3 as BlockType, a4 as CF7Error, a5 as CF7SubmissionStatus, a6 as CF7ValidationError, C as CookieConsentCategories, a7 as CookieConsentConfig, a8 as EditorBlock, a9 as EmbeddedAuthor, aa as EmbeddedTerm, ab as GQLError, ac as GQLPageInfo, ad as MediaDetails, ae as MediaSize, af as PostEmbedded, ag as SearchResult, ah as TemplatePart, ai as WCDimensions, aj as WCOrderLineItem, ak as WCProductAttribute, al as WCProductDefaultAttribute, am as WCShippingLine, an as WCWishlistItem, ao as WPGraphQLError, ap as WPULikeItemType, t as WPULikeStatus, aq as WooCommerceError, ar as WooCommercePaginationHeaders, as as WordPressAPIError, at as createCookieConsentHandler, au as defaultMessages, av as defaultMessagesPl, aw as parseCookieConsent, ax as resolveMessage } from './types-DmNIXJNR.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createApplicationPasswordToken(username: string, appPassword: string): string;
|
|
5
5
|
|
|
@@ -1023,6 +1023,64 @@ interface WCPaymentGateway {
|
|
|
1023
1023
|
settings: Record<string, WCPaymentGatewaySetting>;
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
+
declare class YithWishlistError extends Error {
|
|
1027
|
+
readonly code: ErrorCode;
|
|
1028
|
+
readonly status: number;
|
|
1029
|
+
readonly url: string;
|
|
1030
|
+
readonly upstreamCode?: string | undefined;
|
|
1031
|
+
readonly upstreamMessage?: string | undefined;
|
|
1032
|
+
constructor(code: ErrorCode, status: number, url: string, message: string, upstreamCode?: string | undefined, upstreamMessage?: string | undefined);
|
|
1033
|
+
}
|
|
1034
|
+
declare function createYithWishlistFetcher(config: YithWishlistConfig): {
|
|
1035
|
+
yithFetch: <T>(path: string, tags?: string[], options?: RequestInit) => Promise<T>;
|
|
1036
|
+
yithFetchGraceful: <T>(path: string, fallback: T, tags?: string[]) => Promise<T>;
|
|
1037
|
+
yithMutate: <T>(path: string, body: unknown, method?: "POST" | "PATCH" | "DELETE") => Promise<T>;
|
|
1038
|
+
};
|
|
1039
|
+
type YithWishlistFetcher = ReturnType<typeof createYithWishlistFetcher>;
|
|
1040
|
+
|
|
1041
|
+
declare function createWishlistQueries(fetcher: YithWishlistFetcher): {
|
|
1042
|
+
getWishlists: () => Promise<WCWishlist[]>;
|
|
1043
|
+
getWishlistByToken: (token: string) => Promise<WCWishlist>;
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
declare function createWishlistMutations(fetcher: YithWishlistFetcher): {
|
|
1047
|
+
createWishlist: (input: CreateWishlistInput) => Promise<WCWishlist>;
|
|
1048
|
+
updateWishlist: (token: string, input: UpdateWishlistInput) => Promise<WCWishlist>;
|
|
1049
|
+
deleteWishlist: (token: string) => Promise<{
|
|
1050
|
+
deleted: boolean;
|
|
1051
|
+
previous: WCWishlist;
|
|
1052
|
+
}>;
|
|
1053
|
+
addProductToWishlist: (token: string, input: AddProductToWishlistInput) => Promise<WCWishlist>;
|
|
1054
|
+
removeProductFromWishlist: (token: string, productId: number) => Promise<WCWishlist>;
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
declare class TIWishlistError extends Error {
|
|
1058
|
+
readonly code: ErrorCode;
|
|
1059
|
+
readonly status: number;
|
|
1060
|
+
readonly url: string;
|
|
1061
|
+
constructor(code: ErrorCode, status: number, url: string, message: string);
|
|
1062
|
+
}
|
|
1063
|
+
declare function createTIWishlistFetcher(config: TIWishlistConfig): {
|
|
1064
|
+
tiFetch: <T>(path: string, tags?: string[], options?: RequestInit) => Promise<T>;
|
|
1065
|
+
tiFetchGraceful: <T>(path: string, fallback: T, tags?: string[]) => Promise<T>;
|
|
1066
|
+
tiMutate: <T>(path: string, body: unknown, method?: "POST") => Promise<T>;
|
|
1067
|
+
};
|
|
1068
|
+
type TIWishlistFetcher = ReturnType<typeof createTIWishlistFetcher>;
|
|
1069
|
+
|
|
1070
|
+
declare function createTIWishlistQueries(fetcher: TIWishlistFetcher): {
|
|
1071
|
+
getWishlistsByUser: (userId: number) => Promise<TIWishlist[]>;
|
|
1072
|
+
getWishlistByShareKey: (shareKey: string) => Promise<TIWishlist>;
|
|
1073
|
+
getWishlistProducts: (shareKey: string, params?: GetTIWishlistProductsParams) => Promise<TIWishlistItem[]>;
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
declare function createTIWishlistMutations(fetcher: TIWishlistFetcher): {
|
|
1077
|
+
createWishlist: (input: CreateTIWishlistInput) => Promise<TIWishlist>;
|
|
1078
|
+
updateWishlist: (shareKey: string, input: UpdateTIWishlistInput) => Promise<TIWishlist>;
|
|
1079
|
+
deleteWishlist: (shareKey: string) => Promise<string>;
|
|
1080
|
+
addProduct: (shareKey: string, input: AddProductToTIWishlistInput) => Promise<TIWishlistItem[]>;
|
|
1081
|
+
removeProduct: (itemId: number) => Promise<string>;
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1026
1084
|
interface OmnibusPriceEntry {
|
|
1027
1085
|
price: string;
|
|
1028
1086
|
date: string;
|
|
@@ -2010,4 +2068,4 @@ interface FaustPreviewDeps {
|
|
|
2010
2068
|
declare function createFaustAuthHandler(config: FaustConfig): (request: Request, routePath: string) => Promise<Response>;
|
|
2011
2069
|
declare function createPreviewHandler(config: FaustPreviewConfig, deps: FaustPreviewDeps): (request: Request) => Promise<Response>;
|
|
2012
2070
|
|
|
2013
|
-
export { Author, CF7SubmissionResponse, type Category, type Comment, type CommentAuthorAvatar, type CreateAttributeTermInput, type CreateAuthorInput, type CreateCategoryInput, type CreateCommentInput, type CreateCouponInput, type CreateMenuInput, type CreateMenuItemInput, type CreatePageInput, type CreatePostInput, type CreateProductAttributeInput, type CreateProductCategoryInput, type CreateProductInput, type CreateProductReviewInput, type CreateProductTagInput, type CreateShippingClassInput, type CreateShippingZoneInput, type CreateShippingZoneMethodInput, type CreateTagInput, type CreateTaxClassInput, type CreateTaxRateInput, type CreateWebhookInput, type FaustConfig, type FaustPreviewConfig, type FaustPreviewDeps, FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, GQLConnection, type GQLCreateCommentInput, type GQLCreateCommentResult, type GQLCreatePostInput, type GQLCustomer, type GQLDeletePostResult, type GQLLineItem, type GQLMutatedComment, type GQLMutatedPost, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageWithSEO, GQLPost, GQLPostFilter, type GQLPostStatus, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, GQLResetUserPasswordInput, GQLResetUserPasswordResult, GQLSendPasswordResetEmailInput, GQLSendPasswordResetEmailResult, type GQLTag, type GQLUpdatePostInput, type GQLYoastSEO, JwtAuthCredentials, JwtAuthResponse, type Menu, type MenuItem, type MenuLocation, type MenuWithItems, NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, Post, RenderedContent, RenderedTitle, type RestPageStatus, type RestPostStatus, type RevalidationConfig, type RevalidationPayload, type RevalidationResult, type Tag, Taxonomy, type UpdateAttributeTermInput, type UpdateAuthorInput, type UpdateCategoryInput, type UpdateCommentInput, type UpdateCouponInput, UpdateCustomerInput, type UpdateMediaInput, type UpdateMenuInput, type UpdateMenuItemInput, type UpdatePageInput, type UpdatePostInput, type UpdateProductAttributeInput, type UpdateProductCategoryInput, type UpdateProductInput, type UpdateProductReviewInput, type UpdateProductTagInput, type UpdateShippingClassInput, type UpdateShippingZoneInput, type UpdateShippingZoneMethodInput, type UpdateTagInput, type UpdateTaxRateInput, type UpdateWebhookInput, type UploadMediaInput, WCAddress, type WCAttributeTerm, type WCContinent, type WCCountry, type WCCoupon, WCCreateOrderInput, type WCCreateOrderNoteInput, type WCCreateOrderRefundInput, type WCCurrency, WCCustomer, type WCProductAttribute as WCGlobalProductAttribute, WCImage, WCOrder, type WCOrderNote, type WCOrderRefund, type WCPaymentGateway, type WCPaymentGatewaySetting, WCProduct, type WCProductCategory, WCProductFilterParams, type WCProductReview, type WCProductReviewFilterParams, type WCProductStatus, type WCProductTag, WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCRefundLineItem, type WCReviewStatus, type WCSalesReport, type WCSalesReportParams, type WCSettingGroup, type WCSettingOption, type WCShippingClass, type WCShippingMethod, type WCShippingZone, type WCShippingZoneLocation, type WCShippingZoneMethod, type WCStatusCount, type WCSystemStatus, type WCSystemStatusTool, type WCTaxClass, type WCTaxRate, type WCTopSeller, type WCTopSellersParams, type WCWebhook, type WCWebhookStatus, type WCWebhookTopic, WPEntity, WPGraphQLConfig, type WPGraphQLFetcher, WPULikeCheckParams, WPULikeCheckResponse, WPULikeStats, WPULikeStatsParams, WPULikeVoteParams, WPULikeVoteResponse, WooCommerceConfig, type WooCommerceFetcher, WooCommerceResponse, 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, extractOmnibusData, resolveBaseUrl, validateJwtToken, withOmnibus, withOmnibusVariation };
|
|
2071
|
+
export { AddProductToTIWishlistInput, AddProductToWishlistInput, Author, CF7SubmissionResponse, type Category, type Comment, type CommentAuthorAvatar, type CreateAttributeTermInput, type CreateAuthorInput, type CreateCategoryInput, type CreateCommentInput, type CreateCouponInput, type CreateMenuInput, type CreateMenuItemInput, type CreatePageInput, type CreatePostInput, type CreateProductAttributeInput, type CreateProductCategoryInput, type CreateProductInput, type CreateProductReviewInput, type CreateProductTagInput, type CreateShippingClassInput, type CreateShippingZoneInput, type CreateShippingZoneMethodInput, CreateTIWishlistInput, type CreateTagInput, type CreateTaxClassInput, type CreateTaxRateInput, type CreateWebhookInput, CreateWishlistInput, ErrorCode, type FaustConfig, type FaustPreviewConfig, type FaustPreviewDeps, FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, GQLConnection, type GQLCreateCommentInput, type GQLCreateCommentResult, type GQLCreatePostInput, type GQLCustomer, type GQLDeletePostResult, type GQLLineItem, type GQLMutatedComment, type GQLMutatedPost, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageWithSEO, GQLPost, GQLPostFilter, type GQLPostStatus, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, GQLResetUserPasswordInput, GQLResetUserPasswordResult, GQLSendPasswordResetEmailInput, GQLSendPasswordResetEmailResult, type GQLTag, type GQLUpdatePostInput, type GQLYoastSEO, GetTIWishlistProductsParams, JwtAuthCredentials, JwtAuthResponse, type Menu, type MenuItem, type MenuLocation, type MenuWithItems, NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, Post, RenderedContent, RenderedTitle, type RestPageStatus, type RestPostStatus, type RevalidationConfig, type RevalidationPayload, type RevalidationResult, TIWishlist, TIWishlistConfig, TIWishlistError, type TIWishlistFetcher, TIWishlistItem, type Tag, Taxonomy, type UpdateAttributeTermInput, type UpdateAuthorInput, type UpdateCategoryInput, type UpdateCommentInput, type UpdateCouponInput, UpdateCustomerInput, type UpdateMediaInput, type UpdateMenuInput, type UpdateMenuItemInput, type UpdatePageInput, type UpdatePostInput, type UpdateProductAttributeInput, type UpdateProductCategoryInput, type UpdateProductInput, type UpdateProductReviewInput, type UpdateProductTagInput, type UpdateShippingClassInput, type UpdateShippingZoneInput, type UpdateShippingZoneMethodInput, UpdateTIWishlistInput, type UpdateTagInput, type UpdateTaxRateInput, type UpdateWebhookInput, UpdateWishlistInput, type UploadMediaInput, WCAddress, type WCAttributeTerm, type WCContinent, type WCCountry, type WCCoupon, WCCreateOrderInput, type WCCreateOrderNoteInput, type WCCreateOrderRefundInput, type WCCurrency, WCCustomer, type WCProductAttribute as WCGlobalProductAttribute, WCImage, WCOrder, type WCOrderNote, type WCOrderRefund, type WCPaymentGateway, type WCPaymentGatewaySetting, WCProduct, type WCProductCategory, WCProductFilterParams, type WCProductReview, type WCProductReviewFilterParams, type WCProductStatus, type WCProductTag, WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCRefundLineItem, type WCReviewStatus, type WCSalesReport, type WCSalesReportParams, type WCSettingGroup, type WCSettingOption, type WCShippingClass, type WCShippingMethod, type WCShippingZone, type WCShippingZoneLocation, type WCShippingZoneMethod, type WCStatusCount, type WCSystemStatus, type WCSystemStatusTool, type WCTaxClass, type WCTaxRate, type WCTopSeller, type WCTopSellersParams, type WCWebhook, type WCWebhookStatus, type WCWebhookTopic, WCWishlist, WPEntity, WPGraphQLConfig, type WPGraphQLFetcher, WPULikeCheckParams, WPULikeCheckResponse, WPULikeStats, WPULikeStatsParams, WPULikeVoteParams, WPULikeVoteResponse, WooCommerceConfig, type WooCommerceFetcher, WooCommerceResponse, YithWishlistConfig, YithWishlistError, type YithWishlistFetcher, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTIWishlistFetcher, createTIWishlistMutations, createTIWishlistQueries, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWishlistMutations, createWishlistQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYithWishlistFetcher, createYoastQueries, extractOmnibusData, resolveBaseUrl, validateJwtToken, withOmnibus, withOmnibusVariation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NextWordpressConfig, J as JwtAuthCredentials,
|
|
2
|
-
export {
|
|
1
|
+
import { N as NextWordpressConfig, J as JwtAuthCredentials, y as JwtAuthResponse, W as WPGraphQLConfig, c as WordPressResponse, d as WooCommerceConfig, g as WooCommerceResponse, z as Taxonomy, A as WPEntity, B as RenderedTitle, D as RenderedContent, P as Post, E as Author, F as FeaturedMedia, H as RestSendPasswordResetEmailInput, R as RestSendPasswordResetEmailResult, I as RestResetUserPasswordInput, b as RestResetUserPasswordResult, K as WCImage, L as ErrorCode, Y as YithWishlistConfig, k as WCWishlist, M as CreateWishlistInput, O as UpdateWishlistInput, Q as AddProductToWishlistInput, T as TIWishlistConfig, l as TIWishlist, m as GetTIWishlistProductsParams, n as TIWishlistItem, S as CreateTIWishlistInput, V as UpdateTIWishlistInput, X as AddProductToTIWishlistInput, Z as WCProductVariation, e as WCProduct, j as WCCustomer, _ as WCAddress, U as UpdateCustomerInput, h as WCCreateOrderInput, i as WCOrder, f as WCProductFilterParams, r as WPULikeStatsParams, s as WPULikeStats, v as WPULikeCheckParams, w as WPULikeCheckResponse, $ as WPULikeVoteParams, u as WPULikeVoteResponse, x as CF7SubmissionResponse, a0 as GQLSendPasswordResetEmailInput, G as GQLSendPasswordResetEmailResult, a1 as GQLResetUserPasswordInput, a as GQLResetUserPasswordResult, q as GQLConnection, p as GQLPostFilter, o as GQLPost } from './types-DmNIXJNR.js';
|
|
2
|
+
export { a2 as AuthenticationError, a3 as BlockType, a4 as CF7Error, a5 as CF7SubmissionStatus, a6 as CF7ValidationError, C as CookieConsentCategories, a7 as CookieConsentConfig, a8 as EditorBlock, a9 as EmbeddedAuthor, aa as EmbeddedTerm, ab as GQLError, ac as GQLPageInfo, ad as MediaDetails, ae as MediaSize, af as PostEmbedded, ag as SearchResult, ah as TemplatePart, ai as WCDimensions, aj as WCOrderLineItem, ak as WCProductAttribute, al as WCProductDefaultAttribute, am as WCShippingLine, an as WCWishlistItem, ao as WPGraphQLError, ap as WPULikeItemType, t as WPULikeStatus, aq as WooCommerceError, ar as WooCommercePaginationHeaders, as as WordPressAPIError, at as createCookieConsentHandler, au as defaultMessages, av as defaultMessagesPl, aw as parseCookieConsent, ax as resolveMessage } from './types-DmNIXJNR.js';
|
|
3
3
|
|
|
4
4
|
declare function createApplicationPasswordToken(username: string, appPassword: string): string;
|
|
5
5
|
|
|
@@ -1023,6 +1023,64 @@ interface WCPaymentGateway {
|
|
|
1023
1023
|
settings: Record<string, WCPaymentGatewaySetting>;
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
+
declare class YithWishlistError extends Error {
|
|
1027
|
+
readonly code: ErrorCode;
|
|
1028
|
+
readonly status: number;
|
|
1029
|
+
readonly url: string;
|
|
1030
|
+
readonly upstreamCode?: string | undefined;
|
|
1031
|
+
readonly upstreamMessage?: string | undefined;
|
|
1032
|
+
constructor(code: ErrorCode, status: number, url: string, message: string, upstreamCode?: string | undefined, upstreamMessage?: string | undefined);
|
|
1033
|
+
}
|
|
1034
|
+
declare function createYithWishlistFetcher(config: YithWishlistConfig): {
|
|
1035
|
+
yithFetch: <T>(path: string, tags?: string[], options?: RequestInit) => Promise<T>;
|
|
1036
|
+
yithFetchGraceful: <T>(path: string, fallback: T, tags?: string[]) => Promise<T>;
|
|
1037
|
+
yithMutate: <T>(path: string, body: unknown, method?: "POST" | "PATCH" | "DELETE") => Promise<T>;
|
|
1038
|
+
};
|
|
1039
|
+
type YithWishlistFetcher = ReturnType<typeof createYithWishlistFetcher>;
|
|
1040
|
+
|
|
1041
|
+
declare function createWishlistQueries(fetcher: YithWishlistFetcher): {
|
|
1042
|
+
getWishlists: () => Promise<WCWishlist[]>;
|
|
1043
|
+
getWishlistByToken: (token: string) => Promise<WCWishlist>;
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
declare function createWishlistMutations(fetcher: YithWishlistFetcher): {
|
|
1047
|
+
createWishlist: (input: CreateWishlistInput) => Promise<WCWishlist>;
|
|
1048
|
+
updateWishlist: (token: string, input: UpdateWishlistInput) => Promise<WCWishlist>;
|
|
1049
|
+
deleteWishlist: (token: string) => Promise<{
|
|
1050
|
+
deleted: boolean;
|
|
1051
|
+
previous: WCWishlist;
|
|
1052
|
+
}>;
|
|
1053
|
+
addProductToWishlist: (token: string, input: AddProductToWishlistInput) => Promise<WCWishlist>;
|
|
1054
|
+
removeProductFromWishlist: (token: string, productId: number) => Promise<WCWishlist>;
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
declare class TIWishlistError extends Error {
|
|
1058
|
+
readonly code: ErrorCode;
|
|
1059
|
+
readonly status: number;
|
|
1060
|
+
readonly url: string;
|
|
1061
|
+
constructor(code: ErrorCode, status: number, url: string, message: string);
|
|
1062
|
+
}
|
|
1063
|
+
declare function createTIWishlistFetcher(config: TIWishlistConfig): {
|
|
1064
|
+
tiFetch: <T>(path: string, tags?: string[], options?: RequestInit) => Promise<T>;
|
|
1065
|
+
tiFetchGraceful: <T>(path: string, fallback: T, tags?: string[]) => Promise<T>;
|
|
1066
|
+
tiMutate: <T>(path: string, body: unknown, method?: "POST") => Promise<T>;
|
|
1067
|
+
};
|
|
1068
|
+
type TIWishlistFetcher = ReturnType<typeof createTIWishlistFetcher>;
|
|
1069
|
+
|
|
1070
|
+
declare function createTIWishlistQueries(fetcher: TIWishlistFetcher): {
|
|
1071
|
+
getWishlistsByUser: (userId: number) => Promise<TIWishlist[]>;
|
|
1072
|
+
getWishlistByShareKey: (shareKey: string) => Promise<TIWishlist>;
|
|
1073
|
+
getWishlistProducts: (shareKey: string, params?: GetTIWishlistProductsParams) => Promise<TIWishlistItem[]>;
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
declare function createTIWishlistMutations(fetcher: TIWishlistFetcher): {
|
|
1077
|
+
createWishlist: (input: CreateTIWishlistInput) => Promise<TIWishlist>;
|
|
1078
|
+
updateWishlist: (shareKey: string, input: UpdateTIWishlistInput) => Promise<TIWishlist>;
|
|
1079
|
+
deleteWishlist: (shareKey: string) => Promise<string>;
|
|
1080
|
+
addProduct: (shareKey: string, input: AddProductToTIWishlistInput) => Promise<TIWishlistItem[]>;
|
|
1081
|
+
removeProduct: (itemId: number) => Promise<string>;
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1026
1084
|
interface OmnibusPriceEntry {
|
|
1027
1085
|
price: string;
|
|
1028
1086
|
date: string;
|
|
@@ -2010,4 +2068,4 @@ interface FaustPreviewDeps {
|
|
|
2010
2068
|
declare function createFaustAuthHandler(config: FaustConfig): (request: Request, routePath: string) => Promise<Response>;
|
|
2011
2069
|
declare function createPreviewHandler(config: FaustPreviewConfig, deps: FaustPreviewDeps): (request: Request) => Promise<Response>;
|
|
2012
2070
|
|
|
2013
|
-
export { Author, CF7SubmissionResponse, type Category, type Comment, type CommentAuthorAvatar, type CreateAttributeTermInput, type CreateAuthorInput, type CreateCategoryInput, type CreateCommentInput, type CreateCouponInput, type CreateMenuInput, type CreateMenuItemInput, type CreatePageInput, type CreatePostInput, type CreateProductAttributeInput, type CreateProductCategoryInput, type CreateProductInput, type CreateProductReviewInput, type CreateProductTagInput, type CreateShippingClassInput, type CreateShippingZoneInput, type CreateShippingZoneMethodInput, type CreateTagInput, type CreateTaxClassInput, type CreateTaxRateInput, type CreateWebhookInput, type FaustConfig, type FaustPreviewConfig, type FaustPreviewDeps, FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, GQLConnection, type GQLCreateCommentInput, type GQLCreateCommentResult, type GQLCreatePostInput, type GQLCustomer, type GQLDeletePostResult, type GQLLineItem, type GQLMutatedComment, type GQLMutatedPost, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageWithSEO, GQLPost, GQLPostFilter, type GQLPostStatus, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, GQLResetUserPasswordInput, GQLResetUserPasswordResult, GQLSendPasswordResetEmailInput, GQLSendPasswordResetEmailResult, type GQLTag, type GQLUpdatePostInput, type GQLYoastSEO, JwtAuthCredentials, JwtAuthResponse, type Menu, type MenuItem, type MenuLocation, type MenuWithItems, NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, Post, RenderedContent, RenderedTitle, type RestPageStatus, type RestPostStatus, type RevalidationConfig, type RevalidationPayload, type RevalidationResult, type Tag, Taxonomy, type UpdateAttributeTermInput, type UpdateAuthorInput, type UpdateCategoryInput, type UpdateCommentInput, type UpdateCouponInput, UpdateCustomerInput, type UpdateMediaInput, type UpdateMenuInput, type UpdateMenuItemInput, type UpdatePageInput, type UpdatePostInput, type UpdateProductAttributeInput, type UpdateProductCategoryInput, type UpdateProductInput, type UpdateProductReviewInput, type UpdateProductTagInput, type UpdateShippingClassInput, type UpdateShippingZoneInput, type UpdateShippingZoneMethodInput, type UpdateTagInput, type UpdateTaxRateInput, type UpdateWebhookInput, type UploadMediaInput, WCAddress, type WCAttributeTerm, type WCContinent, type WCCountry, type WCCoupon, WCCreateOrderInput, type WCCreateOrderNoteInput, type WCCreateOrderRefundInput, type WCCurrency, WCCustomer, type WCProductAttribute as WCGlobalProductAttribute, WCImage, WCOrder, type WCOrderNote, type WCOrderRefund, type WCPaymentGateway, type WCPaymentGatewaySetting, WCProduct, type WCProductCategory, WCProductFilterParams, type WCProductReview, type WCProductReviewFilterParams, type WCProductStatus, type WCProductTag, WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCRefundLineItem, type WCReviewStatus, type WCSalesReport, type WCSalesReportParams, type WCSettingGroup, type WCSettingOption, type WCShippingClass, type WCShippingMethod, type WCShippingZone, type WCShippingZoneLocation, type WCShippingZoneMethod, type WCStatusCount, type WCSystemStatus, type WCSystemStatusTool, type WCTaxClass, type WCTaxRate, type WCTopSeller, type WCTopSellersParams, type WCWebhook, type WCWebhookStatus, type WCWebhookTopic, WPEntity, WPGraphQLConfig, type WPGraphQLFetcher, WPULikeCheckParams, WPULikeCheckResponse, WPULikeStats, WPULikeStatsParams, WPULikeVoteParams, WPULikeVoteResponse, WooCommerceConfig, type WooCommerceFetcher, WooCommerceResponse, 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, extractOmnibusData, resolveBaseUrl, validateJwtToken, withOmnibus, withOmnibusVariation };
|
|
2071
|
+
export { AddProductToTIWishlistInput, AddProductToWishlistInput, Author, CF7SubmissionResponse, type Category, type Comment, type CommentAuthorAvatar, type CreateAttributeTermInput, type CreateAuthorInput, type CreateCategoryInput, type CreateCommentInput, type CreateCouponInput, type CreateMenuInput, type CreateMenuItemInput, type CreatePageInput, type CreatePostInput, type CreateProductAttributeInput, type CreateProductCategoryInput, type CreateProductInput, type CreateProductReviewInput, type CreateProductTagInput, type CreateShippingClassInput, type CreateShippingZoneInput, type CreateShippingZoneMethodInput, CreateTIWishlistInput, type CreateTagInput, type CreateTaxClassInput, type CreateTaxRateInput, type CreateWebhookInput, CreateWishlistInput, ErrorCode, type FaustConfig, type FaustPreviewConfig, type FaustPreviewDeps, FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, GQLConnection, type GQLCreateCommentInput, type GQLCreateCommentResult, type GQLCreatePostInput, type GQLCustomer, type GQLDeletePostResult, type GQLLineItem, type GQLMutatedComment, type GQLMutatedPost, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageWithSEO, GQLPost, GQLPostFilter, type GQLPostStatus, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, GQLResetUserPasswordInput, GQLResetUserPasswordResult, GQLSendPasswordResetEmailInput, GQLSendPasswordResetEmailResult, type GQLTag, type GQLUpdatePostInput, type GQLYoastSEO, GetTIWishlistProductsParams, JwtAuthCredentials, JwtAuthResponse, type Menu, type MenuItem, type MenuLocation, type MenuWithItems, NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, Post, RenderedContent, RenderedTitle, type RestPageStatus, type RestPostStatus, type RevalidationConfig, type RevalidationPayload, type RevalidationResult, TIWishlist, TIWishlistConfig, TIWishlistError, type TIWishlistFetcher, TIWishlistItem, type Tag, Taxonomy, type UpdateAttributeTermInput, type UpdateAuthorInput, type UpdateCategoryInput, type UpdateCommentInput, type UpdateCouponInput, UpdateCustomerInput, type UpdateMediaInput, type UpdateMenuInput, type UpdateMenuItemInput, type UpdatePageInput, type UpdatePostInput, type UpdateProductAttributeInput, type UpdateProductCategoryInput, type UpdateProductInput, type UpdateProductReviewInput, type UpdateProductTagInput, type UpdateShippingClassInput, type UpdateShippingZoneInput, type UpdateShippingZoneMethodInput, UpdateTIWishlistInput, type UpdateTagInput, type UpdateTaxRateInput, type UpdateWebhookInput, UpdateWishlistInput, type UploadMediaInput, WCAddress, type WCAttributeTerm, type WCContinent, type WCCountry, type WCCoupon, WCCreateOrderInput, type WCCreateOrderNoteInput, type WCCreateOrderRefundInput, type WCCurrency, WCCustomer, type WCProductAttribute as WCGlobalProductAttribute, WCImage, WCOrder, type WCOrderNote, type WCOrderRefund, type WCPaymentGateway, type WCPaymentGatewaySetting, WCProduct, type WCProductCategory, WCProductFilterParams, type WCProductReview, type WCProductReviewFilterParams, type WCProductStatus, type WCProductTag, WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCRefundLineItem, type WCReviewStatus, type WCSalesReport, type WCSalesReportParams, type WCSettingGroup, type WCSettingOption, type WCShippingClass, type WCShippingMethod, type WCShippingZone, type WCShippingZoneLocation, type WCShippingZoneMethod, type WCStatusCount, type WCSystemStatus, type WCSystemStatusTool, type WCTaxClass, type WCTaxRate, type WCTopSeller, type WCTopSellersParams, type WCWebhook, type WCWebhookStatus, type WCWebhookTopic, WCWishlist, WPEntity, WPGraphQLConfig, type WPGraphQLFetcher, WPULikeCheckParams, WPULikeCheckResponse, WPULikeStats, WPULikeStatsParams, WPULikeVoteParams, WPULikeVoteResponse, WooCommerceConfig, type WooCommerceFetcher, WooCommerceResponse, YithWishlistConfig, YithWishlistError, type YithWishlistFetcher, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTIWishlistFetcher, createTIWishlistMutations, createTIWishlistQueries, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWishlistMutations, createWishlistQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYithWishlistFetcher, createYoastQueries, extractOmnibusData, resolveBaseUrl, validateJwtToken, withOmnibus, withOmnibusVariation };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,8 @@ var ErrorCode = {
|
|
|
33
33
|
WOO_REVIEW_NOT_FOUND: "WOO_REVIEW_NOT_FOUND",
|
|
34
34
|
WOO_WEBHOOK_NOT_FOUND: "WOO_WEBHOOK_NOT_FOUND",
|
|
35
35
|
WOO_SHIPPING_ZONE_NOT_FOUND: "WOO_SHIPPING_ZONE_NOT_FOUND",
|
|
36
|
+
WOO_WISHLIST_NOT_FOUND: "WOO_WISHLIST_NOT_FOUND",
|
|
37
|
+
WOO_WISHLIST_ITEM_NOT_FOUND: "WOO_WISHLIST_ITEM_NOT_FOUND",
|
|
36
38
|
// Auth
|
|
37
39
|
AUTH_JWT_FAILED: "AUTH_JWT_FAILED",
|
|
38
40
|
AUTH_CREDENTIALS_INVALID: "AUTH_CREDENTIALS_INVALID",
|
|
@@ -67,6 +69,8 @@ var defaultMessages = {
|
|
|
67
69
|
WOO_REVIEW_NOT_FOUND: "Product review not found",
|
|
68
70
|
WOO_WEBHOOK_NOT_FOUND: "Webhook not found",
|
|
69
71
|
WOO_SHIPPING_ZONE_NOT_FOUND: "Shipping zone not found",
|
|
72
|
+
WOO_WISHLIST_NOT_FOUND: "Wishlist not found",
|
|
73
|
+
WOO_WISHLIST_ITEM_NOT_FOUND: "Wishlist item not found",
|
|
70
74
|
AUTH_JWT_FAILED: "JWT authentication failed",
|
|
71
75
|
AUTH_CREDENTIALS_INVALID: "Invalid credentials",
|
|
72
76
|
AUTH_TOKEN_INVALID: "JWT token is invalid or expired",
|
|
@@ -99,6 +103,8 @@ var defaultMessagesPl = {
|
|
|
99
103
|
WOO_REVIEW_NOT_FOUND: "Opinia o produkcie nie istnieje",
|
|
100
104
|
WOO_WEBHOOK_NOT_FOUND: "Webhook nie istnieje",
|
|
101
105
|
WOO_SHIPPING_ZONE_NOT_FOUND: "Strefa wysy\u0142ki nie istnieje",
|
|
106
|
+
WOO_WISHLIST_NOT_FOUND: "Lista \u017Cycze\u0144 nie istnieje",
|
|
107
|
+
WOO_WISHLIST_ITEM_NOT_FOUND: "Element listy \u017Cycze\u0144 nie istnieje",
|
|
102
108
|
AUTH_JWT_FAILED: "B\u0142\u0105d uwierzytelnienia JWT",
|
|
103
109
|
AUTH_CREDENTIALS_INVALID: "Nieprawid\u0142owe dane logowania",
|
|
104
110
|
AUTH_TOKEN_INVALID: "Token JWT jest nieprawid\u0142owy lub wygas\u0142",
|
|
@@ -803,6 +809,264 @@ function createWordPressClient(config) {
|
|
|
803
809
|
};
|
|
804
810
|
}
|
|
805
811
|
|
|
812
|
+
// src/integrations/restApi/woocommerce/wishlist/fetcher.ts
|
|
813
|
+
var USER_AGENT2 = "NextWordpress YITH Wishlist Client";
|
|
814
|
+
var DEFAULT_CACHE_TTL = 3600;
|
|
815
|
+
var YithWishlistError = class extends Error {
|
|
816
|
+
constructor(code, status, url, message, upstreamCode, upstreamMessage) {
|
|
817
|
+
super(message);
|
|
818
|
+
__publicField(this, "code", code);
|
|
819
|
+
__publicField(this, "status", status);
|
|
820
|
+
__publicField(this, "url", url);
|
|
821
|
+
__publicField(this, "upstreamCode", upstreamCode);
|
|
822
|
+
__publicField(this, "upstreamMessage", upstreamMessage);
|
|
823
|
+
this.name = "YithWishlistError";
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
function resolveYithErrorCode(status, upstreamCode) {
|
|
827
|
+
if (status === 401) return ErrorCode.WOO_UNAUTHORIZED;
|
|
828
|
+
if (status === 403) return ErrorCode.WOO_FORBIDDEN;
|
|
829
|
+
if (status === 404) {
|
|
830
|
+
if (upstreamCode === "yith_wcwl_wishlist_not_found") return ErrorCode.WOO_WISHLIST_NOT_FOUND;
|
|
831
|
+
if (upstreamCode === "yith_wcwl_wishlist_item_not_found")
|
|
832
|
+
return ErrorCode.WOO_WISHLIST_ITEM_NOT_FOUND;
|
|
833
|
+
return ErrorCode.WOO_NOT_FOUND;
|
|
834
|
+
}
|
|
835
|
+
return ErrorCode.WOO_REQUEST_FAILED;
|
|
836
|
+
}
|
|
837
|
+
function createYithWishlistFetcher(config) {
|
|
838
|
+
const cacheTTL = config.cacheTTL ?? DEFAULT_CACHE_TTL;
|
|
839
|
+
function buildUrl2(path) {
|
|
840
|
+
const base = typeof window !== "undefined" && config.clientURL ? config.clientURL : config.serverURL;
|
|
841
|
+
return `${base}${path}`;
|
|
842
|
+
}
|
|
843
|
+
function authHeaders() {
|
|
844
|
+
return {
|
|
845
|
+
"User-Agent": USER_AGENT2,
|
|
846
|
+
"Content-Type": "application/json",
|
|
847
|
+
Authorization: `Bearer ${config.token}`
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
async function throwYithError(response, url) {
|
|
851
|
+
const body = await response.json().catch(() => ({}));
|
|
852
|
+
const errorCode = resolveYithErrorCode(response.status, body.code);
|
|
853
|
+
throw new YithWishlistError(
|
|
854
|
+
errorCode,
|
|
855
|
+
response.status,
|
|
856
|
+
url,
|
|
857
|
+
resolveMessage(errorCode, config.errorMessages),
|
|
858
|
+
body.code,
|
|
859
|
+
body.message
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
async function yithFetch(path, tags = ["yith-wishlist"], options) {
|
|
863
|
+
const url = buildUrl2(path);
|
|
864
|
+
const isMutation = options?.method && options.method !== "GET";
|
|
865
|
+
const response = await fetch(url, {
|
|
866
|
+
...options,
|
|
867
|
+
headers: {
|
|
868
|
+
...authHeaders(),
|
|
869
|
+
...options?.headers
|
|
870
|
+
},
|
|
871
|
+
next: isMutation ? void 0 : { tags, revalidate: cacheTTL }
|
|
872
|
+
});
|
|
873
|
+
if (!response.ok) {
|
|
874
|
+
await throwYithError(response, url);
|
|
875
|
+
}
|
|
876
|
+
return response.json();
|
|
877
|
+
}
|
|
878
|
+
async function yithFetchGraceful(path, fallback, tags = ["yith-wishlist"]) {
|
|
879
|
+
try {
|
|
880
|
+
return await yithFetch(path, tags);
|
|
881
|
+
} catch (err) {
|
|
882
|
+
console.warn(`YITH Wishlist fetch failed for ${path}`, err);
|
|
883
|
+
return fallback;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
async function yithMutate(path, body, method = "POST") {
|
|
887
|
+
return yithFetch(path, ["yith-wishlist"], {
|
|
888
|
+
method,
|
|
889
|
+
body: JSON.stringify(body)
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
return { yithFetch, yithFetchGraceful, yithMutate };
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// src/integrations/restApi/woocommerce/wishlist/queries.ts
|
|
896
|
+
var BASE = "/wp-json/yith/wishlist/v1/wishlists";
|
|
897
|
+
function createWishlistQueries(fetcher) {
|
|
898
|
+
const { yithFetch, yithFetchGraceful } = fetcher;
|
|
899
|
+
async function getWishlists() {
|
|
900
|
+
return yithFetchGraceful(BASE, [], ["yith-wishlist", "wishlists"]);
|
|
901
|
+
}
|
|
902
|
+
async function getWishlistByToken(token) {
|
|
903
|
+
return yithFetch(`${BASE}/${token}`, ["yith-wishlist", "wishlists", `wishlist-${token}`]);
|
|
904
|
+
}
|
|
905
|
+
return { getWishlists, getWishlistByToken };
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// src/integrations/restApi/woocommerce/wishlist/mutations.ts
|
|
909
|
+
var BASE2 = "/wp-json/yith/wishlist/v1/wishlists";
|
|
910
|
+
function createWishlistMutations(fetcher) {
|
|
911
|
+
const { yithMutate } = fetcher;
|
|
912
|
+
async function createWishlist(input) {
|
|
913
|
+
return yithMutate(BASE2, input, "POST");
|
|
914
|
+
}
|
|
915
|
+
async function updateWishlist(token, input) {
|
|
916
|
+
return yithMutate(`${BASE2}/${token}`, input, "PATCH");
|
|
917
|
+
}
|
|
918
|
+
async function deleteWishlist(token) {
|
|
919
|
+
return yithMutate(
|
|
920
|
+
`${BASE2}/${token}`,
|
|
921
|
+
{},
|
|
922
|
+
"DELETE"
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
async function addProductToWishlist(token, input) {
|
|
926
|
+
return yithMutate(`${BASE2}/${token}/add-product`, input, "POST");
|
|
927
|
+
}
|
|
928
|
+
async function removeProductFromWishlist(token, productId) {
|
|
929
|
+
return yithMutate(
|
|
930
|
+
`${BASE2}/${token}/remove-product/${productId}`,
|
|
931
|
+
{},
|
|
932
|
+
"DELETE"
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
return {
|
|
936
|
+
createWishlist,
|
|
937
|
+
updateWishlist,
|
|
938
|
+
deleteWishlist,
|
|
939
|
+
addProductToWishlist,
|
|
940
|
+
removeProductFromWishlist
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// src/integrations/restApi/woocommerce/ti_wishlist/fetcher.ts
|
|
945
|
+
var USER_AGENT3 = "NextWordpress TI Wishlist Client";
|
|
946
|
+
var DEFAULT_CACHE_TTL2 = 3600;
|
|
947
|
+
var TIWishlistError = class extends Error {
|
|
948
|
+
constructor(code, status, url, message) {
|
|
949
|
+
super(message);
|
|
950
|
+
__publicField(this, "code", code);
|
|
951
|
+
__publicField(this, "status", status);
|
|
952
|
+
__publicField(this, "url", url);
|
|
953
|
+
this.name = "TIWishlistError";
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
function resolveTIErrorCode(status) {
|
|
957
|
+
if (status === 401) return ErrorCode.WOO_UNAUTHORIZED;
|
|
958
|
+
if (status === 403) return ErrorCode.WOO_FORBIDDEN;
|
|
959
|
+
if (status === 404) return ErrorCode.WOO_WISHLIST_NOT_FOUND;
|
|
960
|
+
return ErrorCode.WOO_REQUEST_FAILED;
|
|
961
|
+
}
|
|
962
|
+
function createTIWishlistFetcher(config) {
|
|
963
|
+
const cacheTTL = config.cacheTTL ?? DEFAULT_CACHE_TTL2;
|
|
964
|
+
function buildUrl2(path) {
|
|
965
|
+
const base = typeof window !== "undefined" && config.clientURL ? config.clientURL : config.serverURL;
|
|
966
|
+
return `${base}${path}`;
|
|
967
|
+
}
|
|
968
|
+
function authHeaders() {
|
|
969
|
+
return {
|
|
970
|
+
"User-Agent": USER_AGENT3,
|
|
971
|
+
"Content-Type": "application/json",
|
|
972
|
+
Authorization: `Bearer ${config.token}`
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
async function throwTIError(response, url) {
|
|
976
|
+
const errorCode = resolveTIErrorCode(response.status);
|
|
977
|
+
throw new TIWishlistError(
|
|
978
|
+
errorCode,
|
|
979
|
+
response.status,
|
|
980
|
+
url,
|
|
981
|
+
resolveMessage(errorCode, config.errorMessages)
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
async function tiFetch(path, tags = ["ti-wishlist"], options) {
|
|
985
|
+
const url = buildUrl2(path);
|
|
986
|
+
const isMutation = options?.method && options.method !== "GET";
|
|
987
|
+
const response = await fetch(url, {
|
|
988
|
+
...options,
|
|
989
|
+
headers: {
|
|
990
|
+
...authHeaders(),
|
|
991
|
+
...options?.headers
|
|
992
|
+
},
|
|
993
|
+
next: isMutation ? void 0 : { tags, revalidate: cacheTTL }
|
|
994
|
+
});
|
|
995
|
+
if (!response.ok) {
|
|
996
|
+
await throwTIError(response, url);
|
|
997
|
+
}
|
|
998
|
+
return response.json();
|
|
999
|
+
}
|
|
1000
|
+
async function tiFetchGraceful(path, fallback, tags = ["ti-wishlist"]) {
|
|
1001
|
+
try {
|
|
1002
|
+
return await tiFetch(path, tags);
|
|
1003
|
+
} catch (err) {
|
|
1004
|
+
console.warn(`TI Wishlist fetch failed for ${path}`, err);
|
|
1005
|
+
return fallback;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
async function tiMutate(path, body, method = "POST") {
|
|
1009
|
+
return tiFetch(path, ["ti-wishlist"], {
|
|
1010
|
+
method,
|
|
1011
|
+
body: JSON.stringify(body)
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
return { tiFetch, tiFetchGraceful, tiMutate };
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// src/integrations/restApi/woocommerce/ti_wishlist/queries.ts
|
|
1018
|
+
var BASE3 = "/wp-json/wc/v3/wishlist";
|
|
1019
|
+
function createTIWishlistQueries(fetcher) {
|
|
1020
|
+
const { tiFetch, tiFetchGraceful } = fetcher;
|
|
1021
|
+
async function getWishlistsByUser(userId) {
|
|
1022
|
+
return tiFetchGraceful(
|
|
1023
|
+
`${BASE3}/get_by_user/${userId}`,
|
|
1024
|
+
[],
|
|
1025
|
+
["ti-wishlist", `ti-wishlists-user-${userId}`]
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
async function getWishlistByShareKey(shareKey) {
|
|
1029
|
+
return tiFetch(`${BASE3}/get_by_share_key/${shareKey}`, [
|
|
1030
|
+
"ti-wishlist",
|
|
1031
|
+
`ti-wishlist-${shareKey}`
|
|
1032
|
+
]);
|
|
1033
|
+
}
|
|
1034
|
+
async function getWishlistProducts(shareKey, params) {
|
|
1035
|
+
const query = new URLSearchParams();
|
|
1036
|
+
if (params?.count != null) query.set("count", String(params.count));
|
|
1037
|
+
if (params?.offset != null) query.set("offset", String(params.offset));
|
|
1038
|
+
if (params?.order != null) query.set("order", params.order);
|
|
1039
|
+
const qs = query.toString() ? `?${query.toString()}` : "";
|
|
1040
|
+
return tiFetch(`${BASE3}/${shareKey}/get_products${qs}`, [
|
|
1041
|
+
"ti-wishlist",
|
|
1042
|
+
`ti-wishlist-products-${shareKey}`
|
|
1043
|
+
]);
|
|
1044
|
+
}
|
|
1045
|
+
return { getWishlistsByUser, getWishlistByShareKey, getWishlistProducts };
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// src/integrations/restApi/woocommerce/ti_wishlist/mutations.ts
|
|
1049
|
+
var BASE4 = "/wp-json/wc/v3/wishlist";
|
|
1050
|
+
function createTIWishlistMutations(fetcher) {
|
|
1051
|
+
const { tiFetch, tiMutate } = fetcher;
|
|
1052
|
+
async function createWishlist(input) {
|
|
1053
|
+
return tiMutate(`${BASE4}/create`, input);
|
|
1054
|
+
}
|
|
1055
|
+
async function updateWishlist(shareKey, input) {
|
|
1056
|
+
return tiMutate(`${BASE4}/update/${shareKey}`, input);
|
|
1057
|
+
}
|
|
1058
|
+
async function deleteWishlist(shareKey) {
|
|
1059
|
+
return tiFetch(`${BASE4}/delete/${shareKey}`, ["ti-wishlist"]);
|
|
1060
|
+
}
|
|
1061
|
+
async function addProduct(shareKey, input) {
|
|
1062
|
+
return tiMutate(`${BASE4}/${shareKey}/add_product`, input);
|
|
1063
|
+
}
|
|
1064
|
+
async function removeProduct(itemId) {
|
|
1065
|
+
return tiFetch(`${BASE4}/remove_product/${itemId}`, ["ti-wishlist"]);
|
|
1066
|
+
}
|
|
1067
|
+
return { createWishlist, updateWishlist, deleteWishlist, addProduct, removeProduct };
|
|
1068
|
+
}
|
|
1069
|
+
|
|
806
1070
|
// src/integrations/restApi/woocommerce/omnibus/queries.ts
|
|
807
1071
|
var META_KEY_LOWEST_PRICE = "wpo_lowest_price";
|
|
808
1072
|
var META_KEY_PRICE_HISTORY = "_alg_wc_price_history";
|
|
@@ -869,8 +1133,8 @@ function resolveWooErrorCode(status, upstreamCode) {
|
|
|
869
1133
|
}
|
|
870
1134
|
|
|
871
1135
|
// src/integrations/restApi/woocommerce/client/fetcher.ts
|
|
872
|
-
var
|
|
873
|
-
var
|
|
1136
|
+
var USER_AGENT4 = "NextWordpress WooCommerce Client";
|
|
1137
|
+
var DEFAULT_CACHE_TTL3 = 3600;
|
|
874
1138
|
function toQueryString(params) {
|
|
875
1139
|
const pairs = [];
|
|
876
1140
|
for (const [key, value] of Object.entries(params)) {
|
|
@@ -880,7 +1144,7 @@ function toQueryString(params) {
|
|
|
880
1144
|
return pairs.join("&");
|
|
881
1145
|
}
|
|
882
1146
|
function createWooCommerceFetcher(config) {
|
|
883
|
-
const cacheTTL = config.cacheTTL ??
|
|
1147
|
+
const cacheTTL = config.cacheTTL ?? DEFAULT_CACHE_TTL3;
|
|
884
1148
|
function withAuth(query) {
|
|
885
1149
|
return { ...query, consumer_key: config.consumerKey, consumer_secret: config.consumerSecret };
|
|
886
1150
|
}
|
|
@@ -907,7 +1171,7 @@ function createWooCommerceFetcher(config) {
|
|
|
907
1171
|
const response = await fetch(url, {
|
|
908
1172
|
...options,
|
|
909
1173
|
headers: {
|
|
910
|
-
"User-Agent":
|
|
1174
|
+
"User-Agent": USER_AGENT4,
|
|
911
1175
|
"Content-Type": "application/json",
|
|
912
1176
|
...options?.headers
|
|
913
1177
|
},
|
|
@@ -929,7 +1193,7 @@ function createWooCommerceFetcher(config) {
|
|
|
929
1193
|
async function wcFetchPaginated(path, query, tags = ["woocommerce"]) {
|
|
930
1194
|
const url = buildUrl2(path, query);
|
|
931
1195
|
const response = await fetch(url, {
|
|
932
|
-
headers: { "User-Agent":
|
|
1196
|
+
headers: { "User-Agent": USER_AGENT4 },
|
|
933
1197
|
next: { tags, revalidate: cacheTTL }
|
|
934
1198
|
});
|
|
935
1199
|
if (!response.ok) {
|
|
@@ -2215,7 +2479,7 @@ var WPGraphQLError = class extends Error {
|
|
|
2215
2479
|
};
|
|
2216
2480
|
|
|
2217
2481
|
// src/integrations/wpGraphQL/client/fetcher.ts
|
|
2218
|
-
var
|
|
2482
|
+
var USER_AGENT5 = "NextWordpress WPGraphQL Client";
|
|
2219
2483
|
function createWPGraphQLFetcher(config) {
|
|
2220
2484
|
const url = `${resolveBaseUrl(config)}/graphql`;
|
|
2221
2485
|
const cacheTTL = config.cacheTTL ?? 300;
|
|
@@ -2224,7 +2488,7 @@ function createWPGraphQLFetcher(config) {
|
|
|
2224
2488
|
method: "POST",
|
|
2225
2489
|
headers: {
|
|
2226
2490
|
"Content-Type": "application/json",
|
|
2227
|
-
"User-Agent":
|
|
2491
|
+
"User-Agent": USER_AGENT5
|
|
2228
2492
|
},
|
|
2229
2493
|
body: JSON.stringify({ query: document, variables }),
|
|
2230
2494
|
next: { tags, revalidate: cacheTTL }
|
|
@@ -2268,7 +2532,7 @@ function createWPGraphQLFetcher(config) {
|
|
|
2268
2532
|
async function gqlMutate(document, variables, authToken) {
|
|
2269
2533
|
const headers = {
|
|
2270
2534
|
"Content-Type": "application/json",
|
|
2271
|
-
"User-Agent":
|
|
2535
|
+
"User-Agent": USER_AGENT5
|
|
2272
2536
|
};
|
|
2273
2537
|
if (authToken) {
|
|
2274
2538
|
headers["Authorization"] = authToken;
|
|
@@ -4419,6 +4683,6 @@ async function validateJwtToken(config, token) {
|
|
|
4419
4683
|
return response.ok;
|
|
4420
4684
|
}
|
|
4421
4685
|
|
|
4422
|
-
export { AuthenticationError, CF7Error, 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 };
|
|
4686
|
+
export { AuthenticationError, CF7Error, ErrorCode, TIWishlistError, WPGraphQLError, WooCommerceError, WordPressAPIError, YithWishlistError, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createCookieConsentHandler, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTIWishlistFetcher, createTIWishlistMutations, createTIWishlistQueries, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWishlistMutations, createWishlistQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYithWishlistFetcher, createYoastQueries, defaultMessages, defaultMessagesPl, extractOmnibusData, parseCookieConsent, resolveBaseUrl, resolveMessage, validateJwtToken, withOmnibus, withOmnibusVariation };
|
|
4423
4687
|
//# sourceMappingURL=index.js.map
|
|
4424
4688
|
//# sourceMappingURL=index.js.map
|