@szymonpiatek/nextwordpress 0.0.1 → 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.cjs CHANGED
@@ -4,10 +4,22 @@ var __defProp = Object.defineProperty;
4
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
5
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
6
 
7
- // src/client/url/url.ts
7
+ // src/shared/url.ts
8
8
  function resolveBaseUrl(config) {
9
9
  return typeof window === "undefined" ? config.serverURL : config.clientURL;
10
10
  }
11
+
12
+ // src/integrations/restApi/core/client/types.ts
13
+ var WordPressAPIError = class extends Error {
14
+ constructor(message, status, endpoint) {
15
+ super(message);
16
+ __publicField(this, "status", status);
17
+ __publicField(this, "endpoint", endpoint);
18
+ this.name = "WordPressAPIError";
19
+ }
20
+ };
21
+
22
+ // src/integrations/restApi/core/client/url.ts
11
23
  function buildUrl(config, path, query) {
12
24
  const base = resolveBaseUrl(config);
13
25
  if (!query) return `${base}${path}`;
@@ -21,17 +33,7 @@ function buildUrl(config, path, query) {
21
33
  return qs ? `${base}${path}?${qs}` : `${base}${path}`;
22
34
  }
23
35
 
24
- // src/client/types/types.ts
25
- var WordPressAPIError = class extends Error {
26
- constructor(message, status, endpoint) {
27
- super(message);
28
- __publicField(this, "status", status);
29
- __publicField(this, "endpoint", endpoint);
30
- this.name = "WordPressAPIError";
31
- }
32
- };
33
-
34
- // src/client/fetcher/fetcher.ts
36
+ // src/integrations/restApi/core/client/fetcher.ts
35
37
  var USER_AGENT = "NextWordpress Client";
36
38
  async function doFetch(url, init = {}) {
37
39
  const response = await fetch(url, init);
@@ -101,7 +103,7 @@ function createFetcher(config) {
101
103
  return { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful, wpMutate };
102
104
  }
103
105
 
104
- // src/integrations/base/posts/queries.ts
106
+ // src/integrations/restApi/core/posts/queries.ts
105
107
  function createPostsQueries(fetcher) {
106
108
  const { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful } = fetcher;
107
109
  async function getPostsPaginated(page = 1, perPage = 9, filterParams) {
@@ -229,7 +231,7 @@ function createPostsQueries(fetcher) {
229
231
  };
230
232
  }
231
233
 
232
- // src/integrations/base/categories/queries.ts
234
+ // src/integrations/restApi/core/categories/queries.ts
233
235
  function createCategoriesQueries(fetcher) {
234
236
  const { wpFetch, wpFetchGraceful } = fetcher;
235
237
  async function getAllCategories() {
@@ -254,7 +256,7 @@ function createCategoriesQueries(fetcher) {
254
256
  return { getAllCategories, getCategoryById, getCategoryBySlug, searchCategories };
255
257
  }
256
258
 
257
- // src/integrations/base/tags/queries.ts
259
+ // src/integrations/restApi/core/tags/queries.ts
258
260
  function createTagsQueries(fetcher) {
259
261
  const { wpFetch, wpFetchGraceful } = fetcher;
260
262
  async function getAllTags() {
@@ -279,7 +281,7 @@ function createTagsQueries(fetcher) {
279
281
  return { getAllTags, getTagById, getTagBySlug, getTagsByPost, searchTags };
280
282
  }
281
283
 
282
- // src/integrations/base/authors/queries.ts
284
+ // src/integrations/restApi/core/authors/queries.ts
283
285
  function createAuthorsQueries(fetcher) {
284
286
  const { wpFetch, wpFetchGraceful } = fetcher;
285
287
  async function getAllAuthors() {
@@ -301,7 +303,7 @@ function createAuthorsQueries(fetcher) {
301
303
  return { getAllAuthors, getAuthorById, getAuthorBySlug, searchAuthors };
302
304
  }
303
305
 
304
- // src/integrations/base/media/queries.ts
306
+ // src/integrations/restApi/core/media/queries.ts
305
307
  function createMediaQueries(fetcher) {
306
308
  const { wpFetch } = fetcher;
307
309
  async function getFeaturedMediaById(id) {
@@ -310,7 +312,7 @@ function createMediaQueries(fetcher) {
310
312
  return { getFeaturedMediaById };
311
313
  }
312
314
 
313
- // src/integrations/base/pages/queries.ts
315
+ // src/integrations/restApi/core/pages/queries.ts
314
316
  function createPagesQueries(fetcher) {
315
317
  const { wpFetch, wpFetchGraceful } = fetcher;
316
318
  async function getAllPages() {
@@ -329,7 +331,101 @@ function createPagesQueries(fetcher) {
329
331
  return { getAllPages, getPageById, getPageBySlug };
330
332
  }
331
333
 
332
- // src/integrations/base/index.ts
334
+ // src/integrations/restApi/core/menus/queries.ts
335
+ function createMenusQueries(fetcher) {
336
+ const { wpFetch, wpFetchGraceful } = fetcher;
337
+ async function getMenus() {
338
+ return wpFetchGraceful("/wp-json/wp/v2/menus", [], void 0, ["wordpress", "menus"]);
339
+ }
340
+ async function getMenuById(id) {
341
+ return wpFetch(`/wp-json/wp/v2/menus/${id}`, void 0, ["wordpress", "menus", `menu-${id}`]);
342
+ }
343
+ async function getMenuBySlug(slug) {
344
+ const menus = await wpFetchGraceful("/wp-json/wp/v2/menus", [], { slug }, ["wordpress", "menus"]);
345
+ return menus[0];
346
+ }
347
+ async function getMenuItemsByMenuId(menuId) {
348
+ return wpFetchGraceful(
349
+ "/wp-json/wp/v2/menu-items",
350
+ [],
351
+ { menus: menuId, per_page: 100, orderby: "menu_order", order: "asc" },
352
+ ["wordpress", "menus", `menu-items-${menuId}`]
353
+ );
354
+ }
355
+ async function getMenuLocations() {
356
+ return wpFetchGraceful(
357
+ "/wp-json/wp/v2/menu-locations",
358
+ {},
359
+ void 0,
360
+ ["wordpress", "menus", "menu-locations"]
361
+ );
362
+ }
363
+ async function getMenuByLocation(location) {
364
+ const locations = await getMenuLocations();
365
+ const loc = locations[location];
366
+ if (!loc || !loc.menu) return void 0;
367
+ const [menu, items] = await Promise.all([
368
+ getMenuById(loc.menu),
369
+ getMenuItemsByMenuId(loc.menu)
370
+ ]);
371
+ return { menu, items };
372
+ }
373
+ return {
374
+ getMenus,
375
+ getMenuById,
376
+ getMenuBySlug,
377
+ getMenuItemsByMenuId,
378
+ getMenuLocations,
379
+ getMenuByLocation
380
+ };
381
+ }
382
+
383
+ // src/integrations/restApi/core/comments/queries.ts
384
+ function createCommentsQueries(fetcher) {
385
+ const { wpFetch, wpFetchGraceful, wpFetchPaginatedGraceful, wpMutate } = fetcher;
386
+ async function getCommentsByPostId(postId, page = 1, perPage = 10) {
387
+ return wpFetchPaginatedGraceful(
388
+ "/wp-json/wp/v2/comments",
389
+ { post: postId, per_page: perPage, page, status: "approve" },
390
+ ["wordpress", "comments", `comments-post-${postId}`]
391
+ );
392
+ }
393
+ async function getAllCommentsByPostId(postId) {
394
+ return wpFetchGraceful(
395
+ "/wp-json/wp/v2/comments",
396
+ [],
397
+ { post: postId, per_page: 100, status: "approve" },
398
+ ["wordpress", "comments", `comments-post-${postId}`]
399
+ );
400
+ }
401
+ async function getCommentById(id) {
402
+ return wpFetch(`/wp-json/wp/v2/comments/${id}`, void 0, [
403
+ "wordpress",
404
+ "comments",
405
+ `comment-${id}`
406
+ ]);
407
+ }
408
+ async function getCommentReplies(parentId) {
409
+ return wpFetchGraceful(
410
+ "/wp-json/wp/v2/comments",
411
+ [],
412
+ { parent: parentId, per_page: 100, status: "approve" },
413
+ ["wordpress", "comments", `comments-parent-${parentId}`]
414
+ );
415
+ }
416
+ async function createComment(input) {
417
+ return wpMutate("/wp-json/wp/v2/comments", input, "POST");
418
+ }
419
+ return {
420
+ getCommentsByPostId,
421
+ getAllCommentsByPostId,
422
+ getCommentById,
423
+ getCommentReplies,
424
+ createComment
425
+ };
426
+ }
427
+
428
+ // src/integrations/restApi/core/index.ts
333
429
  function createWordPressClient(config) {
334
430
  const fetcher = createFetcher(config);
335
431
  return {
@@ -338,11 +434,13 @@ function createWordPressClient(config) {
338
434
  ...createTagsQueries(fetcher),
339
435
  ...createAuthorsQueries(fetcher),
340
436
  ...createMediaQueries(fetcher),
341
- ...createPagesQueries(fetcher)
437
+ ...createPagesQueries(fetcher),
438
+ ...createMenusQueries(fetcher),
439
+ ...createCommentsQueries(fetcher)
342
440
  };
343
441
  }
344
442
 
345
- // src/integrations/woocommerce/omnibus/queries.ts
443
+ // src/integrations/restApi/woocommerce/omnibus/queries.ts
346
444
  var META_KEY_LOWEST_PRICE = "wpo_lowest_price";
347
445
  var META_KEY_PRICE_HISTORY = "_alg_wc_price_history";
348
446
  function extractMetaValue(meta_data, key) {
@@ -371,7 +469,7 @@ function withOmnibusVariation(variation) {
371
469
  };
372
470
  }
373
471
 
374
- // src/integrations/woocommerce/client/fetcher.ts
472
+ // src/integrations/restApi/woocommerce/client/fetcher.ts
375
473
  var USER_AGENT2 = "NextWordpress WooCommerce Client";
376
474
  var DEFAULT_CACHE_TTL = 3600;
377
475
  function toQueryString(params) {
@@ -453,7 +551,7 @@ function createWooCommerceFetcher(config) {
453
551
  return { wcFetch, wcFetchGraceful, wcFetchPaginated, wcFetchPaginatedGraceful, wcMutate };
454
552
  }
455
553
 
456
- // src/integrations/woocommerce/products/queries.ts
554
+ // src/integrations/restApi/woocommerce/products/queries.ts
457
555
  function buildProductQuery(base, filterParams) {
458
556
  const query = { ...base };
459
557
  if (!filterParams) return query;
@@ -580,7 +678,7 @@ function createProductsQueries(fetcher) {
580
678
  };
581
679
  }
582
680
 
583
- // src/integrations/woocommerce/categories/queries.ts
681
+ // src/integrations/restApi/woocommerce/categories/queries.ts
584
682
  function createCategoriesQueries2(fetcher) {
585
683
  const { wcFetch, wcFetchGraceful } = fetcher;
586
684
  async function getAllProductCategories() {
@@ -629,7 +727,7 @@ function createCategoriesQueries2(fetcher) {
629
727
  };
630
728
  }
631
729
 
632
- // src/integrations/woocommerce/tags/queries.ts
730
+ // src/integrations/restApi/woocommerce/tags/queries.ts
633
731
  function createTagsQueries2(fetcher) {
634
732
  const { wcFetch, wcFetchGraceful } = fetcher;
635
733
  async function getAllProductTags() {
@@ -662,7 +760,7 @@ function createTagsQueries2(fetcher) {
662
760
  };
663
761
  }
664
762
 
665
- // src/integrations/woocommerce/orders/queries.ts
763
+ // src/integrations/restApi/woocommerce/orders/queries.ts
666
764
  function createOrdersQueries(fetcher) {
667
765
  const { wcFetch, wcFetchGraceful, wcMutate } = fetcher;
668
766
  async function createOrder(input) {
@@ -694,7 +792,7 @@ function createOrdersQueries(fetcher) {
694
792
  };
695
793
  }
696
794
 
697
- // src/integrations/woocommerce/coupons/queries.ts
795
+ // src/integrations/restApi/woocommerce/coupons/queries.ts
698
796
  function createCouponsQueries(fetcher) {
699
797
  const { wcFetchGraceful } = fetcher;
700
798
  async function getCouponByCode(code) {
@@ -724,7 +822,7 @@ function createCouponsQueries(fetcher) {
724
822
  };
725
823
  }
726
824
 
727
- // src/integrations/woocommerce/customers/queries.ts
825
+ // src/integrations/restApi/woocommerce/customers/queries.ts
728
826
  function createCustomersQueries(fetcher) {
729
827
  const { wcFetch, wcFetchGraceful } = fetcher;
730
828
  async function getCustomerById(id) {
@@ -772,7 +870,7 @@ function createCustomersQueries(fetcher) {
772
870
  };
773
871
  }
774
872
 
775
- // src/integrations/woocommerce/index.ts
873
+ // src/integrations/restApi/woocommerce/index.ts
776
874
  function createWooCommerceClient(config) {
777
875
  const fetcher = createWooCommerceFetcher(config);
778
876
  return {
@@ -785,11 +883,1204 @@ function createWooCommerceClient(config) {
785
883
  };
786
884
  }
787
885
 
788
- exports.buildUrl = buildUrl;
789
- exports.createFetcher = createFetcher;
886
+ // src/integrations/wpGraphQL/client/types.ts
887
+ var WPGraphQLError = class extends Error {
888
+ constructor(message, status, endpoint, gqlErrors) {
889
+ super(message);
890
+ __publicField(this, "status", status);
891
+ __publicField(this, "endpoint", endpoint);
892
+ __publicField(this, "gqlErrors", gqlErrors);
893
+ this.name = "WPGraphQLError";
894
+ }
895
+ };
896
+
897
+ // src/integrations/wpGraphQL/client/fetcher.ts
898
+ var USER_AGENT3 = "NextWordpress WPGraphQL Client";
899
+ var CACHE_TTL = 300;
900
+ function createWPGraphQLFetcher(config) {
901
+ const url = `${resolveBaseUrl(config)}/graphql`;
902
+ async function gqlFetch(document, variables, tags = ["wpgraphql"]) {
903
+ const response = await fetch(url, {
904
+ method: "POST",
905
+ headers: {
906
+ "Content-Type": "application/json",
907
+ "User-Agent": USER_AGENT3
908
+ },
909
+ body: JSON.stringify({ query: document, variables }),
910
+ next: { tags, revalidate: CACHE_TTL }
911
+ });
912
+ if (!response.ok) {
913
+ throw new WPGraphQLError(
914
+ `WPGraphQL request failed: ${response.statusText}`,
915
+ response.status,
916
+ url
917
+ );
918
+ }
919
+ const parsed = await response.json();
920
+ if (parsed.errors && parsed.errors.length > 0) {
921
+ throw new WPGraphQLError(
922
+ parsed.errors[0].message,
923
+ 200,
924
+ url,
925
+ parsed.errors
926
+ );
927
+ }
928
+ if (parsed.data === void 0) {
929
+ throw new WPGraphQLError("No data returned from WPGraphQL", 200, url);
930
+ }
931
+ return parsed.data;
932
+ }
933
+ async function gqlFetchGraceful(document, fallback, variables, tags = ["wpgraphql"]) {
934
+ try {
935
+ return await gqlFetch(document, variables, tags);
936
+ } catch {
937
+ console.warn(`WPGraphQL fetch failed for query`);
938
+ return fallback;
939
+ }
940
+ }
941
+ return { gqlFetch, gqlFetchGraceful };
942
+ }
943
+
944
+ // src/integrations/wpGraphQL/core/posts/queries.ts
945
+ var DEFAULT_FIRST = 10;
946
+ var BATCH_FIRST = 100;
947
+ var POST_FIELDS = `
948
+ id
949
+ databaseId
950
+ slug
951
+ title
952
+ excerpt
953
+ date
954
+ modified
955
+ status
956
+ uri
957
+ author {
958
+ node {
959
+ databaseId
960
+ name
961
+ slug
962
+ avatar { url }
963
+ }
964
+ }
965
+ featuredImage {
966
+ node {
967
+ sourceUrl
968
+ altText
969
+ mediaDetails { width height }
970
+ }
971
+ }
972
+ categories {
973
+ nodes { databaseId name slug }
974
+ }
975
+ tags {
976
+ nodes { databaseId name slug }
977
+ }
978
+ `;
979
+ var POST_FIELDS_WITH_CONTENT = `
980
+ ${POST_FIELDS}
981
+ content
982
+ `;
983
+ var GQL_GET_POSTS = `
984
+ query GetPosts($first: Int, $after: String, $where: RootQueryToPostConnectionWhereArgs) {
985
+ posts(first: $first, after: $after, where: $where) {
986
+ nodes { ${POST_FIELDS} }
987
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
988
+ }
989
+ }
990
+ `;
991
+ var GQL_GET_POST_BY_SLUG = `
992
+ query GetPostBySlug($slug: ID!) {
993
+ post(id: $slug, idType: SLUG) { ${POST_FIELDS_WITH_CONTENT} }
994
+ }
995
+ `;
996
+ var GQL_GET_POST_BY_DATABASE_ID = `
997
+ query GetPostByDatabaseId($id: ID!) {
998
+ post(id: $id, idType: DATABASE_ID) { ${POST_FIELDS_WITH_CONTENT} }
999
+ }
1000
+ `;
1001
+ var GQL_GET_ALL_POST_SLUGS = `
1002
+ query GetAllPostSlugs($first: Int, $after: String) {
1003
+ posts(first: $first, after: $after) {
1004
+ nodes { slug }
1005
+ pageInfo { hasNextPage endCursor }
1006
+ }
1007
+ }
1008
+ `;
1009
+ var GQL_GET_ALL_POSTS_FOR_SITEMAP = `
1010
+ query GetAllPostsForSitemap($first: Int, $after: String) {
1011
+ posts(first: $first, after: $after) {
1012
+ nodes { slug modified }
1013
+ pageInfo { hasNextPage endCursor }
1014
+ }
1015
+ }
1016
+ `;
1017
+ function createPostsQueries2(fetcher) {
1018
+ const { gqlFetch, gqlFetchGraceful } = fetcher;
1019
+ async function getPosts(first = DEFAULT_FIRST, after, filter) {
1020
+ const where = {};
1021
+ if (filter?.authorName) where["authorName"] = filter.authorName;
1022
+ if (filter?.categoryName) where["categoryName"] = filter.categoryName;
1023
+ if (filter?.tag) where["tag"] = filter.tag;
1024
+ if (filter?.search) where["search"] = filter.search;
1025
+ if (filter?.status) where["status"] = filter.status;
1026
+ const data = await gqlFetchGraceful(
1027
+ GQL_GET_POSTS,
1028
+ { posts: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1029
+ { first, after, where: Object.keys(where).length > 0 ? where : void 0 },
1030
+ ["wpgraphql", "gql-posts"]
1031
+ );
1032
+ return data.posts;
1033
+ }
1034
+ async function getPostBySlug(slug) {
1035
+ const data = await gqlFetchGraceful(
1036
+ GQL_GET_POST_BY_SLUG,
1037
+ { post: null },
1038
+ { slug },
1039
+ ["wpgraphql", "gql-posts", `gql-post-${slug}`]
1040
+ );
1041
+ return data.post;
1042
+ }
1043
+ async function getPostByDatabaseId(id) {
1044
+ const data = await gqlFetchGraceful(
1045
+ GQL_GET_POST_BY_DATABASE_ID,
1046
+ { post: null },
1047
+ { id: String(id) },
1048
+ ["wpgraphql", "gql-posts", `gql-post-id-${id}`]
1049
+ );
1050
+ return data.post;
1051
+ }
1052
+ async function getRecentPosts(first = DEFAULT_FIRST) {
1053
+ const connection = await getPosts(first);
1054
+ return connection.nodes;
1055
+ }
1056
+ async function getAllPostSlugs() {
1057
+ try {
1058
+ const all = [];
1059
+ let after = void 0;
1060
+ let hasNextPage = true;
1061
+ while (hasNextPage) {
1062
+ const data = await gqlFetch(GQL_GET_ALL_POST_SLUGS, { first: BATCH_FIRST, after }, ["wpgraphql"]);
1063
+ all.push(...data.posts.nodes);
1064
+ hasNextPage = data.posts.pageInfo.hasNextPage;
1065
+ after = data.posts.pageInfo.endCursor;
1066
+ }
1067
+ return all;
1068
+ } catch {
1069
+ console.warn("WPGraphQL unavailable, skipping static generation for posts");
1070
+ return [];
1071
+ }
1072
+ }
1073
+ async function getAllPostsForSitemap() {
1074
+ try {
1075
+ const all = [];
1076
+ let after = void 0;
1077
+ let hasNextPage = true;
1078
+ while (hasNextPage) {
1079
+ const data = await gqlFetch(
1080
+ GQL_GET_ALL_POSTS_FOR_SITEMAP,
1081
+ { first: BATCH_FIRST, after },
1082
+ ["wpgraphql"]
1083
+ );
1084
+ all.push(...data.posts.nodes);
1085
+ hasNextPage = data.posts.pageInfo.hasNextPage;
1086
+ after = data.posts.pageInfo.endCursor;
1087
+ }
1088
+ return all;
1089
+ } catch {
1090
+ console.warn("WPGraphQL unavailable, skipping sitemap generation");
1091
+ return [];
1092
+ }
1093
+ }
1094
+ return {
1095
+ getPosts,
1096
+ getPostBySlug,
1097
+ getPostByDatabaseId,
1098
+ getRecentPosts,
1099
+ getAllPostSlugs,
1100
+ getAllPostsForSitemap
1101
+ };
1102
+ }
1103
+
1104
+ // src/integrations/wpGraphQL/core/pages/queries.ts
1105
+ var DEFAULT_FIRST2 = 10;
1106
+ var BATCH_FIRST2 = 100;
1107
+ var PAGE_FIELDS = `
1108
+ id
1109
+ databaseId
1110
+ slug
1111
+ title
1112
+ content
1113
+ date
1114
+ modified
1115
+ status
1116
+ uri
1117
+ featuredImage {
1118
+ node {
1119
+ sourceUrl
1120
+ altText
1121
+ mediaDetails { width height }
1122
+ }
1123
+ }
1124
+ `;
1125
+ var GQL_GET_PAGES = `
1126
+ query GetPages($first: Int, $after: String) {
1127
+ pages(first: $first, after: $after) {
1128
+ nodes { ${PAGE_FIELDS} }
1129
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1130
+ }
1131
+ }
1132
+ `;
1133
+ var GQL_GET_PAGE_BY_SLUG = `
1134
+ query GetPageBySlug($uri: ID!) {
1135
+ page(id: $uri, idType: URI) { ${PAGE_FIELDS} }
1136
+ }
1137
+ `;
1138
+ var GQL_GET_PAGE_BY_URI = `
1139
+ query GetPageByUri($uri: ID!) {
1140
+ page(id: $uri, idType: URI) { ${PAGE_FIELDS} }
1141
+ }
1142
+ `;
1143
+ var GQL_GET_ALL_PAGE_URIS = `
1144
+ query GetAllPageUris($first: Int, $after: String) {
1145
+ pages(first: $first, after: $after) {
1146
+ nodes { uri }
1147
+ pageInfo { hasNextPage endCursor }
1148
+ }
1149
+ }
1150
+ `;
1151
+ function createPagesQueries2(fetcher) {
1152
+ const { gqlFetch, gqlFetchGraceful } = fetcher;
1153
+ async function getPages(first = DEFAULT_FIRST2, after) {
1154
+ const data = await gqlFetchGraceful(
1155
+ GQL_GET_PAGES,
1156
+ { pages: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1157
+ { first, after },
1158
+ ["wpgraphql", "gql-pages"]
1159
+ );
1160
+ return data.pages;
1161
+ }
1162
+ async function getPageBySlug(slug) {
1163
+ const data = await gqlFetchGraceful(
1164
+ GQL_GET_PAGE_BY_SLUG,
1165
+ { page: null },
1166
+ { uri: `/${slug}/` },
1167
+ ["wpgraphql", "gql-pages", `gql-page-${slug}`]
1168
+ );
1169
+ return data.page;
1170
+ }
1171
+ async function getPageByUri(uri) {
1172
+ const data = await gqlFetchGraceful(
1173
+ GQL_GET_PAGE_BY_URI,
1174
+ { page: null },
1175
+ { uri },
1176
+ ["wpgraphql", "gql-pages", `gql-page-uri-${uri.replace(/\//g, "-")}`]
1177
+ );
1178
+ return data.page;
1179
+ }
1180
+ async function getAllPageUris() {
1181
+ try {
1182
+ const all = [];
1183
+ let after = void 0;
1184
+ let hasNextPage = true;
1185
+ while (hasNextPage) {
1186
+ const data = await gqlFetch(GQL_GET_ALL_PAGE_URIS, { first: BATCH_FIRST2, after }, ["wpgraphql"]);
1187
+ all.push(...data.pages.nodes);
1188
+ hasNextPage = data.pages.pageInfo.hasNextPage;
1189
+ after = data.pages.pageInfo.endCursor;
1190
+ }
1191
+ return all;
1192
+ } catch {
1193
+ console.warn("WPGraphQL unavailable, skipping static generation for pages");
1194
+ return [];
1195
+ }
1196
+ }
1197
+ return { getPages, getPageBySlug, getPageByUri, getAllPageUris };
1198
+ }
1199
+
1200
+ // src/integrations/wpGraphQL/core/categories/queries.ts
1201
+ var DEFAULT_FIRST3 = 100;
1202
+ var CATEGORY_FIELDS = `
1203
+ id
1204
+ databaseId
1205
+ name
1206
+ slug
1207
+ description
1208
+ count
1209
+ uri
1210
+ parent {
1211
+ node { databaseId name slug }
1212
+ }
1213
+ `;
1214
+ var GQL_GET_CATEGORIES = `
1215
+ query GetCategories($first: Int, $after: String) {
1216
+ categories(first: $first, after: $after) {
1217
+ nodes { ${CATEGORY_FIELDS} }
1218
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1219
+ }
1220
+ }
1221
+ `;
1222
+ var GQL_GET_CATEGORY_BY_SLUG = `
1223
+ query GetCategoryBySlug($slug: ID!) {
1224
+ category(id: $slug, idType: SLUG) { ${CATEGORY_FIELDS} }
1225
+ }
1226
+ `;
1227
+ var GQL_GET_CATEGORY_BY_DATABASE_ID = `
1228
+ query GetCategoryByDatabaseId($id: ID!) {
1229
+ category(id: $id, idType: DATABASE_ID) { ${CATEGORY_FIELDS} }
1230
+ }
1231
+ `;
1232
+ function createCategoriesQueries3(fetcher) {
1233
+ const { gqlFetchGraceful } = fetcher;
1234
+ async function getCategories(first = DEFAULT_FIRST3, after) {
1235
+ const data = await gqlFetchGraceful(
1236
+ GQL_GET_CATEGORIES,
1237
+ { categories: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1238
+ { first, after },
1239
+ ["wpgraphql", "gql-categories"]
1240
+ );
1241
+ return data.categories;
1242
+ }
1243
+ async function getCategoryBySlug(slug) {
1244
+ const data = await gqlFetchGraceful(
1245
+ GQL_GET_CATEGORY_BY_SLUG,
1246
+ { category: null },
1247
+ { slug },
1248
+ ["wpgraphql", "gql-categories", `gql-category-${slug}`]
1249
+ );
1250
+ return data.category;
1251
+ }
1252
+ async function getCategoryByDatabaseId(id) {
1253
+ const data = await gqlFetchGraceful(
1254
+ GQL_GET_CATEGORY_BY_DATABASE_ID,
1255
+ { category: null },
1256
+ { id: String(id) },
1257
+ ["wpgraphql", "gql-categories", `gql-category-id-${id}`]
1258
+ );
1259
+ return data.category;
1260
+ }
1261
+ return { getCategories, getCategoryBySlug, getCategoryByDatabaseId };
1262
+ }
1263
+
1264
+ // src/integrations/wpGraphQL/core/tags/queries.ts
1265
+ var DEFAULT_FIRST4 = 100;
1266
+ var TAG_FIELDS = `
1267
+ id
1268
+ databaseId
1269
+ name
1270
+ slug
1271
+ description
1272
+ count
1273
+ uri
1274
+ `;
1275
+ var GQL_GET_TAGS = `
1276
+ query GetTags($first: Int, $after: String) {
1277
+ tags(first: $first, after: $after) {
1278
+ nodes { ${TAG_FIELDS} }
1279
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1280
+ }
1281
+ }
1282
+ `;
1283
+ var GQL_GET_TAG_BY_SLUG = `
1284
+ query GetTagBySlug($slug: ID!) {
1285
+ tag(id: $slug, idType: SLUG) { ${TAG_FIELDS} }
1286
+ }
1287
+ `;
1288
+ function createTagsQueries3(fetcher) {
1289
+ const { gqlFetchGraceful } = fetcher;
1290
+ async function getTags(first = DEFAULT_FIRST4, after) {
1291
+ const data = await gqlFetchGraceful(
1292
+ GQL_GET_TAGS,
1293
+ { tags: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1294
+ { first, after },
1295
+ ["wpgraphql", "gql-tags"]
1296
+ );
1297
+ return data.tags;
1298
+ }
1299
+ async function getTagBySlug(slug) {
1300
+ const data = await gqlFetchGraceful(
1301
+ GQL_GET_TAG_BY_SLUG,
1302
+ { tag: null },
1303
+ { slug },
1304
+ ["wpgraphql", "gql-tags", `gql-tag-${slug}`]
1305
+ );
1306
+ return data.tag;
1307
+ }
1308
+ return { getTags, getTagBySlug };
1309
+ }
1310
+
1311
+ // src/integrations/wpGraphQL/core/authors/queries.ts
1312
+ var DEFAULT_FIRST5 = 100;
1313
+ var AUTHOR_FIELDS = `
1314
+ id
1315
+ databaseId
1316
+ name
1317
+ slug
1318
+ description
1319
+ email
1320
+ uri
1321
+ avatar { url width height }
1322
+ `;
1323
+ var GQL_GET_AUTHORS = `
1324
+ query GetAuthors($first: Int, $after: String) {
1325
+ users(first: $first, after: $after) {
1326
+ nodes { ${AUTHOR_FIELDS} }
1327
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1328
+ }
1329
+ }
1330
+ `;
1331
+ var GQL_GET_AUTHOR_BY_SLUG = `
1332
+ query GetAuthorBySlug($slug: String!) {
1333
+ users(where: { login: $slug }) {
1334
+ nodes { ${AUTHOR_FIELDS} }
1335
+ }
1336
+ }
1337
+ `;
1338
+ function createAuthorsQueries2(fetcher) {
1339
+ const { gqlFetchGraceful } = fetcher;
1340
+ async function getAuthors(first = DEFAULT_FIRST5, after) {
1341
+ const data = await gqlFetchGraceful(
1342
+ GQL_GET_AUTHORS,
1343
+ { users: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1344
+ { first, after },
1345
+ ["wpgraphql", "gql-authors"]
1346
+ );
1347
+ return data.users;
1348
+ }
1349
+ async function getAuthorBySlug(slug) {
1350
+ const data = await gqlFetchGraceful(
1351
+ GQL_GET_AUTHOR_BY_SLUG,
1352
+ { users: { nodes: [] } },
1353
+ { slug },
1354
+ ["wpgraphql", "gql-authors", `gql-author-${slug}`]
1355
+ );
1356
+ return data.users.nodes[0] ?? null;
1357
+ }
1358
+ return { getAuthors, getAuthorBySlug };
1359
+ }
1360
+
1361
+ // src/integrations/wpGraphQL/core/menus/queries.ts
1362
+ var MENU_ITEM_FIELDS = `
1363
+ id
1364
+ databaseId
1365
+ label
1366
+ url
1367
+ parentId
1368
+ order
1369
+ target
1370
+ cssClasses
1371
+ description
1372
+ connectedNode {
1373
+ node {
1374
+ __typename
1375
+ ... on Page { id databaseId slug }
1376
+ ... on Post { id databaseId slug }
1377
+ ... on Category { id databaseId slug }
1378
+ ... on Tag { id databaseId slug }
1379
+ }
1380
+ }
1381
+ `;
1382
+ var MENU_FIELDS = `
1383
+ id
1384
+ databaseId
1385
+ name
1386
+ slug
1387
+ locations
1388
+ menuItems(first: 100) {
1389
+ nodes { ${MENU_ITEM_FIELDS} }
1390
+ }
1391
+ `;
1392
+ var GQL_GET_MENUS = `
1393
+ query GetMenus {
1394
+ menus(first: 100) {
1395
+ nodes { ${MENU_FIELDS} }
1396
+ }
1397
+ }
1398
+ `;
1399
+ var GQL_GET_MENU_BY_ID = `
1400
+ query GetMenuById($id: ID!) {
1401
+ menu(id: $id, idType: DATABASE_ID) { ${MENU_FIELDS} }
1402
+ }
1403
+ `;
1404
+ var GQL_GET_MENU_BY_SLUG = `
1405
+ query GetMenuBySlug($id: ID!) {
1406
+ menu(id: $id, idType: SLUG) { ${MENU_FIELDS} }
1407
+ }
1408
+ `;
1409
+ var GQL_GET_MENUS_BY_LOCATION = `
1410
+ query GetMenusByLocation($location: MenuLocationEnum!) {
1411
+ menus(where: { location: $location }, first: 1) {
1412
+ nodes { ${MENU_FIELDS} }
1413
+ }
1414
+ }
1415
+ `;
1416
+ function createMenusQueries2(fetcher) {
1417
+ const { gqlFetch, gqlFetchGraceful } = fetcher;
1418
+ async function getMenus() {
1419
+ const data = await gqlFetchGraceful(
1420
+ GQL_GET_MENUS,
1421
+ { menus: { nodes: [] } },
1422
+ void 0,
1423
+ ["wpgraphql", "gql-menus"]
1424
+ );
1425
+ return data.menus.nodes;
1426
+ }
1427
+ async function getMenuById(id) {
1428
+ const data = await gqlFetchGraceful(
1429
+ GQL_GET_MENU_BY_ID,
1430
+ { menu: null },
1431
+ { id: String(id) },
1432
+ ["wpgraphql", "gql-menus", `gql-menu-${id}`]
1433
+ );
1434
+ return data.menu;
1435
+ }
1436
+ async function getMenuBySlug(slug) {
1437
+ const data = await gqlFetchGraceful(
1438
+ GQL_GET_MENU_BY_SLUG,
1439
+ { menu: null },
1440
+ { id: slug },
1441
+ ["wpgraphql", "gql-menus", `gql-menu-${slug}`]
1442
+ );
1443
+ return data.menu;
1444
+ }
1445
+ async function getMenuByLocation(location) {
1446
+ const data = await gqlFetch(
1447
+ GQL_GET_MENUS_BY_LOCATION,
1448
+ { location: location.toUpperCase() },
1449
+ ["wpgraphql", "gql-menus", `gql-menu-location-${location}`]
1450
+ );
1451
+ return data.menus.nodes[0] ?? null;
1452
+ }
1453
+ async function getMenuItems(menuSlug) {
1454
+ const menu = await getMenuBySlug(menuSlug);
1455
+ return menu?.menuItems?.nodes ?? [];
1456
+ }
1457
+ return {
1458
+ getMenus,
1459
+ getMenuById,
1460
+ getMenuBySlug,
1461
+ getMenuByLocation,
1462
+ getMenuItems
1463
+ };
1464
+ }
1465
+
1466
+ // src/integrations/wpGraphQL/core/comments/queries.ts
1467
+ var COMMENT_AUTHOR_FIELDS = `
1468
+ name
1469
+ url
1470
+ avatar { url width height }
1471
+ `;
1472
+ var COMMENT_FIELDS = `
1473
+ id
1474
+ databaseId
1475
+ content(format: RENDERED)
1476
+ date
1477
+ parentId
1478
+ status
1479
+ author { node { ${COMMENT_AUTHOR_FIELDS} } }
1480
+ `;
1481
+ var GQL_GET_COMMENTS_BY_POST = `
1482
+ query GetCommentsByPost($contentId: ID!, $first: Int, $after: String) {
1483
+ comments(
1484
+ first: $first
1485
+ after: $after
1486
+ where: { contentId: $contentId, status: "approve", parent: 0 }
1487
+ ) {
1488
+ nodes {
1489
+ ${COMMENT_FIELDS}
1490
+ replies(first: 100) {
1491
+ nodes { ${COMMENT_FIELDS} }
1492
+ }
1493
+ }
1494
+ pageInfo { hasNextPage endCursor }
1495
+ }
1496
+ }
1497
+ `;
1498
+ var GQL_GET_ALL_COMMENTS_BY_POST = `
1499
+ query GetAllCommentsByPost($contentId: ID!) {
1500
+ comments(
1501
+ first: 100
1502
+ where: { contentId: $contentId, status: "approve" }
1503
+ ) {
1504
+ nodes { ${COMMENT_FIELDS} }
1505
+ }
1506
+ }
1507
+ `;
1508
+ var GQL_GET_COMMENT_BY_ID = `
1509
+ query GetCommentById($id: ID!) {
1510
+ comment(id: $id, idType: DATABASE_ID) { ${COMMENT_FIELDS} }
1511
+ }
1512
+ `;
1513
+ function createCommentsQueries2(fetcher) {
1514
+ const { gqlFetchGraceful } = fetcher;
1515
+ async function getCommentsByPostId(postId, first = 10, after) {
1516
+ const data = await gqlFetchGraceful(
1517
+ GQL_GET_COMMENTS_BY_POST,
1518
+ { comments: { nodes: [], pageInfo: { hasNextPage: false } } },
1519
+ { contentId: String(postId), first, after },
1520
+ ["wpgraphql", "gql-comments", `gql-comments-post-${postId}`]
1521
+ );
1522
+ return data.comments;
1523
+ }
1524
+ async function getAllCommentsByPostId(postId) {
1525
+ const data = await gqlFetchGraceful(
1526
+ GQL_GET_ALL_COMMENTS_BY_POST,
1527
+ { comments: { nodes: [] } },
1528
+ { contentId: String(postId) },
1529
+ ["wpgraphql", "gql-comments", `gql-comments-post-${postId}`]
1530
+ );
1531
+ return data.comments.nodes;
1532
+ }
1533
+ async function getCommentById(id) {
1534
+ const data = await gqlFetchGraceful(
1535
+ GQL_GET_COMMENT_BY_ID,
1536
+ { comment: null },
1537
+ { id: String(id) },
1538
+ ["wpgraphql", "gql-comments", `gql-comment-${id}`]
1539
+ );
1540
+ return data.comment;
1541
+ }
1542
+ return {
1543
+ getCommentsByPostId,
1544
+ getAllCommentsByPostId,
1545
+ getCommentById
1546
+ };
1547
+ }
1548
+
1549
+ // src/integrations/wpGraphQL/core/index.ts
1550
+ function createWPGraphQLCoreClient(config) {
1551
+ const fetcher = createWPGraphQLFetcher(config);
1552
+ return {
1553
+ ...createPostsQueries2(fetcher),
1554
+ ...createPagesQueries2(fetcher),
1555
+ ...createCategoriesQueries3(fetcher),
1556
+ ...createTagsQueries3(fetcher),
1557
+ ...createAuthorsQueries2(fetcher),
1558
+ ...createMenusQueries2(fetcher),
1559
+ ...createCommentsQueries2(fetcher)
1560
+ };
1561
+ }
1562
+
1563
+ // src/integrations/wpGraphQL/yoast/queries.ts
1564
+ var SEO_FIELDS = `
1565
+ seo {
1566
+ title
1567
+ metaDesc
1568
+ canonical
1569
+ opengraphTitle
1570
+ opengraphDescription
1571
+ opengraphImage { sourceUrl altText }
1572
+ twitterTitle
1573
+ twitterDescription
1574
+ twitterImage { sourceUrl }
1575
+ schema { raw }
1576
+ }
1577
+ `;
1578
+ var POST_FIELDS_WITH_SEO = `
1579
+ id
1580
+ databaseId
1581
+ slug
1582
+ title
1583
+ content
1584
+ excerpt
1585
+ date
1586
+ modified
1587
+ status
1588
+ uri
1589
+ author {
1590
+ node {
1591
+ databaseId
1592
+ name
1593
+ slug
1594
+ avatar { url }
1595
+ }
1596
+ }
1597
+ featuredImage {
1598
+ node {
1599
+ sourceUrl
1600
+ altText
1601
+ mediaDetails { width height }
1602
+ }
1603
+ }
1604
+ categories {
1605
+ nodes { databaseId name slug }
1606
+ }
1607
+ tags {
1608
+ nodes { databaseId name slug }
1609
+ }
1610
+ ${SEO_FIELDS}
1611
+ `;
1612
+ var PAGE_FIELDS_WITH_SEO = `
1613
+ id
1614
+ databaseId
1615
+ slug
1616
+ title
1617
+ content
1618
+ date
1619
+ modified
1620
+ status
1621
+ uri
1622
+ featuredImage {
1623
+ node {
1624
+ sourceUrl
1625
+ altText
1626
+ mediaDetails { width height }
1627
+ }
1628
+ }
1629
+ ${SEO_FIELDS}
1630
+ `;
1631
+ var GQL_GET_POST_WITH_SEO = `
1632
+ query GetPostWithSEO($slug: ID!) {
1633
+ post(id: $slug, idType: SLUG) { ${POST_FIELDS_WITH_SEO} }
1634
+ }
1635
+ `;
1636
+ var GQL_GET_PAGE_WITH_SEO = `
1637
+ query GetPageWithSEO($slug: ID!) {
1638
+ page(id: $slug, idType: SLUG) { ${PAGE_FIELDS_WITH_SEO} }
1639
+ }
1640
+ `;
1641
+ var GQL_GET_PAGE_WITH_SEO_BY_URI = `
1642
+ query GetPageWithSEOByUri($uri: ID!) {
1643
+ page(id: $uri, idType: URI) { ${PAGE_FIELDS_WITH_SEO} }
1644
+ }
1645
+ `;
1646
+ function createYoastQueries(fetcher) {
1647
+ const { gqlFetchGraceful } = fetcher;
1648
+ async function getPostWithSEO(slug) {
1649
+ const data = await gqlFetchGraceful(
1650
+ GQL_GET_POST_WITH_SEO,
1651
+ { post: null },
1652
+ { slug },
1653
+ ["wpgraphql", "gql-posts", "gql-yoast", `gql-post-${slug}`]
1654
+ );
1655
+ return data.post;
1656
+ }
1657
+ async function getPageWithSEO(slug) {
1658
+ const data = await gqlFetchGraceful(
1659
+ GQL_GET_PAGE_WITH_SEO,
1660
+ { page: null },
1661
+ { slug },
1662
+ ["wpgraphql", "gql-pages", "gql-yoast", `gql-page-${slug}`]
1663
+ );
1664
+ return data.page;
1665
+ }
1666
+ async function getPageWithSEOByUri(uri) {
1667
+ const data = await gqlFetchGraceful(
1668
+ GQL_GET_PAGE_WITH_SEO_BY_URI,
1669
+ { page: null },
1670
+ { uri },
1671
+ ["wpgraphql", "gql-pages", "gql-yoast", `gql-page-uri-${uri.replace(/\//g, "-")}`]
1672
+ );
1673
+ return data.page;
1674
+ }
1675
+ return { getPostWithSEO, getPageWithSEO, getPageWithSEOByUri };
1676
+ }
1677
+
1678
+ // src/integrations/wpGraphQL/acf/helpers.ts
1679
+ var BASE_POST_FIELDS = `
1680
+ id databaseId slug title content excerpt date modified status uri
1681
+ author { node { databaseId name slug avatar { url } } }
1682
+ featuredImage { node { sourceUrl altText mediaDetails { width height } } }
1683
+ categories { nodes { databaseId name slug } }
1684
+ tags { nodes { databaseId name slug } }
1685
+ `;
1686
+ var BASE_PAGE_FIELDS = `
1687
+ id databaseId slug title content date modified status uri
1688
+ featuredImage { node { sourceUrl altText mediaDetails { width height } } }
1689
+ `;
1690
+ function buildACFFragment(fieldGroupName, fields) {
1691
+ return `${fieldGroupName} { ${fields.join(" ")} }`;
1692
+ }
1693
+ function buildPostWithACFQuery(fieldGroupName, fields) {
1694
+ return `
1695
+ query GetPostWithACF($slug: ID!) {
1696
+ post(id: $slug, idType: SLUG) {
1697
+ ${BASE_POST_FIELDS}
1698
+ ${buildACFFragment(fieldGroupName, fields)}
1699
+ }
1700
+ }
1701
+ `;
1702
+ }
1703
+ function buildPageWithACFQuery(fieldGroupName, fields) {
1704
+ return `
1705
+ query GetPageWithACF($slug: ID!) {
1706
+ page(id: $slug, idType: SLUG) {
1707
+ ${BASE_PAGE_FIELDS}
1708
+ ${buildACFFragment(fieldGroupName, fields)}
1709
+ }
1710
+ }
1711
+ `;
1712
+ }
1713
+ function buildPostsWithACFQuery(fieldGroupName, fields) {
1714
+ return `
1715
+ query GetPostsWithACF($first: Int, $after: String) {
1716
+ posts(first: $first, after: $after) {
1717
+ nodes {
1718
+ ${BASE_POST_FIELDS}
1719
+ ${buildACFFragment(fieldGroupName, fields)}
1720
+ }
1721
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1722
+ }
1723
+ }
1724
+ `;
1725
+ }
1726
+
1727
+ // src/integrations/wpGraphQL/woocommerce/products/queries.ts
1728
+ var DEFAULT_FIRST6 = 10;
1729
+ var BATCH_FIRST3 = 100;
1730
+ var PRODUCT_FIELDS = `
1731
+ id
1732
+ databaseId
1733
+ slug
1734
+ name
1735
+ status
1736
+ description
1737
+ shortDescription
1738
+ type
1739
+ onSale
1740
+ featuredImage { node { sourceUrl altText } }
1741
+ galleryImages { nodes { sourceUrl altText } }
1742
+ productCategories { nodes { databaseId name slug } }
1743
+ productTags { nodes { databaseId name slug } }
1744
+ ... on SimpleProduct {
1745
+ sku
1746
+ price
1747
+ regularPrice
1748
+ salePrice
1749
+ stockStatus
1750
+ stockQuantity
1751
+ manageStock
1752
+ }
1753
+ ... on VariableProduct {
1754
+ price
1755
+ regularPrice
1756
+ salePrice
1757
+ stockStatus
1758
+ stockQuantity
1759
+ manageStock
1760
+ variations {
1761
+ nodes {
1762
+ id
1763
+ databaseId
1764
+ slug
1765
+ sku
1766
+ price
1767
+ regularPrice
1768
+ salePrice
1769
+ onSale
1770
+ stockStatus
1771
+ stockQuantity
1772
+ image { sourceUrl altText }
1773
+ attributes { nodes { name value } }
1774
+ }
1775
+ }
1776
+ }
1777
+ `;
1778
+ var GQL_GET_PRODUCTS = `
1779
+ query GetProducts($first: Int, $after: String, $where: RootQueryToProductConnectionWhereArgs) {
1780
+ products(first: $first, after: $after, where: $where) {
1781
+ nodes { ${PRODUCT_FIELDS} }
1782
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1783
+ }
1784
+ }
1785
+ `;
1786
+ var GQL_GET_PRODUCT_BY_SLUG = `
1787
+ query GetProductBySlug($slug: ID!) {
1788
+ product(id: $slug, idType: SLUG) { ${PRODUCT_FIELDS} }
1789
+ }
1790
+ `;
1791
+ var GQL_GET_PRODUCT_BY_DATABASE_ID = `
1792
+ query GetProductByDatabaseId($id: ID!) {
1793
+ product(id: $id, idType: DATABASE_ID) { ${PRODUCT_FIELDS} }
1794
+ }
1795
+ `;
1796
+ var GQL_GET_ALL_PRODUCT_SLUGS = `
1797
+ query GetAllProductSlugs($first: Int, $after: String) {
1798
+ products(first: $first, after: $after) {
1799
+ nodes { slug }
1800
+ pageInfo { hasNextPage endCursor }
1801
+ }
1802
+ }
1803
+ `;
1804
+ function createProductsQueries2(fetcher) {
1805
+ const { gqlFetch, gqlFetchGraceful } = fetcher;
1806
+ async function getProducts(first = DEFAULT_FIRST6, after, filter) {
1807
+ const where = {};
1808
+ if (filter?.search) where["search"] = filter.search;
1809
+ if (filter?.onSale !== void 0) where["onSale"] = filter.onSale;
1810
+ if (filter?.featured !== void 0) where["featured"] = filter.featured;
1811
+ if (filter?.stockStatus) where["stockStatus"] = filter.stockStatus;
1812
+ if (filter?.minPrice) where["minPrice"] = filter.minPrice;
1813
+ if (filter?.maxPrice) where["maxPrice"] = filter.maxPrice;
1814
+ if (filter?.categoryId) where["categoryIdIn"] = [filter.categoryId];
1815
+ if (filter?.tagId) where["tagIdIn"] = [filter.tagId];
1816
+ const data = await gqlFetchGraceful(
1817
+ GQL_GET_PRODUCTS,
1818
+ { products: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1819
+ { first, after, where: Object.keys(where).length > 0 ? where : void 0 },
1820
+ ["wpgraphql", "gql-products"]
1821
+ );
1822
+ return data.products;
1823
+ }
1824
+ async function getProductBySlug(slug) {
1825
+ const data = await gqlFetchGraceful(
1826
+ GQL_GET_PRODUCT_BY_SLUG,
1827
+ { product: null },
1828
+ { slug },
1829
+ ["wpgraphql", "gql-products", `gql-product-${slug}`]
1830
+ );
1831
+ return data.product;
1832
+ }
1833
+ async function getProductByDatabaseId(id) {
1834
+ const data = await gqlFetchGraceful(
1835
+ GQL_GET_PRODUCT_BY_DATABASE_ID,
1836
+ { product: null },
1837
+ { id: String(id) },
1838
+ ["wpgraphql", "gql-products", `gql-product-id-${id}`]
1839
+ );
1840
+ return data.product;
1841
+ }
1842
+ async function getFeaturedProducts(first = DEFAULT_FIRST6) {
1843
+ const connection = await getProducts(first, void 0, { featured: true });
1844
+ return connection.nodes;
1845
+ }
1846
+ async function getOnSaleProducts(first = DEFAULT_FIRST6) {
1847
+ const connection = await getProducts(first, void 0, { onSale: true });
1848
+ return connection.nodes;
1849
+ }
1850
+ async function getAllProductSlugs() {
1851
+ try {
1852
+ const all = [];
1853
+ let after = void 0;
1854
+ let hasNextPage = true;
1855
+ while (hasNextPage) {
1856
+ const data = await gqlFetch(GQL_GET_ALL_PRODUCT_SLUGS, { first: BATCH_FIRST3, after }, ["wpgraphql"]);
1857
+ all.push(...data.products.nodes);
1858
+ hasNextPage = data.products.pageInfo.hasNextPage;
1859
+ after = data.products.pageInfo.endCursor;
1860
+ }
1861
+ return all;
1862
+ } catch {
1863
+ console.warn("WPGraphQL unavailable, skipping static generation for products");
1864
+ return [];
1865
+ }
1866
+ }
1867
+ return {
1868
+ getProducts,
1869
+ getProductBySlug,
1870
+ getProductByDatabaseId,
1871
+ getFeaturedProducts,
1872
+ getOnSaleProducts,
1873
+ getAllProductSlugs
1874
+ };
1875
+ }
1876
+
1877
+ // src/integrations/wpGraphQL/woocommerce/orders/queries.ts
1878
+ var DEFAULT_FIRST7 = 10;
1879
+ var ADDRESS_FIELDS = `
1880
+ firstName lastName address1 address2 city postcode country email phone
1881
+ `;
1882
+ var ORDER_FIELDS = `
1883
+ id
1884
+ databaseId
1885
+ orderNumber
1886
+ status
1887
+ date
1888
+ modified
1889
+ total
1890
+ subtotal
1891
+ totalTax
1892
+ shippingTotal
1893
+ currency
1894
+ billing { ${ADDRESS_FIELDS} }
1895
+ shipping { ${ADDRESS_FIELDS} }
1896
+ lineItems {
1897
+ nodes {
1898
+ productId
1899
+ variationId
1900
+ quantity
1901
+ subtotal
1902
+ total
1903
+ product { node { databaseId name slug } }
1904
+ }
1905
+ }
1906
+ `;
1907
+ var GQL_GET_ORDER = `
1908
+ query GetOrder($id: ID!) {
1909
+ order(id: $id, idType: DATABASE_ID) { ${ORDER_FIELDS} }
1910
+ }
1911
+ `;
1912
+ var GQL_GET_MY_ORDERS = `
1913
+ query GetMyOrders($first: Int, $after: String) {
1914
+ orders(first: $first, after: $after) {
1915
+ nodes { ${ORDER_FIELDS} }
1916
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
1917
+ }
1918
+ }
1919
+ `;
1920
+ function createOrdersQueries2(fetcher) {
1921
+ const { gqlFetchGraceful } = fetcher;
1922
+ async function getOrder(id) {
1923
+ const data = await gqlFetchGraceful(
1924
+ GQL_GET_ORDER,
1925
+ { order: null },
1926
+ { id: String(id) },
1927
+ ["wpgraphql", "gql-orders", `gql-order-${id}`]
1928
+ );
1929
+ return data.order;
1930
+ }
1931
+ async function getMyOrders(first = DEFAULT_FIRST7, after) {
1932
+ const data = await gqlFetchGraceful(
1933
+ GQL_GET_MY_ORDERS,
1934
+ { orders: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
1935
+ { first, after },
1936
+ ["wpgraphql", "gql-orders"]
1937
+ );
1938
+ return data.orders;
1939
+ }
1940
+ return { getOrder, getMyOrders };
1941
+ }
1942
+
1943
+ // src/integrations/wpGraphQL/woocommerce/customers/queries.ts
1944
+ var ADDRESS_FIELDS2 = `
1945
+ firstName lastName address1 address2 city postcode country
1946
+ `;
1947
+ var CUSTOMER_FIELDS = `
1948
+ id
1949
+ databaseId
1950
+ email
1951
+ firstName
1952
+ lastName
1953
+ username
1954
+ billing { ${ADDRESS_FIELDS2} phone }
1955
+ shipping { ${ADDRESS_FIELDS2} }
1956
+ `;
1957
+ var GQL_GET_CUSTOMER = `
1958
+ query GetCustomer {
1959
+ customer { ${CUSTOMER_FIELDS} }
1960
+ }
1961
+ `;
1962
+ var GQL_GET_CUSTOMER_BY_ID = `
1963
+ query GetCustomerById($id: ID!) {
1964
+ customer(customerId: $id) { ${CUSTOMER_FIELDS} }
1965
+ }
1966
+ `;
1967
+ function createCustomersQueries2(fetcher) {
1968
+ const { gqlFetchGraceful } = fetcher;
1969
+ async function getCustomer() {
1970
+ const data = await gqlFetchGraceful(
1971
+ GQL_GET_CUSTOMER,
1972
+ { customer: null },
1973
+ void 0,
1974
+ ["wpgraphql", "gql-customer"]
1975
+ );
1976
+ return data.customer;
1977
+ }
1978
+ async function getCustomerById(id) {
1979
+ const data = await gqlFetchGraceful(
1980
+ GQL_GET_CUSTOMER_BY_ID,
1981
+ { customer: null },
1982
+ { id: String(id) },
1983
+ ["wpgraphql", "gql-customer", `gql-customer-${id}`]
1984
+ );
1985
+ return data.customer;
1986
+ }
1987
+ return { getCustomer, getCustomerById };
1988
+ }
1989
+
1990
+ // src/integrations/wpGraphQL/woocommerce/index.ts
1991
+ function createWPGraphQLWooCommerceClient(config) {
1992
+ const fetcher = createWPGraphQLFetcher(config);
1993
+ return {
1994
+ ...createProductsQueries2(fetcher),
1995
+ ...createOrdersQueries2(fetcher),
1996
+ ...createCustomersQueries2(fetcher)
1997
+ };
1998
+ }
1999
+
2000
+ // src/integrations/wpGraphQL/cpt/queries.ts
2001
+ var DEFAULT_FIRST8 = 10;
2002
+ var BATCH_FIRST4 = 100;
2003
+ var BASE_CPT_FIELDS = `
2004
+ id databaseId slug title date modified status uri
2005
+ `;
2006
+ function createCPTQueries(fetcher, typeName, singularTypeName, extraFields) {
2007
+ const { gqlFetch, gqlFetchGraceful } = fetcher;
2008
+ const fields = extraFields ? `${BASE_CPT_FIELDS} ${extraFields}` : BASE_CPT_FIELDS;
2009
+ const GQL_GET_ITEMS = `
2010
+ query GetCPT_${typeName}($first: Int, $after: String) {
2011
+ ${typeName}(first: $first, after: $after) {
2012
+ nodes { ${fields} }
2013
+ pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
2014
+ }
2015
+ }
2016
+ `;
2017
+ const GQL_GET_ITEM_BY_SLUG = `
2018
+ query GetCPT_${singularTypeName}BySlug($slug: ID!) {
2019
+ ${singularTypeName}(id: $slug, idType: SLUG) { ${fields} }
2020
+ }
2021
+ `;
2022
+ const GQL_GET_ALL_SLUGS = `
2023
+ query GetAllCPT_${typeName}Slugs($first: Int, $after: String) {
2024
+ ${typeName}(first: $first, after: $after) {
2025
+ nodes { slug }
2026
+ pageInfo { hasNextPage endCursor }
2027
+ }
2028
+ }
2029
+ `;
2030
+ async function getItems(first = DEFAULT_FIRST8, after) {
2031
+ const data = await gqlFetchGraceful(
2032
+ GQL_GET_ITEMS,
2033
+ { [typeName]: { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } } },
2034
+ { first, after },
2035
+ ["wpgraphql", `gql-${typeName}`]
2036
+ );
2037
+ return data[typeName] ?? { nodes: [], pageInfo: { hasNextPage: false, hasPreviousPage: false } };
2038
+ }
2039
+ async function getItemBySlug(slug) {
2040
+ const data = await gqlFetchGraceful(
2041
+ GQL_GET_ITEM_BY_SLUG,
2042
+ { [singularTypeName]: null },
2043
+ { slug },
2044
+ ["wpgraphql", `gql-${typeName}`, `gql-${singularTypeName}-${slug}`]
2045
+ );
2046
+ return data[singularTypeName] ?? null;
2047
+ }
2048
+ async function getAllSlugs() {
2049
+ try {
2050
+ const all = [];
2051
+ let after = void 0;
2052
+ let hasNextPage = true;
2053
+ while (hasNextPage) {
2054
+ const data = await gqlFetch(GQL_GET_ALL_SLUGS, { first: BATCH_FIRST4, after }, ["wpgraphql"]);
2055
+ const connection = data[typeName];
2056
+ if (!connection) break;
2057
+ all.push(...connection.nodes);
2058
+ hasNextPage = connection.pageInfo.hasNextPage;
2059
+ after = connection.pageInfo.endCursor;
2060
+ }
2061
+ return all;
2062
+ } catch {
2063
+ console.warn(`WPGraphQL unavailable, skipping static generation for ${typeName}`);
2064
+ return [];
2065
+ }
2066
+ }
2067
+ return { getItems, getItemBySlug, getAllSlugs };
2068
+ }
2069
+
2070
+ exports.WPGraphQLError = WPGraphQLError;
2071
+ exports.buildACFFragment = buildACFFragment;
2072
+ exports.buildPageWithACFQuery = buildPageWithACFQuery;
2073
+ exports.buildPostWithACFQuery = buildPostWithACFQuery;
2074
+ exports.buildPostsWithACFQuery = buildPostsWithACFQuery;
2075
+ exports.createCPTQueries = createCPTQueries;
2076
+ exports.createWPGraphQLClient = createWPGraphQLCoreClient;
2077
+ exports.createWPGraphQLCoreClient = createWPGraphQLCoreClient;
2078
+ exports.createWPGraphQLFetcher = createWPGraphQLFetcher;
2079
+ exports.createWPGraphQLWooCommerceClient = createWPGraphQLWooCommerceClient;
790
2080
  exports.createWooCommerceClient = createWooCommerceClient;
791
2081
  exports.createWooCommerceFetcher = createWooCommerceFetcher;
792
2082
  exports.createWordPressClient = createWordPressClient;
2083
+ exports.createYoastQueries = createYoastQueries;
793
2084
  exports.extractOmnibusData = extractOmnibusData;
794
2085
  exports.resolveBaseUrl = resolveBaseUrl;
795
2086
  exports.withOmnibus = withOmnibus;