@szymonpiatek/nextwordpress 0.0.2 → 0.0.3

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/index.d.cts CHANGED
@@ -36,15 +36,6 @@ interface Taxonomy {
36
36
 
37
37
  declare function resolveBaseUrl(config: NextWordpressConfig): string;
38
38
 
39
- interface WordPressPaginationHeaders {
40
- total: number;
41
- totalPages: number;
42
- }
43
- interface WordPressResponse<T> {
44
- data: T;
45
- headers: WordPressPaginationHeaders;
46
- }
47
-
48
39
  interface MediaSize {
49
40
  file: string;
50
41
  width: number;
@@ -205,6 +196,15 @@ interface Post extends WPEntity {
205
196
  _embedded?: PostEmbedded;
206
197
  }
207
198
 
199
+ interface WordPressPaginationHeaders {
200
+ total: number;
201
+ totalPages: number;
202
+ }
203
+ interface WordPressResponse<T> {
204
+ data: T;
205
+ headers: WordPressPaginationHeaders;
206
+ }
207
+
208
208
  interface Category extends Taxonomy {
209
209
  taxonomy: 'category';
210
210
  parent: number;
@@ -228,7 +228,94 @@ interface Page extends WPEntity {
228
228
  meta: Record<string, unknown>;
229
229
  }
230
230
 
231
+ interface Menu {
232
+ id: number;
233
+ description: string;
234
+ name: string;
235
+ slug: string;
236
+ meta: Record<string, unknown>;
237
+ locations: string[];
238
+ auto_add: boolean;
239
+ }
240
+ interface MenuItem {
241
+ id: number;
242
+ title: {
243
+ rendered: string;
244
+ };
245
+ status: string;
246
+ url: string;
247
+ attr_title: string;
248
+ description: string;
249
+ type: string;
250
+ type_label: string;
251
+ object: string;
252
+ object_id: number;
253
+ parent: number;
254
+ menu_order: number;
255
+ target: string;
256
+ classes: string[];
257
+ xfn: string[];
258
+ invalid: boolean;
259
+ menus: number;
260
+ meta: Record<string, unknown>;
261
+ }
262
+ interface MenuLocation {
263
+ name: string;
264
+ description: string;
265
+ menu: number;
266
+ }
267
+ interface MenuWithItems {
268
+ menu: Menu;
269
+ items: MenuItem[];
270
+ }
271
+
272
+ interface CommentAuthorAvatar {
273
+ '24': string;
274
+ '48': string;
275
+ '96': string;
276
+ [size: string]: string;
277
+ }
278
+ interface Comment {
279
+ id: number;
280
+ post: number;
281
+ parent: number;
282
+ author: number;
283
+ author_name: string;
284
+ author_email: string;
285
+ author_url: string;
286
+ author_ip: string;
287
+ author_avatar_urls: CommentAuthorAvatar;
288
+ date: string;
289
+ date_gmt: string;
290
+ content: {
291
+ rendered: string;
292
+ };
293
+ link: string;
294
+ status: 'approve' | 'hold' | 'spam' | 'trash';
295
+ type: string;
296
+ meta: Record<string, unknown>;
297
+ }
298
+ interface CreateCommentInput {
299
+ post: number;
300
+ content: string;
301
+ author_name?: string;
302
+ author_email?: string;
303
+ author_url?: string;
304
+ parent?: number;
305
+ }
306
+
231
307
  declare function createWordPressClient(config: NextWordpressConfig): {
308
+ getCommentsByPostId: (postId: number, page?: number, perPage?: number) => Promise<WordPressResponse<Comment[]>>;
309
+ getAllCommentsByPostId: (postId: number) => Promise<Comment[]>;
310
+ getCommentById: (id: number) => Promise<Comment>;
311
+ getCommentReplies: (parentId: number) => Promise<Comment[]>;
312
+ createComment: (input: CreateCommentInput) => Promise<Comment>;
313
+ getMenus: () => Promise<Menu[]>;
314
+ getMenuById: (id: number) => Promise<Menu>;
315
+ getMenuBySlug: (slug: string) => Promise<Menu | undefined>;
316
+ getMenuItemsByMenuId: (menuId: number) => Promise<MenuItem[]>;
317
+ getMenuLocations: () => Promise<Record<string, MenuLocation>>;
318
+ getMenuByLocation: (location: string) => Promise<MenuWithItems | undefined>;
232
319
  getAllPages: () => Promise<Page[]>;
233
320
  getPageById: (id: number) => Promise<Page>;
234
321
  getPageBySlug: (slug: string) => Promise<Page | undefined>;
@@ -829,7 +916,75 @@ interface GQLAuthor {
829
916
  };
830
917
  }
831
918
 
919
+ interface GQLMenuItem {
920
+ id: string;
921
+ databaseId: number;
922
+ label: string;
923
+ url: string;
924
+ parentId: string | null;
925
+ order: number;
926
+ target: string;
927
+ cssClasses: string[];
928
+ description: string;
929
+ connectedNode?: {
930
+ node: {
931
+ __typename: string;
932
+ id?: string;
933
+ databaseId?: number;
934
+ slug?: string;
935
+ };
936
+ };
937
+ }
938
+ interface GQLMenu {
939
+ id: string;
940
+ databaseId: number;
941
+ name: string;
942
+ slug: string;
943
+ locations: string[];
944
+ menuItems?: {
945
+ nodes: GQLMenuItem[];
946
+ };
947
+ }
948
+
949
+ interface GQLCommentAuthor {
950
+ name: string;
951
+ url: string;
952
+ avatar?: {
953
+ url: string;
954
+ width: number;
955
+ height: number;
956
+ };
957
+ }
958
+ interface GQLComment {
959
+ id: string;
960
+ databaseId: number;
961
+ content: string;
962
+ date: string;
963
+ parentId: string | null;
964
+ status: string;
965
+ author: {
966
+ node: GQLCommentAuthor;
967
+ };
968
+ replies?: {
969
+ nodes: GQLComment[];
970
+ };
971
+ }
972
+
832
973
  declare function createWPGraphQLCoreClient(config: WPGraphQLConfig): {
974
+ getCommentsByPostId: (postId: number, first?: number, after?: string) => Promise<{
975
+ nodes: GQLComment[];
976
+ pageInfo: {
977
+ hasNextPage: boolean;
978
+ endCursor?: string;
979
+ };
980
+ }>;
981
+ getAllCommentsByPostId: (postId: number) => Promise<GQLComment[]>;
982
+ getCommentById: (id: number) => Promise<GQLComment | null>;
983
+ getMenus: () => Promise<GQLMenu[]>;
984
+ getMenuById: (id: number) => Promise<GQLMenu | null>;
985
+ getMenuBySlug: (slug: string) => Promise<GQLMenu | null>;
986
+ getMenuByLocation: (location: string) => Promise<GQLMenu | null>;
987
+ getMenuItems: (menuSlug: string) => Promise<GQLMenuItem[]>;
833
988
  getAuthors: (first?: number, after?: string) => Promise<GQLConnection<GQLAuthor>>;
834
989
  getAuthorBySlug: (slug: string) => Promise<GQLAuthor | null>;
835
990
  getTags: (first?: number, after?: string) => Promise<GQLConnection<GQLTag>>;
@@ -1083,4 +1238,4 @@ declare function createCPTQueries(fetcher: WPGraphQLFetcher, typeName: string, s
1083
1238
  }[]>;
1084
1239
  };
1085
1240
 
1086
- export { type Author, type BlockType, type Category, type EditorBlock, type EmbeddedAuthor, type EmbeddedTerm, type FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, type GQLConnection, type GQLCustomer, type GQLError, type GQLLineItem, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageInfo, type GQLPageWithSEO, type GQLPost, type GQLPostFilter, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, type GQLTag, type GQLYoastSEO, type MediaDetails, type MediaSize, type NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, type Post, type PostEmbedded, type RenderedContent, type RenderedTitle, type SearchResult, type Tag, type Taxonomy, type TemplatePart, type WCAddress, type WCCoupon, type WCCreateOrderInput, type WCCustomer, type WCDimensions, type WCImage, type WCOrder, type WCOrderLineItem, type WCProduct, type WCProductAttribute, type WCProductCategory, type WCProductDefaultAttribute, type WCProductFilterParams, type WCProductTag, type WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCShippingLine, type WPEntity, type WPGraphQLConfig, WPGraphQLError, type WPGraphQLFetcher, type WooCommerceConfig, type WooCommerceFetcher, type WooCommercePaginationHeaders, type WooCommerceResponse, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createCPTQueries, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLWooCommerceClient, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createYoastQueries, extractOmnibusData, resolveBaseUrl, withOmnibus, withOmnibusVariation };
1241
+ export { type Author, type BlockType, type Category, type Comment, type CommentAuthorAvatar, type CreateCommentInput, type EditorBlock, type EmbeddedAuthor, type EmbeddedTerm, type FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, type GQLConnection, type GQLCustomer, type GQLError, type GQLLineItem, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageInfo, type GQLPageWithSEO, type GQLPost, type GQLPostFilter, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, type GQLTag, type GQLYoastSEO, type MediaDetails, type MediaSize, type Menu, type MenuItem, type MenuLocation, type MenuWithItems, type NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, type Post, type PostEmbedded, type RenderedContent, type RenderedTitle, type SearchResult, type Tag, type Taxonomy, type TemplatePart, type WCAddress, type WCCoupon, type WCCreateOrderInput, type WCCustomer, type WCDimensions, type WCImage, type WCOrder, type WCOrderLineItem, type WCProduct, type WCProductAttribute, type WCProductCategory, type WCProductDefaultAttribute, type WCProductFilterParams, type WCProductTag, type WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCShippingLine, type WPEntity, type WPGraphQLConfig, WPGraphQLError, type WPGraphQLFetcher, type WooCommerceConfig, type WooCommerceFetcher, type WooCommercePaginationHeaders, type WooCommerceResponse, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createCPTQueries, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLWooCommerceClient, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createYoastQueries, extractOmnibusData, resolveBaseUrl, withOmnibus, withOmnibusVariation };
package/dist/index.d.ts CHANGED
@@ -36,15 +36,6 @@ interface Taxonomy {
36
36
 
37
37
  declare function resolveBaseUrl(config: NextWordpressConfig): string;
38
38
 
39
- interface WordPressPaginationHeaders {
40
- total: number;
41
- totalPages: number;
42
- }
43
- interface WordPressResponse<T> {
44
- data: T;
45
- headers: WordPressPaginationHeaders;
46
- }
47
-
48
39
  interface MediaSize {
49
40
  file: string;
50
41
  width: number;
@@ -205,6 +196,15 @@ interface Post extends WPEntity {
205
196
  _embedded?: PostEmbedded;
206
197
  }
207
198
 
199
+ interface WordPressPaginationHeaders {
200
+ total: number;
201
+ totalPages: number;
202
+ }
203
+ interface WordPressResponse<T> {
204
+ data: T;
205
+ headers: WordPressPaginationHeaders;
206
+ }
207
+
208
208
  interface Category extends Taxonomy {
209
209
  taxonomy: 'category';
210
210
  parent: number;
@@ -228,7 +228,94 @@ interface Page extends WPEntity {
228
228
  meta: Record<string, unknown>;
229
229
  }
230
230
 
231
+ interface Menu {
232
+ id: number;
233
+ description: string;
234
+ name: string;
235
+ slug: string;
236
+ meta: Record<string, unknown>;
237
+ locations: string[];
238
+ auto_add: boolean;
239
+ }
240
+ interface MenuItem {
241
+ id: number;
242
+ title: {
243
+ rendered: string;
244
+ };
245
+ status: string;
246
+ url: string;
247
+ attr_title: string;
248
+ description: string;
249
+ type: string;
250
+ type_label: string;
251
+ object: string;
252
+ object_id: number;
253
+ parent: number;
254
+ menu_order: number;
255
+ target: string;
256
+ classes: string[];
257
+ xfn: string[];
258
+ invalid: boolean;
259
+ menus: number;
260
+ meta: Record<string, unknown>;
261
+ }
262
+ interface MenuLocation {
263
+ name: string;
264
+ description: string;
265
+ menu: number;
266
+ }
267
+ interface MenuWithItems {
268
+ menu: Menu;
269
+ items: MenuItem[];
270
+ }
271
+
272
+ interface CommentAuthorAvatar {
273
+ '24': string;
274
+ '48': string;
275
+ '96': string;
276
+ [size: string]: string;
277
+ }
278
+ interface Comment {
279
+ id: number;
280
+ post: number;
281
+ parent: number;
282
+ author: number;
283
+ author_name: string;
284
+ author_email: string;
285
+ author_url: string;
286
+ author_ip: string;
287
+ author_avatar_urls: CommentAuthorAvatar;
288
+ date: string;
289
+ date_gmt: string;
290
+ content: {
291
+ rendered: string;
292
+ };
293
+ link: string;
294
+ status: 'approve' | 'hold' | 'spam' | 'trash';
295
+ type: string;
296
+ meta: Record<string, unknown>;
297
+ }
298
+ interface CreateCommentInput {
299
+ post: number;
300
+ content: string;
301
+ author_name?: string;
302
+ author_email?: string;
303
+ author_url?: string;
304
+ parent?: number;
305
+ }
306
+
231
307
  declare function createWordPressClient(config: NextWordpressConfig): {
308
+ getCommentsByPostId: (postId: number, page?: number, perPage?: number) => Promise<WordPressResponse<Comment[]>>;
309
+ getAllCommentsByPostId: (postId: number) => Promise<Comment[]>;
310
+ getCommentById: (id: number) => Promise<Comment>;
311
+ getCommentReplies: (parentId: number) => Promise<Comment[]>;
312
+ createComment: (input: CreateCommentInput) => Promise<Comment>;
313
+ getMenus: () => Promise<Menu[]>;
314
+ getMenuById: (id: number) => Promise<Menu>;
315
+ getMenuBySlug: (slug: string) => Promise<Menu | undefined>;
316
+ getMenuItemsByMenuId: (menuId: number) => Promise<MenuItem[]>;
317
+ getMenuLocations: () => Promise<Record<string, MenuLocation>>;
318
+ getMenuByLocation: (location: string) => Promise<MenuWithItems | undefined>;
232
319
  getAllPages: () => Promise<Page[]>;
233
320
  getPageById: (id: number) => Promise<Page>;
234
321
  getPageBySlug: (slug: string) => Promise<Page | undefined>;
@@ -829,7 +916,75 @@ interface GQLAuthor {
829
916
  };
830
917
  }
831
918
 
919
+ interface GQLMenuItem {
920
+ id: string;
921
+ databaseId: number;
922
+ label: string;
923
+ url: string;
924
+ parentId: string | null;
925
+ order: number;
926
+ target: string;
927
+ cssClasses: string[];
928
+ description: string;
929
+ connectedNode?: {
930
+ node: {
931
+ __typename: string;
932
+ id?: string;
933
+ databaseId?: number;
934
+ slug?: string;
935
+ };
936
+ };
937
+ }
938
+ interface GQLMenu {
939
+ id: string;
940
+ databaseId: number;
941
+ name: string;
942
+ slug: string;
943
+ locations: string[];
944
+ menuItems?: {
945
+ nodes: GQLMenuItem[];
946
+ };
947
+ }
948
+
949
+ interface GQLCommentAuthor {
950
+ name: string;
951
+ url: string;
952
+ avatar?: {
953
+ url: string;
954
+ width: number;
955
+ height: number;
956
+ };
957
+ }
958
+ interface GQLComment {
959
+ id: string;
960
+ databaseId: number;
961
+ content: string;
962
+ date: string;
963
+ parentId: string | null;
964
+ status: string;
965
+ author: {
966
+ node: GQLCommentAuthor;
967
+ };
968
+ replies?: {
969
+ nodes: GQLComment[];
970
+ };
971
+ }
972
+
832
973
  declare function createWPGraphQLCoreClient(config: WPGraphQLConfig): {
974
+ getCommentsByPostId: (postId: number, first?: number, after?: string) => Promise<{
975
+ nodes: GQLComment[];
976
+ pageInfo: {
977
+ hasNextPage: boolean;
978
+ endCursor?: string;
979
+ };
980
+ }>;
981
+ getAllCommentsByPostId: (postId: number) => Promise<GQLComment[]>;
982
+ getCommentById: (id: number) => Promise<GQLComment | null>;
983
+ getMenus: () => Promise<GQLMenu[]>;
984
+ getMenuById: (id: number) => Promise<GQLMenu | null>;
985
+ getMenuBySlug: (slug: string) => Promise<GQLMenu | null>;
986
+ getMenuByLocation: (location: string) => Promise<GQLMenu | null>;
987
+ getMenuItems: (menuSlug: string) => Promise<GQLMenuItem[]>;
833
988
  getAuthors: (first?: number, after?: string) => Promise<GQLConnection<GQLAuthor>>;
834
989
  getAuthorBySlug: (slug: string) => Promise<GQLAuthor | null>;
835
990
  getTags: (first?: number, after?: string) => Promise<GQLConnection<GQLTag>>;
@@ -1083,4 +1238,4 @@ declare function createCPTQueries(fetcher: WPGraphQLFetcher, typeName: string, s
1083
1238
  }[]>;
1084
1239
  };
1085
1240
 
1086
- export { type Author, type BlockType, type Category, type EditorBlock, type EmbeddedAuthor, type EmbeddedTerm, type FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, type GQLConnection, type GQLCustomer, type GQLError, type GQLLineItem, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageInfo, type GQLPageWithSEO, type GQLPost, type GQLPostFilter, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, type GQLTag, type GQLYoastSEO, type MediaDetails, type MediaSize, type NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, type Post, type PostEmbedded, type RenderedContent, type RenderedTitle, type SearchResult, type Tag, type Taxonomy, type TemplatePart, type WCAddress, type WCCoupon, type WCCreateOrderInput, type WCCustomer, type WCDimensions, type WCImage, type WCOrder, type WCOrderLineItem, type WCProduct, type WCProductAttribute, type WCProductCategory, type WCProductDefaultAttribute, type WCProductFilterParams, type WCProductTag, type WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCShippingLine, type WPEntity, type WPGraphQLConfig, WPGraphQLError, type WPGraphQLFetcher, type WooCommerceConfig, type WooCommerceFetcher, type WooCommercePaginationHeaders, type WooCommerceResponse, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createCPTQueries, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLWooCommerceClient, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createYoastQueries, extractOmnibusData, resolveBaseUrl, withOmnibus, withOmnibusVariation };
1241
+ export { type Author, type BlockType, type Category, type Comment, type CommentAuthorAvatar, type CreateCommentInput, type EditorBlock, type EmbeddedAuthor, type EmbeddedTerm, type FeaturedMedia, type GQLACFFieldGroup, type GQLAuthor, type GQLCPTNode, type GQLCategory, type GQLConnection, type GQLCustomer, type GQLError, type GQLLineItem, type GQLOrder, type GQLOrderAddress, type GQLPage, type GQLPageInfo, type GQLPageWithSEO, type GQLPost, type GQLPostFilter, type GQLPostWithSEO, type GQLProduct, type GQLProductFilter, type GQLProductVariation, type GQLTag, type GQLYoastSEO, type MediaDetails, type MediaSize, type Menu, type MenuItem, type MenuLocation, type MenuWithItems, type NextWordpressConfig, type OmnibusPriceEntry, type OmnibusProductData, type Page, type Post, type PostEmbedded, type RenderedContent, type RenderedTitle, type SearchResult, type Tag, type Taxonomy, type TemplatePart, type WCAddress, type WCCoupon, type WCCreateOrderInput, type WCCustomer, type WCDimensions, type WCImage, type WCOrder, type WCOrderLineItem, type WCProduct, type WCProductAttribute, type WCProductCategory, type WCProductDefaultAttribute, type WCProductFilterParams, type WCProductTag, type WCProductVariation, type WCProductVariationWithOmnibus, type WCProductWithOmnibus, type WCShippingLine, type WPEntity, type WPGraphQLConfig, WPGraphQLError, type WPGraphQLFetcher, type WooCommerceConfig, type WooCommerceFetcher, type WooCommercePaginationHeaders, type WooCommerceResponse, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createCPTQueries, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLWooCommerceClient, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createYoastQueries, extractOmnibusData, resolveBaseUrl, withOmnibus, withOmnibusVariation };