nextpress-core 1.0.0 → 1.0.1

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.
Files changed (182) hide show
  1. package/dist/acf-functions/core/acf-builder.d.ts +50 -0
  2. package/{lib/acf-functions/core/acf-builder.ts → dist/acf-functions/core/acf-builder.js} +17 -41
  3. package/dist/acf-functions/core/acf-component-autoloader.d.ts +11 -0
  4. package/{lib/acf-functions/core/acf-component-autoloader.ts → dist/acf-functions/core/acf-component-autoloader.js} +7 -13
  5. package/dist/acf-functions/core/acf-field-group-autoloader.d.ts +9 -0
  6. package/{lib/acf-functions/core/acf-field-group-autoloader.ts → dist/acf-functions/core/acf-field-group-autoloader.js} +4 -9
  7. package/dist/acf-functions/services/define-field-group.d.ts +8 -0
  8. package/{lib/acf-functions/services/define-field-group.ts → dist/acf-functions/services/define-field-group.js} +1 -1
  9. package/dist/acf-functions/services/define-layout.d.ts +8 -0
  10. package/{lib/acf-functions/services/define-layout.ts → dist/acf-functions/services/define-layout.js} +1 -1
  11. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.d.ts +2 -0
  12. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.js +18 -0
  13. package/dist/acf-functions/services/map-fields/map-fields.d.ts +18 -0
  14. package/{lib/acf-functions/services/map-fields/map-fields.ts → dist/acf-functions/services/map-fields/map-fields.js} +88 -124
  15. package/dist/entities/option/option.d.ts +19 -0
  16. package/{lib/entities/option/option.ts → dist/entities/option/option.js} +13 -20
  17. package/dist/entities/post/post.d.ts +50 -0
  18. package/dist/entities/post/post.js +184 -0
  19. package/dist/entities/term/term.d.ts +28 -0
  20. package/dist/entities/term/term.js +67 -0
  21. package/dist/entities/user/user.d.ts +27 -0
  22. package/dist/entities/user/user.js +74 -0
  23. package/dist/globals/entity-loader/entity-loader-base.d.ts +65 -0
  24. package/{lib/globals/entity-loader/entity-loader-base.ts → dist/globals/entity-loader/entity-loader-base.js} +10 -64
  25. package/dist/globals/entity-loader/option-loader.d.ts +15 -0
  26. package/dist/globals/entity-loader/option-loader.js +31 -0
  27. package/dist/globals/entity-loader/post-loader.d.ts +21 -0
  28. package/dist/globals/entity-loader/post-loader.js +28 -0
  29. package/dist/globals/entity-loader/term-loader.d.ts +21 -0
  30. package/dist/globals/entity-loader/term-loader.js +28 -0
  31. package/dist/globals/entity-loader/user-loader.d.ts +21 -0
  32. package/dist/globals/entity-loader/user-loader.js +28 -0
  33. package/dist/globals/get-field/get-field.d.ts +17 -0
  34. package/dist/globals/get-field/get-field.js +44 -0
  35. package/dist/globals/globals.d.ts +18 -0
  36. package/{lib/globals/globals.ts → dist/globals/globals.js} +3 -8
  37. package/dist/globals/nextpress-config/nextpress-config.d.ts +4 -0
  38. package/{lib/globals/nextpress-config/nextpress-config.ts → dist/globals/nextpress-config/nextpress-config.js} +0 -5
  39. package/dist/globals/queried-object/queried-object.d.ts +62 -0
  40. package/dist/globals/queried-object/queried-object.js +56 -0
  41. package/dist/repository/optionquery/option-query.d.ts +12 -0
  42. package/dist/repository/optionquery/option-query.js +20 -0
  43. package/dist/repository/postquery/post-query.d.ts +12 -0
  44. package/dist/repository/postquery/post-query.js +272 -0
  45. package/dist/repository/termquery/term-query.d.ts +11 -0
  46. package/dist/repository/termquery/term-query.js +213 -0
  47. package/dist/repository/userquery/user-query.d.ts +12 -0
  48. package/{lib/repository/userquery/user-query.ts → dist/repository/userquery/user-query.js} +75 -91
  49. package/dist/router/helpers.d.ts +14 -0
  50. package/{lib/router/helpers.ts → dist/router/helpers.js} +4 -4
  51. package/dist/router/nextpress-layout.d.ts +11 -0
  52. package/{lib/router/nextpress-layout.tsx → dist/router/nextpress-layout.js} +6 -23
  53. package/dist/router/nextpress-proxy.d.ts +8 -0
  54. package/{lib/router/nextpress-proxy.ts → dist/router/nextpress-proxy.js} +3 -15
  55. package/dist/router/nextpress-static-params.d.ts +9 -0
  56. package/{lib/router/nextpress-static-params.ts → dist/router/nextpress-static-params.js} +5 -17
  57. package/dist/router/router.d.ts +23 -0
  58. package/{lib/router/router.tsx → dist/router/router.js} +21 -29
  59. package/dist/router/routes/api/api-get-admin-bar.d.ts +8 -0
  60. package/{lib/router/routes/api/api-get-admin-bar.ts → dist/router/routes/api/api-get-admin-bar.js} +6 -8
  61. package/dist/router/routes/api/api-get-draft-mode.d.ts +8 -0
  62. package/{lib/router/routes/api/api-get-draft-mode.ts → dist/router/routes/api/api-get-draft-mode.js} +6 -15
  63. package/dist/router/routes/api/api-get-field-groups.d.ts +7 -0
  64. package/{lib/router/routes/api/api-get-field-groups.ts → dist/router/routes/api/api-get-field-groups.js} +6 -11
  65. package/dist/router/routes/api/api-post-revalidate.d.ts +7 -0
  66. package/{lib/router/routes/api/api-post-revalidate.ts → dist/router/routes/api/api-post-revalidate.js} +4 -6
  67. package/dist/router/routes/api/helpers.d.ts +8 -0
  68. package/{lib/router/routes/api/helpers.ts → dist/router/routes/api/helpers.js} +3 -4
  69. package/dist/router/routes/author-archive.d.ts +25 -0
  70. package/{lib/router/routes/author-archive.tsx → dist/router/routes/author-archive.js} +11 -37
  71. package/dist/router/routes/not-found-page.d.ts +15 -0
  72. package/{lib/router/routes/not-found-page.tsx → dist/router/routes/not-found-page.js} +3 -5
  73. package/dist/router/routes/post-index-page.d.ts +25 -0
  74. package/dist/router/routes/post-index-page.js +33 -0
  75. package/dist/router/routes/singular-page.d.ts +29 -0
  76. package/dist/router/routes/singular-page.js +51 -0
  77. package/dist/router/routes/site-front-page.d.ts +27 -0
  78. package/dist/router/routes/site-front-page.js +26 -0
  79. package/dist/router/routes/term-archive.d.ts +29 -0
  80. package/{lib/router/routes/term-archive.tsx → dist/router/routes/term-archive.js} +17 -45
  81. package/dist/services/get-menu.d.ts +13 -0
  82. package/{lib/services/get-menu.ts → dist/services/get-menu.js} +32 -56
  83. package/dist/services/get-theme-mods.d.ts +7 -0
  84. package/{lib/services/get-theme-mods.ts → dist/services/get-theme-mods.js} +4 -6
  85. package/dist/services/metadata/get-blogname.d.ts +6 -0
  86. package/{lib/services/metadata/get-blogname.ts → dist/services/metadata/get-blogname.js} +2 -2
  87. package/dist/services/metadata/get-favicon-url.d.ts +6 -0
  88. package/{lib/services/metadata/get-favicon-url.ts → dist/services/metadata/get-favicon-url.js} +4 -5
  89. package/dist/services/metadata/get-language-attribute.d.ts +6 -0
  90. package/{lib/services/metadata/get-language-attribute.ts → dist/services/metadata/get-language-attribute.js} +1 -1
  91. package/{lib/services/services.ts → dist/services/services.d.ts} +1 -5
  92. package/dist/services/services.js +3 -0
  93. package/dist/services/utilities/capitalise-first-letter.d.ts +7 -0
  94. package/{lib/services/utilities/capitalise-first-letter.ts → dist/services/utilities/capitalise-first-letter.js} +3 -2
  95. package/dist/services/utilities/esc-html.d.ts +7 -0
  96. package/{lib/services/utilities/esc-html.ts → dist/services/utilities/esc-html.js} +1 -3
  97. package/dist/services/utilities/get-date-time-formatter.d.ts +6 -0
  98. package/{lib/services/utilities/get-date-time-formatter.ts → dist/services/utilities/get-date-time-formatter.js} +6 -16
  99. package/dist/services/utilities/index.js +1 -0
  100. package/dist/services/utilities/kses-post.d.ts +7 -0
  101. package/{lib/services/utilities/kses-post.ts → dist/services/utilities/kses-post.js} +1 -2
  102. package/dist/services/utilities/process-url.d.ts +7 -0
  103. package/{lib/services/utilities/process-url.ts → dist/services/utilities/process-url.js} +3 -4
  104. package/dist/template-heirarchy/_autoloader/template-autoloader.d.ts +9 -0
  105. package/{lib/template-heirarchy/_autoloader/template-autoloader.ts → dist/template-heirarchy/_autoloader/template-autoloader.js} +9 -18
  106. package/dist/template-heirarchy/archive/archive.d.ts +16 -0
  107. package/{lib/template-heirarchy/archive/archive.tsx → dist/template-heirarchy/archive/archive.js} +7 -10
  108. package/dist/template-heirarchy/archive/author.d.ts +16 -0
  109. package/{lib/template-heirarchy/archive/author.tsx → dist/template-heirarchy/archive/author.js} +7 -10
  110. package/dist/template-heirarchy/archive/category.d.ts +16 -0
  111. package/{lib/template-heirarchy/archive/category.tsx → dist/template-heirarchy/archive/category.js} +7 -11
  112. package/dist/template-heirarchy/archive/posttypearchive.d.ts +24 -0
  113. package/{lib/template-heirarchy/archive/posttypearchive.tsx → dist/template-heirarchy/archive/posttypearchive.js} +7 -10
  114. package/dist/template-heirarchy/archive/tag.d.ts +16 -0
  115. package/{lib/template-heirarchy/archive/tag.tsx → dist/template-heirarchy/archive/tag.js} +7 -12
  116. package/dist/template-heirarchy/archive/taxonomy.d.ts +16 -0
  117. package/{lib/template-heirarchy/archive/taxonomy.tsx → dist/template-heirarchy/archive/taxonomy.js} +7 -10
  118. package/dist/template-heirarchy/home/home.d.ts +16 -0
  119. package/{lib/template-heirarchy/home/home.tsx → dist/template-heirarchy/home/home.js} +7 -10
  120. package/dist/template-heirarchy/index.d.ts +17 -0
  121. package/{lib/template-heirarchy/index.tsx → dist/template-heirarchy/index.js} +5 -9
  122. package/dist/template-heirarchy/not-found.tsx/not-found.d.ts +16 -0
  123. package/{lib/template-heirarchy/not-found.tsx/not-found.tsx → dist/template-heirarchy/not-found.tsx/not-found.js} +7 -10
  124. package/dist/template-heirarchy/page/page.d.ts +16 -0
  125. package/{lib/template-heirarchy/page/page.tsx → dist/template-heirarchy/page/page.js} +7 -10
  126. package/dist/template-heirarchy/page/posttype.d.ts +24 -0
  127. package/{lib/template-heirarchy/page/posttype.tsx → dist/template-heirarchy/page/posttype.js} +7 -11
  128. package/dist/template-heirarchy/page/single.d.ts +16 -0
  129. package/{lib/template-heirarchy/page/single.tsx → dist/template-heirarchy/page/single.js} +7 -10
  130. package/dist/template-heirarchy/page/singular.d.ts +16 -0
  131. package/{lib/template-heirarchy/page/singular.tsx → dist/template-heirarchy/page/singular.js} +7 -10
  132. package/dist/ui/render-attachment-image.d.ts +12 -0
  133. package/dist/ui/render-attachment-image.js +24 -0
  134. package/{lib/ui/render-components.tsx → dist/ui/render-components.d.ts} +4 -7
  135. package/dist/ui/render-components.js +7 -0
  136. package/dist/ui/render-the-admin-bar.d.ts +8 -0
  137. package/dist/ui/render-the-admin-bar.js +36 -0
  138. package/dist/ui/render-the-logo.d.ts +10 -0
  139. package/dist/ui/render-the-logo.js +16 -0
  140. package/dist/wpdb/wpdb.d.ts +3 -0
  141. package/{lib/wpdb/wpdb.ts → dist/wpdb/wpdb.js} +5 -9
  142. package/package.json +7 -3
  143. package/lib/acf-functions/services/map-fields/helpers/map-choice-object.ts +0 -20
  144. package/lib/acf-functions/types/acf-field-group.d.ts +0 -118
  145. package/lib/acf-functions/types/acf-field.d.ts +0 -2851
  146. package/lib/acf-functions/types/acf-layout.d.ts +0 -20
  147. package/lib/acf-functions/types/acf-values.d.ts +0 -4
  148. package/lib/acf-functions/types/components/field-props.d.ts +0 -189
  149. package/lib/acf-functions/types/components/nextpress-component.d.ts +0 -11
  150. package/lib/ambient.d.ts +0 -15
  151. package/lib/entities/common.d.ts +0 -30
  152. package/lib/entities/option/option.interface.d.ts +0 -8
  153. package/lib/entities/post/post.interface.d.ts +0 -72
  154. package/lib/entities/post/post.ts +0 -209
  155. package/lib/entities/term/term.interface.d.ts +0 -8
  156. package/lib/entities/term/term.ts +0 -82
  157. package/lib/entities/user/user.interface.d.ts +0 -10
  158. package/lib/entities/user/user.ts +0 -86
  159. package/lib/globals/entity-loader/entity-loader.d.ts +0 -50
  160. package/lib/globals/entity-loader/option-loader.ts +0 -56
  161. package/lib/globals/entity-loader/post-loader.ts +0 -59
  162. package/lib/globals/entity-loader/term-loader.ts +0 -59
  163. package/lib/globals/entity-loader/user-loader.ts +0 -60
  164. package/lib/globals/get-field/get-field.ts +0 -75
  165. package/lib/globals/nextpress-config/nextpress-config.interface.d.ts +0 -18
  166. package/lib/globals/queried-object/queried-object.ts +0 -124
  167. package/lib/repository/optionquery/option-query-args.d.ts +0 -21
  168. package/lib/repository/optionquery/option-query.ts +0 -29
  169. package/lib/repository/postquery/post-query-args.d.ts +0 -108
  170. package/lib/repository/postquery/post-query.ts +0 -281
  171. package/lib/repository/termquery/term-query-args.d.ts +0 -61
  172. package/lib/repository/termquery/term-query.ts +0 -243
  173. package/lib/repository/userquery/user-query-args.d.ts +0 -75
  174. package/lib/router/routes/post-index-page.tsx +0 -58
  175. package/lib/router/routes/singular-page.tsx +0 -78
  176. package/lib/router/routes/site-front-page.tsx +0 -51
  177. package/lib/router/types.d.ts +0 -9
  178. package/lib/ui/render-attachment-image.tsx +0 -29
  179. package/lib/ui/render-the-admin-bar.tsx +0 -79
  180. package/lib/ui/render-the-logo.tsx +0 -24
  181. package/lib/wpdb/wpdb.interface.d.ts +0 -171
  182. /package/{lib/services/utilities/index.ts → dist/services/utilities/index.d.ts} +0 -0
@@ -1,194 +1,178 @@
1
1
  import { wpdb } from "@/wpdb/wpdb";
2
- import { IUser } from "../../entities/user/user.interface";
3
- import { EntityQuery } from "../../globals/entity-loader/entity-loader";
4
2
  import { sql } from "kysely";
5
-
6
3
  /**
7
4
  * Executes database queries to retrieve user IDs and counts based on provided arguments.
8
5
  */
9
- export class UserQuery implements EntityQuery<IUser>
10
- {
11
- private userCount?: number;
12
-
13
- constructor(
14
- private args: UserQueryArgs
15
- ) {}
16
-
17
- public getCount(): number | undefined {
6
+ export class UserQuery {
7
+ constructor(args) {
8
+ this.args = args;
9
+ }
10
+ getCount() {
18
11
  return this.userCount;
19
12
  }
20
-
21
- public async getIds(): Promise<number[]> {
13
+ async getIds() {
14
+ var _a, _b, _c;
22
15
  let query = wpdb.selectFrom('wpUsers');
23
-
24
16
  // --- ID Filters ---
25
17
  if (this.args.userId) {
26
18
  const types = Array.isArray(this.args.userId) ? this.args.userId : [this.args.userId];
27
19
  query = query.where('wpUsers.ID', 'in', types);
28
20
  }
29
- if (this.args.userIdsNotIn) query = query.where('wpUsers.ID', 'not in', this.args.userIdsNotIn);
30
-
21
+ if (this.args.userIdsNotIn)
22
+ query = query.where('wpUsers.ID', 'not in', this.args.userIdsNotIn);
31
23
  // --- Nicename Filters ---
32
- if (this.args.nicename) query = query.where('wpUsers.userNicename', '=', this.args.nicename);
33
- if (this.args.nicenameIn) query = query.where('wpUsers.userNicename', 'in', this.args.nicenameIn);
34
- if (this.args.nicenameNotIn) query = query.where('wpUsers.userNicename', 'not in', this.args.nicenameNotIn);
35
-
24
+ if (this.args.nicename)
25
+ query = query.where('wpUsers.userNicename', '=', this.args.nicename);
26
+ if (this.args.nicenameIn)
27
+ query = query.where('wpUsers.userNicename', 'in', this.args.nicenameIn);
28
+ if (this.args.nicenameNotIn)
29
+ query = query.where('wpUsers.userNicename', 'not in', this.args.nicenameNotIn);
36
30
  // --- Display name Filters ---
37
- if (this.args.displayName) query = query.where('wpUsers.displayName', '=', this.args.displayName);
38
- if (this.args.displayNameIn) query = query.where('wpUsers.displayName', 'in', this.args.displayNameIn);
39
- if (this.args.displayNameNotIn) query = query.where('wpUsers.displayName', 'not in', this.args.displayNameNotIn);
40
-
31
+ if (this.args.displayName)
32
+ query = query.where('wpUsers.displayName', '=', this.args.displayName);
33
+ if (this.args.displayNameIn)
34
+ query = query.where('wpUsers.displayName', 'in', this.args.displayNameIn);
35
+ if (this.args.displayNameNotIn)
36
+ query = query.where('wpUsers.displayName', 'not in', this.args.displayNameNotIn);
41
37
  // --- Login Filters ---
42
- if (this.args.login) query = query.where('wpUsers.userLogin', '=', this.args.login);
43
- if (this.args.loginIn) query = query.where('wpUsers.userLogin', 'in', this.args.loginIn);
44
- if (this.args.loginNotIn) query = query.where('wpUsers.userLogin', 'not in', this.args.loginNotIn);
45
-
38
+ if (this.args.login)
39
+ query = query.where('wpUsers.userLogin', '=', this.args.login);
40
+ if (this.args.loginIn)
41
+ query = query.where('wpUsers.userLogin', 'in', this.args.loginIn);
42
+ if (this.args.loginNotIn)
43
+ query = query.where('wpUsers.userLogin', 'not in', this.args.loginNotIn);
46
44
  // --- Role Filters ---
47
45
  if (this.args.roleIn) {
48
46
  query = query
49
47
  .innerJoin('wpUsermeta as um_role_in', 'wpUsers.ID', 'um_role_in.userId')
50
48
  .where('um_role_in.metaKey', '=', 'wp_capabilities')
51
49
  .where((eb) => {
52
- const orClauses = this.args.roleIn!.map(role =>
53
- eb('um_role_in.metaValue', 'like', `%"${role}"%`)
54
- );
55
- return eb.or(orClauses);
56
- });
50
+ const orClauses = this.args.roleIn.map(role => eb('um_role_in.metaValue', 'like', `%"${role}"%`));
51
+ return eb.or(orClauses);
52
+ });
57
53
  }
58
-
59
54
  if (this.args.roleAnd) {
60
55
  this.args.roleAnd.forEach((role, index) => {
61
- const alias = `um_role_and_${index}` as const;
62
-
56
+ const alias = `um_role_and_${index}`;
63
57
  query = query
64
58
  .innerJoin(`wpUsermeta as ${alias}`, 'wpUsers.ID', `${alias}.userId`)
65
59
  .where(`${alias}.metaKey`, '=', 'wp_capabilities')
66
60
  .where(`${alias}.metaValue`, 'like', `%"${role}"%`);
67
61
  });
68
62
  }
69
-
70
63
  if (this.args.roleNotIn) {
71
64
  this.args.roleNotIn.forEach((role, index) => {
72
- const alias = `um_role_not_${index}` as const;
73
-
65
+ const alias = `um_role_not_${index}`;
74
66
  query = query
75
67
  .innerJoin(`wpUsermeta as ${alias}`, 'wpUsers.ID', `${alias}.userId`)
76
68
  .where(`${alias}.metaKey`, '=', 'wp_capabilities')
77
69
  .where(`${alias}.metaValue`, 'not like', `%"${role}"%`);
78
70
  });
79
71
  }
80
-
81
72
  // --- Search Filters ---
82
73
  if (this.args.search) {
83
74
  const searchTerm = `%${this.args.search}%`;
84
75
  const searchCols = this.args.search_columns || ['ID', 'userLogin', 'userEmail', 'userUrl', 'userNicename', 'displayName'];
85
-
86
76
  query = query.where((eb) => {
87
77
  const orClauses = searchCols.map(col => eb(col, 'like', searchTerm));
88
78
  return eb.or(orClauses);
89
79
  });
90
80
  }
91
-
92
81
  // --- Published Posts Filter ---
93
82
  if (this.args.hasPublishedPosts) {
94
- query = query.where((eb) => eb(
95
- eb.selectFrom('wpPosts')
96
- .select(eb.fn.count<number>('ID').as('count'))
97
- .whereRef('wpPosts.postAuthor', '=', 'wpUsers.ID')
98
- .where('wpPosts.postStatus', '=', 'publish'),
99
- '>', 0
100
- ));
83
+ query = query.where((eb) => eb(eb.selectFrom('wpPosts')
84
+ .select(eb.fn.count('ID').as('count'))
85
+ .whereRef('wpPosts.postAuthor', '=', 'wpUsers.ID')
86
+ .where('wpPosts.postStatus', '=', 'publish'), '>', 0));
101
87
  }
102
-
103
88
  // 3. Calculate Total Count (Before Limits/Offsets)
104
89
  if (!this.args.noFoundRows) {
105
90
  try {
106
91
  const countQueryBase = query.clearSelect().select('wpUsers.ID').distinct();
107
92
  const countResult = await wpdb.selectFrom(countQueryBase.as('sub'))
108
- .select(sql<number>`count(*)`.as('count'))
93
+ .select(sql `count(*)`.as('count'))
109
94
  .executeTakeFirst();
110
-
111
95
  this.userCount = countResult ? Number(countResult.count) : undefined;
112
- } catch (error: any) {
96
+ }
97
+ catch (error) {
113
98
  console.error('WPUserQuery: Cannot get row count: ', error.message);
114
99
  this.userCount = undefined;
115
100
  }
116
- } else {
101
+ }
102
+ else {
117
103
  this.userCount = undefined;
118
104
  }
119
-
120
105
  // 4. Apply ORDER BY
121
106
  const orderDirection = this.args.order === 'DESC' ? 'desc' : 'asc';
122
107
  const orderBy = this.args.orderBy || 'none';
123
-
124
- switch(orderBy) {
125
- case 'ID': query = query.orderBy('wpUsers.ID', orderDirection).orderBy('wpUsers.ID', orderDirection); break;
126
- case 'name': query = query.orderBy('wpUsers.displayName', orderDirection).orderBy('wpUsers.ID', orderDirection); break;
127
- case 'login': query = query.orderBy('wpUsers.userLogin', orderDirection).orderBy('wpUsers.ID', orderDirection); break;
128
- case 'nicename': query = query.orderBy('wpUsers.userNicename', orderDirection).orderBy('wpUsers.ID', orderDirection); break;
129
- case 'email': query = query.orderBy('wpUsers.userEmail', orderDirection).orderBy('wpUsers.ID', orderDirection); break;
130
- case 'registered': query = query.orderBy('wpUsers.userRegistered', orderDirection).orderBy('wpUsers.ID', orderDirection); break;
108
+ switch (orderBy) {
109
+ case 'ID':
110
+ query = query.orderBy('wpUsers.ID', orderDirection).orderBy('wpUsers.ID', orderDirection);
111
+ break;
112
+ case 'name':
113
+ query = query.orderBy('wpUsers.displayName', orderDirection).orderBy('wpUsers.ID', orderDirection);
114
+ break;
115
+ case 'login':
116
+ query = query.orderBy('wpUsers.userLogin', orderDirection).orderBy('wpUsers.ID', orderDirection);
117
+ break;
118
+ case 'nicename':
119
+ query = query.orderBy('wpUsers.userNicename', orderDirection).orderBy('wpUsers.ID', orderDirection);
120
+ break;
121
+ case 'email':
122
+ query = query.orderBy('wpUsers.userEmail', orderDirection).orderBy('wpUsers.ID', orderDirection);
123
+ break;
124
+ case 'registered':
125
+ query = query.orderBy('wpUsers.userRegistered', orderDirection).orderBy('wpUsers.ID', orderDirection);
126
+ break;
131
127
  case 'post_count':
132
- query = query.orderBy(
133
- (eb) => eb.selectFrom('wpPosts')
134
- .select(eb.fn.count('ID').as('count'))
135
- .whereRef('wpPosts.postAuthor', '=', 'wpUsers.ID')
136
- .where('wpPosts.postStatus', '=', 'publish'),
137
- orderDirection
138
- ).orderBy('wpUsers.ID', orderDirection);
128
+ query = query.orderBy((eb) => eb.selectFrom('wpPosts')
129
+ .select(eb.fn.count('ID').as('count'))
130
+ .whereRef('wpPosts.postAuthor', '=', 'wpUsers.ID')
131
+ .where('wpPosts.postStatus', '=', 'publish'), orderDirection).orderBy('wpUsers.ID', orderDirection);
139
132
  break;
140
133
  case 'none': break;
141
134
  default:
142
135
  query = query.orderBy('wpUsers.userLogin', orderDirection).orderBy('wpUsers.ID', orderDirection);
143
136
  break;
144
137
  }
145
-
146
138
  // 5. Apply LIMIT & OFFSET
147
139
  if (!this.args.noPaging) {
148
- const perPage = this.args.usersPerPage ?? -1;
149
-
140
+ const perPage = (_a = this.args.usersPerPage) !== null && _a !== void 0 ? _a : -1;
150
141
  if (perPage > -1) {
151
142
  query = query.limit(perPage);
152
-
153
- const page = this.args.page ?? 1;
154
- const baseOffset = this.args.offset ?? 0;
143
+ const page = (_b = this.args.page) !== null && _b !== void 0 ? _b : 1;
144
+ const baseOffset = (_c = this.args.offset) !== null && _c !== void 0 ? _c : 0;
155
145
  const offsetAmount = ((page - 1) * perPage) + baseOffset;
156
-
157
146
  if (offsetAmount > 0) {
158
147
  query = query.offset(offsetAmount);
159
148
  }
160
149
  }
161
150
  }
162
-
163
151
  if (this.args.metaQuery) {
164
- let dynamicQuery: any = query;
165
-
152
+ let dynamicQuery = query;
166
153
  for (let metaQuery of this.args.metaQuery) {
167
154
  const uniqueAlias = `meta_${metaQuery.as}`;
168
-
169
- dynamicQuery = dynamicQuery.leftJoin(`wpUsermeta as ${uniqueAlias}`, (join: any) =>
170
- join
171
- .onRef(`${uniqueAlias}.userId`, '=', 'wpUsers.ID')
172
- .on(`${uniqueAlias}.metaKey`, '=', metaQuery.metaKey)
173
- )
155
+ dynamicQuery = dynamicQuery.leftJoin(`wpUsermeta as ${uniqueAlias}`, (join) => join
156
+ .onRef(`${uniqueAlias}.userId`, '=', 'wpUsers.ID')
157
+ .on(`${uniqueAlias}.metaKey`, '=', metaQuery.metaKey))
174
158
  .select(`${uniqueAlias}.metaValue as ${metaQuery.as}`);
175
159
  }
176
-
177
160
  query = dynamicQuery;
178
161
  }
179
-
180
162
  try {
181
163
  if (this.args.multiple !== false) {
182
164
  return (await query
183
165
  .select('wpUsers.ID as id')
184
166
  .groupBy('wpUsers.ID')
185
167
  .execute()).map(res => res.id);
186
- } else {
168
+ }
169
+ else {
187
170
  return (await query
188
171
  .select('wpUsers.ID as id')
189
172
  .execute()).map(res => res.id);
190
173
  }
191
- } catch (error: any) {
174
+ }
175
+ catch (error) {
192
176
  throw new Error(`WPUserQuery: Cannot get users: ${error.message}`, { cause: error });
193
177
  }
194
178
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Retrieves page number from path array.
3
+ *
4
+ * @param {string[]} path - Array of path segments.
5
+ * @returns {number | undefined} Page number or undefined.
6
+ */
7
+ export declare function getPageNumber(path: string[]): number | undefined;
8
+ /**
9
+ * Splits path string into array of segments.
10
+ *
11
+ * @param {string} path - Path string.
12
+ * @returns {string[]} Array of path segments.
13
+ */
14
+ export declare function splitPath(path: string): string[];
@@ -4,17 +4,17 @@
4
4
  * @param {string[]} path - Array of path segments.
5
5
  * @returns {number | undefined} Page number or undefined.
6
6
  */
7
- export function getPageNumber(path: string[]): number|undefined {
7
+ export function getPageNumber(path) {
8
8
  return path[path.length - 2] === 'page' ? Number(path[path.length - 1]) || undefined : undefined;
9
9
  }
10
-
11
10
  /**
12
11
  * Splits path string into array of segments.
13
12
  *
14
13
  * @param {string} path - Path string.
15
14
  * @returns {string[]} Array of path segments.
16
15
  */
17
- export function splitPath(path: string): string[] {
18
- if (!path) return [];
16
+ export function splitPath(path) {
17
+ if (!path)
18
+ return [];
19
19
  return path.split('/').filter(Boolean);
20
20
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The layout for the application.
3
+ * Defines the main HTML shell, handles Draft Mode validation, primes necessary global WordPress options,
4
+ * and routes directly to the `LayoutTemplate` within the Nextpress template hierarchy.
5
+ *
6
+ * @param {Readonly<{children: React.ReactNode;}>} props - Component properties, wrapping the children pages.
7
+ * @returns {Promise<JSX.Element>} The root layout of the entire app.
8
+ */
9
+ export declare function NextpressLayout({ children }: Readonly<{
10
+ children: React.ReactNode;
11
+ }>): Promise<import("react").JSX.Element>;
@@ -1,11 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import fonts from "@/fonts";
2
3
  import { LayoutTemplate } from "@/app/_templates/layout";
3
4
  import { cookies, draftMode } from "next/headers";
4
5
  import { getLanguageAttributes } from "@/services/metadata/get-language-attribute";
5
6
  import { RenderTheAdminBar } from "@/ui/render-the-admin-bar";
6
-
7
7
  const fontClasses = fonts.map(font => font.className).join(' ');
8
-
9
8
  /**
10
9
  * The layout for the application.
11
10
  * Defines the main HTML shell, handles Draft Mode validation, primes necessary global WordPress options,
@@ -14,35 +13,19 @@ const fontClasses = fonts.map(font => font.className).join(' ');
14
13
  * @param {Readonly<{children: React.ReactNode;}>} props - Component properties, wrapping the children pages.
15
14
  * @returns {Promise<JSX.Element>} The root layout of the entire app.
16
15
  */
17
- export async function NextpressLayout({ children }: Readonly<{children: React.ReactNode;}>) {
16
+ export async function NextpressLayout({ children }) {
17
+ var _a, _b;
18
18
  const draftModeEnabled = (await draftMode()).isEnabled;
19
19
  let loggedInUserId = 0;
20
20
  if (draftModeEnabled) {
21
21
  const cookieStore = await cookies();
22
- loggedInUserId = Number(cookieStore.get('nextpress_logged_in_user_id')?.value) || 0;
22
+ loggedInUserId = Number((_a = cookieStore.get('nextpress_logged_in_user_id')) === null || _a === void 0 ? void 0 : _a.value) || 0;
23
23
  }
24
-
25
24
  optionLoader.findAndPrime({
26
25
  column: 'optionName',
27
26
  operand: 'in',
28
27
  value: nextpressConfig.preLoadOptions || ''
29
- })
30
-
28
+ });
31
29
  const languageAttributes = await getLanguageAttributes();
32
-
33
- return (
34
- <html
35
- lang={languageAttributes}
36
- className={fontClasses}
37
- >
38
- <body className="">
39
- {(draftModeEnabled && (await getUser(loggedInUserId))?.showAdminBar) && <RenderTheAdminBar loggedInUserId={loggedInUserId}/>}
40
- <LayoutTemplate>
41
- {children}
42
- </LayoutTemplate>
43
- </body>
44
- </html>
45
- );
30
+ return (_jsx("html", { lang: languageAttributes, className: fontClasses, children: _jsxs("body", { className: "", children: [(draftModeEnabled && ((_b = (await getUser(loggedInUserId))) === null || _b === void 0 ? void 0 : _b.showAdminBar)) && _jsx(RenderTheAdminBar, { loggedInUserId: loggedInUserId }), _jsx(LayoutTemplate, { children: children })] }) }));
46
31
  }
47
-
48
-
@@ -0,0 +1,8 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+ /**
3
+ * Processes incoming requests to manage WordPress session cookies and redirects.
4
+ *
5
+ * @param {NextRequest} request - Incoming request.
6
+ * @returns {NextResponse} Response to proceed or redirect.
7
+ */
8
+ export declare function nextpressProxy(request: NextRequest): NextResponse;
@@ -1,22 +1,18 @@
1
- import { NextRequest, NextResponse } from "next/server";
2
-
1
+ import { NextResponse } from "next/server";
3
2
  /**
4
3
  * Processes incoming requests to manage WordPress session cookies and redirects.
5
4
  *
6
5
  * @param {NextRequest} request - Incoming request.
7
6
  * @returns {NextResponse} Response to proceed or redirect.
8
7
  */
9
- export function nextpressProxy(request: NextRequest): NextResponse {
8
+ export function nextpressProxy(request) {
10
9
  const url = request.nextUrl;
11
-
12
10
  if (url.pathname.startsWith('/api/draft')) {
13
11
  return NextResponse.next();
14
12
  }
15
-
16
13
  if (url.searchParams.has('nextpress_logged_in_user_id')) {
17
14
  const loggedInUserId = url.searchParams.get('nextpress_logged_in_user_id');
18
15
  url.searchParams.delete('nextpress_logged_in_user_id');
19
-
20
16
  const response = NextResponse.redirect(url);
21
17
  response.cookies.set('nextpress_logged_in_user_id', loggedInUserId || '0');
22
18
  return response;
@@ -24,22 +20,14 @@ export function nextpressProxy(request: NextRequest): NextResponse {
24
20
  if (request.cookies.has('nextpress_logged_in_user_id')) {
25
21
  return NextResponse.next();
26
22
  }
27
-
28
23
  const cookies = request.cookies;
29
-
30
- const hasWordpressCookie = cookies.getAll().some(cookie =>
31
- cookie.name.startsWith('wordpress_logged_in_')
32
- );
33
-
24
+ const hasWordpressCookie = cookies.getAll().some(cookie => cookie.name.startsWith('wordpress_logged_in_'));
34
25
  if (hasWordpressCookie) {
35
26
  const currentPath = url.pathname + url.search;
36
-
37
27
  const redirectUrl = url.clone();
38
28
  redirectUrl.pathname = '/api/draft';
39
29
  redirectUrl.searchParams.set('redirect', currentPath);
40
-
41
30
  return NextResponse.redirect(redirectUrl);
42
31
  }
43
-
44
32
  return NextResponse.next();
45
33
  }
@@ -0,0 +1,9 @@
1
+ import { NextpressRouterProps } from "./router";
2
+ export type NextpressStaticParams = Awaited<NextpressRouterProps['params']>[];
3
+ /**
4
+ * Generates static parameters for Next.js build-time prerendering.
5
+ * Queries authors, terms, and posts to generate a comprehensive list of all active routes.
6
+ *
7
+ * @returns {NextpressStaticParams} An array containing the route parameters to be generated statically.
8
+ */
9
+ export declare function nextpressStaticParams(): Promise<NextpressStaticParams>;
@@ -1,17 +1,13 @@
1
1
  import { splitPath } from "./helpers";
2
- import { NextpressRouterProps } from "./router";
3
-
4
- export type NextpressStaticParams = Awaited<NextpressRouterProps['params']>[];
5
-
6
2
  const { publicPostTypes, archivedPostTypes } = nextpressConfig;
7
-
8
3
  /**
9
4
  * Generates static parameters for Next.js build-time prerendering.
10
5
  * Queries authors, terms, and posts to generate a comprehensive list of all active routes.
11
6
  *
12
7
  * @returns {NextpressStaticParams} An array containing the route parameters to be generated statically.
13
8
  */
14
- export async function nextpressStaticParams(): Promise<NextpressStaticParams> {
9
+ export async function nextpressStaticParams() {
10
+ var _a;
15
11
  const { ids: authorIds } = await userLoader.findAndPrime({
16
12
  hasPublishedPosts: true,
17
13
  noFoundRows: false,
@@ -19,35 +15,28 @@ export async function nextpressStaticParams(): Promise<NextpressStaticParams> {
19
15
  });
20
16
  const authors = await getUsers(authorIds);
21
17
  const authorPaths = authors.map((author) => ['author', author.userLogin]);
22
-
23
18
  const { ids: termIds } = await termLoader.findAndPrime({});
24
19
  const terms = await getTerms(termIds);
25
20
  const termPaths = terms.map(term => [term.taxonomy, ...splitPath(term.path)]);
26
-
27
21
  const { ids: archivedPostIds } = await postLoader.findAndPrime({
28
22
  postStatus: 'publish',
29
- postType: archivedPostTypes?.filter(p => !publicPostTypes?.includes(p)) ?? 'post',
23
+ postType: (_a = archivedPostTypes === null || archivedPostTypes === void 0 ? void 0 : archivedPostTypes.filter(p => !(publicPostTypes === null || publicPostTypes === void 0 ? void 0 : publicPostTypes.includes(p)))) !== null && _a !== void 0 ? _a : 'post',
30
24
  ignoreStickyPosts: true,
31
25
  noFoundRows: true,
32
26
  noPaging: true,
33
27
  });
34
28
  const { ids: postIds } = await postLoader.findAndPrime({
35
29
  postStatus: 'publish',
36
- postType: archivedPostTypes ?? 'post',
30
+ postType: archivedPostTypes !== null && archivedPostTypes !== void 0 ? archivedPostTypes : 'post',
37
31
  ignoreStickyPosts: true,
38
32
  noFoundRows: true,
39
33
  noPaging: true,
40
34
  });
41
-
42
35
  const archivedPosts = await getPosts(archivedPostIds);
43
36
  const posts = await getPosts(postIds);
44
-
45
37
  const archivedPostsPaths = archivedPosts.map(post => splitPath(post.path));
46
-
47
- const archivedPostArchivePaths = (archivedPostTypes ?? []).map(type => [type]);
48
-
38
+ const archivedPostArchivePaths = (archivedPostTypes !== null && archivedPostTypes !== void 0 ? archivedPostTypes : []).map(type => [type]);
49
39
  const postPaths = posts.map(post => splitPath(post.path));
50
-
51
40
  const allPaths = [
52
41
  ...authorPaths,
53
42
  ...termPaths,
@@ -55,7 +44,6 @@ export async function nextpressStaticParams(): Promise<NextpressStaticParams> {
55
44
  ...archivedPostArchivePaths,
56
45
  ...postPaths
57
46
  ];
58
-
59
47
  return allPaths.map(segments => ({
60
48
  path: segments.filter(Boolean)
61
49
  }));
@@ -0,0 +1,23 @@
1
+ import "../globals/globals";
2
+ import { Metadata } from "next";
3
+ export type NextpressRouterProps = {
4
+ params: Promise<{
5
+ path: string[] | undefined;
6
+ }>;
7
+ };
8
+ /**
9
+ * Generates metadata dynamically for a given request path.
10
+ * Routes the path to the correct Nextpress routing function based on the configuration logic.
11
+ *
12
+ * @param {NextpressRouterProps} props - The dynamic properties for this page route.
13
+ * @returns {Promise<Metadata>} The Metadata object for the matched route.
14
+ */
15
+ export declare function generateNextpressMetadata({ params }: NextpressRouterProps): Promise<Metadata>;
16
+ /**
17
+ * The main catch-all Page component that renders the layout for matched routes.
18
+ * Routes the path to the correct Nextpress routing component to return a template.
19
+ *
20
+ * @param {NextpressRouterProps} props - The dynamic properties for this page route.
21
+ * @returns {Promise<JSX.Element>} The rendered React component mapping to the matched route's template.
22
+ */
23
+ export default function NextPressPage({ params }: NextpressRouterProps): Promise<import("react").JSX.Element>;
@@ -1,18 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import "../globals/globals";
2
- import { Metadata } from "next";
3
3
  import { AuthorArchive } from "./routes/author-archive";
4
4
  import { SingularPage } from "./routes/singular-page";
5
5
  import { SiteFrontPage } from "./routes/site-front-page";
6
6
  import { TermArchive } from "./routes/term-archive";
7
-
8
- export type NextpressRouterProps = {
9
- params: Promise<{
10
- path: string[] | undefined;
11
- }>;
12
- }
13
-
14
7
  const { publicTaxonomies } = nextpressConfig;
15
-
16
8
  /**
17
9
  * Generates metadata dynamically for a given request path.
18
10
  * Routes the path to the correct Nextpress routing function based on the configuration logic.
@@ -20,22 +12,22 @@ const { publicTaxonomies } = nextpressConfig;
20
12
  * @param {NextpressRouterProps} props - The dynamic properties for this page route.
21
13
  * @returns {Promise<Metadata>} The Metadata object for the matched route.
22
14
  */
23
- export async function generateNextpressMetadata({ params }: NextpressRouterProps): Promise<Metadata> {
24
- const path = (await params).path ?? [];
25
-
15
+ export async function generateNextpressMetadata({ params }) {
16
+ var _a;
17
+ const path = (_a = (await params).path) !== null && _a !== void 0 ? _a : [];
26
18
  if (!path.length) {
27
- return await SiteFrontPage({path, metadata: true});
19
+ return await SiteFrontPage({ path, metadata: true });
28
20
  }
29
- if (publicTaxonomies?.includes(path[0]!)) {
30
- return await TermArchive({path, metadata: true});
21
+ if (publicTaxonomies === null || publicTaxonomies === void 0 ? void 0 : publicTaxonomies.includes(path[0])) {
22
+ return await TermArchive({ path, metadata: true });
31
23
  }
32
24
  if (path[0] === 'author') {
33
- return await AuthorArchive({path, metadata: true});
34
- } else {
35
- return await SingularPage({path, metadata: true});
25
+ return await AuthorArchive({ path, metadata: true });
26
+ }
27
+ else {
28
+ return await SingularPage({ path, metadata: true });
36
29
  }
37
30
  }
38
-
39
31
  /**
40
32
  * The main catch-all Page component that renders the layout for matched routes.
41
33
  * Routes the path to the correct Nextpress routing component to return a template.
@@ -43,19 +35,19 @@ export async function generateNextpressMetadata({ params }: NextpressRouterProps
43
35
  * @param {NextpressRouterProps} props - The dynamic properties for this page route.
44
36
  * @returns {Promise<JSX.Element>} The rendered React component mapping to the matched route's template.
45
37
  */
46
- export default async function NextPressPage({ params }: NextpressRouterProps) {
47
- const path = (await params).path ?? [];
48
-
38
+ export default async function NextPressPage({ params }) {
39
+ var _a;
40
+ const path = (_a = (await params).path) !== null && _a !== void 0 ? _a : [];
49
41
  if (!path.length) {
50
- return <SiteFrontPage path={path}/>
42
+ return _jsx(SiteFrontPage, { path: path });
51
43
  }
52
- if (publicTaxonomies?.includes(path[0]!)) {
53
- return <TermArchive path={path}/>
44
+ if (publicTaxonomies === null || publicTaxonomies === void 0 ? void 0 : publicTaxonomies.includes(path[0])) {
45
+ return _jsx(TermArchive, { path: path });
54
46
  }
55
47
  if (path[0] === 'author') {
56
- return <AuthorArchive path={path}/>
57
- } else {
58
- return <SingularPage path={path}/>
48
+ return _jsx(AuthorArchive, { path: path });
49
+ }
50
+ else {
51
+ return _jsx(SingularPage, { path: path });
59
52
  }
60
53
  }
61
-
@@ -0,0 +1,8 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+ /**
3
+ * Processes GET requests to fetch WordPress admin bar data.
4
+ *
5
+ * @param {NextRequest} request - Incoming request.
6
+ * @returns {Promise<NextResponse>} Response containing admin bar data or error.
7
+ */
8
+ export declare function apiGetAdminBar(request: NextRequest): Promise<NextResponse>;