nextpress-core 1.1.0 → 2.0.0
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/cli/install.js +27 -0
- package/{dist/acf-functions/core/acf-builder.js → lib/acf-functions/core/acf-builder.ts} +45 -17
- package/{dist/acf-functions/core/acf-component-autoloader.js → lib/acf-functions/core/acf-component-autoloader.ts} +13 -7
- package/{dist/acf-functions/core/acf-field-group-autoloader.js → lib/acf-functions/core/acf-field-group-autoloader.ts} +11 -5
- package/{dist/acf-functions/services/define-field-group.d.ts → lib/acf-functions/services/define-field-group.ts} +4 -1
- package/{dist/acf-functions/services/define-layout.d.ts → lib/acf-functions/services/define-layout.ts} +4 -1
- package/lib/acf-functions/services/map-fields/helpers/map-choice-object.ts +20 -0
- package/{dist/acf-functions/services/map-fields/map-fields.js → lib/acf-functions/services/map-fields/map-fields.ts} +128 -89
- package/{dist/acf-functions/types/acf-field-group.d.ts → lib/acf-functions/types/acf-field-group.ts} +49 -28
- package/lib/acf-functions/types/acf-field.ts +2853 -0
- package/lib/acf-functions/types/acf-layout.ts +22 -0
- package/lib/acf-functions/types/components/field-props.ts +189 -0
- package/{dist/acf-functions/types/components/nextpress-component.d.ts → lib/acf-functions/types/components/nextpress-component.ts} +4 -3
- package/lib/ambient.d.ts +16 -0
- package/{dist/entities/common.d.ts → lib/entities/common.ts} +6 -4
- package/{dist/entities/option/option.interface.d.ts → lib/entities/option/option.interface.ts} +3 -3
- package/{dist/entities/option/option.js → lib/entities/option/option.ts} +21 -14
- package/{dist/entities/post/post.interface.d.ts → lib/entities/post/post.interface.ts} +26 -21
- package/lib/entities/post/post.ts +209 -0
- package/{dist/entities/term/term.interface.d.ts → lib/entities/term/term.interface.ts} +3 -3
- package/lib/entities/term/term.ts +82 -0
- package/{dist/entities/user/user.interface.d.ts → lib/entities/user/user.interface.ts} +2 -1
- package/lib/entities/user/user.ts +86 -0
- package/{dist/globals/entity-loader/entity-loader-base.js → lib/globals/entity-loader/entity-loader-base.ts} +64 -10
- package/{dist/globals/entity-loader/entity-loader.interface.d.ts → lib/globals/entity-loader/entity-loader.ts} +2 -4
- package/lib/globals/entity-loader/option-loader.ts +56 -0
- package/lib/globals/entity-loader/post-loader.ts +60 -0
- package/lib/globals/entity-loader/term-loader.ts +60 -0
- package/lib/globals/entity-loader/user-loader.ts +61 -0
- package/lib/globals/get-field/get-field.ts +76 -0
- package/{dist/globals/globals.js → lib/globals/globals.ts} +8 -3
- package/{dist/globals/nextpress-config/nextpress-config.interface.d.ts → lib/globals/nextpress-config/nextpress-config.interface.ts} +10 -6
- package/lib/globals/nextpress-config/nextpress-config.ts +8 -0
- package/lib/globals/queried-object/queried-object.ts +124 -0
- package/{dist/repository/optionquery/option-query-args.d.ts → lib/repository/optionquery/option-query-args.ts} +5 -2
- package/lib/repository/optionquery/option-query.ts +29 -0
- package/{dist/repository/postquery/post-query-args.d.ts → lib/repository/postquery/post-query-args.ts} +10 -6
- package/lib/repository/postquery/post-query.ts +282 -0
- package/{dist/repository/termquery/term-query-args.d.ts → lib/repository/termquery/term-query-args.ts} +16 -6
- package/lib/repository/termquery/term-query.ts +244 -0
- package/{dist/repository/userquery/user-query-args.d.ts → lib/repository/userquery/user-query-args.ts} +19 -7
- package/{dist/repository/userquery/user-query.js → lib/repository/userquery/user-query.ts} +93 -76
- package/{dist/router/helpers.js → lib/router/helpers.ts} +4 -4
- package/{dist/router/nextpress-layout.js → lib/router/nextpress-layout.tsx} +28 -9
- package/{dist/router/routes/not-found-page.js → lib/router/nextpress-not-found-route.tsx} +7 -5
- package/{dist/router/nextpress-proxy.js → lib/router/nextpress-proxy.ts} +15 -3
- package/{dist/router/nextpress-static-params.js → lib/router/nextpress-static-params.ts} +17 -5
- package/{dist/router/router.js → lib/router/router.tsx} +29 -22
- package/{dist/router/routes/api/api-get-admin-bar.js → lib/router/routes/api/api-get-admin-bar.ts} +8 -6
- package/{dist/router/routes/api/api-get-draft-mode.js → lib/router/routes/api/api-get-draft-mode.ts} +15 -6
- package/{dist/router/routes/api/api-get-field-groups.js → lib/router/routes/api/api-get-field-groups.ts} +13 -8
- package/{dist/router/routes/api/api-post-revalidate.js → lib/router/routes/api/api-post-revalidate.ts} +6 -4
- package/{dist/router/routes/api/helpers.js → lib/router/routes/api/helpers.ts} +4 -3
- package/lib/router/routes/author-archive.tsx +75 -0
- package/lib/router/routes/post-index-page.tsx +58 -0
- package/lib/router/routes/singular-page.tsx +78 -0
- package/lib/router/routes/site-front-page.tsx +51 -0
- package/lib/router/routes/term-archive.tsx +93 -0
- package/{dist/router/types.d.ts → lib/router/types.ts} +4 -2
- package/{dist/services/get-menu.js → lib/services/get-menu.ts} +56 -32
- package/{dist/services/get-theme-mods.js → lib/services/get-theme-mods.ts} +6 -4
- package/{dist/services/metadata/get-blogname.js → lib/services/metadata/get-blogname.ts} +2 -2
- package/{dist/services/metadata/get-favicon-url.js → lib/services/metadata/get-favicon-url.ts} +5 -4
- package/{dist/services/metadata/get-language-attribute.js → lib/services/metadata/get-language-attribute.ts} +1 -1
- package/{dist/services/utilities/capitalise-first-letter.js → lib/services/utilities/capitalise-first-letter.ts} +2 -3
- package/{dist/services/utilities/esc-html.js → lib/services/utilities/esc-html.ts} +3 -1
- package/{dist/services/utilities/get-date-time-formatter.js → lib/services/utilities/get-date-time-formatter.ts} +16 -6
- package/{dist/services/utilities/kses-post.js → lib/services/utilities/kses-post.ts} +2 -1
- package/{dist/services/utilities/process-url.js → lib/services/utilities/process-url.ts} +4 -3
- package/{dist/template-heirarchy/_autoloader/template-autoloader.js → lib/template-heirarchy/_autoloader/template-autoloader.ts} +18 -9
- package/{dist/template-heirarchy/archive/archive.js → lib/template-heirarchy/archive/archive.tsx} +10 -7
- package/{dist/template-heirarchy/archive/author.js → lib/template-heirarchy/archive/author.tsx} +10 -7
- package/{dist/template-heirarchy/archive/category.js → lib/template-heirarchy/archive/category.tsx} +11 -7
- package/{dist/template-heirarchy/archive/posttypearchive.js → lib/template-heirarchy/archive/posttypearchive.tsx} +11 -8
- package/{dist/template-heirarchy/archive/tag.js → lib/template-heirarchy/archive/tag.tsx} +12 -7
- package/{dist/template-heirarchy/archive/taxonomy.js → lib/template-heirarchy/archive/taxonomy.tsx} +10 -7
- package/{dist/template-heirarchy/home/home.js → lib/template-heirarchy/home/home.tsx} +10 -7
- package/{dist/template-heirarchy/index.js → lib/template-heirarchy/index.tsx} +9 -5
- package/{dist/template-heirarchy/not-found.tsx/not-found.js → lib/template-heirarchy/not-found.tsx/not-found.tsx} +10 -7
- package/{dist/template-heirarchy/page/page.js → lib/template-heirarchy/page/page.tsx} +10 -7
- package/{dist/template-heirarchy/page/posttype.js → lib/template-heirarchy/page/posttype.tsx} +12 -8
- package/{dist/template-heirarchy/page/single.js → lib/template-heirarchy/page/single.tsx} +10 -7
- package/{dist/template-heirarchy/page/singular.js → lib/template-heirarchy/page/singular.tsx} +10 -7
- package/lib/ui/render-attachment-image.tsx +28 -0
- package/lib/ui/render-components.tsx +12 -0
- package/lib/ui/render-the-admin-bar.tsx +79 -0
- package/lib/ui/render-the-logo.tsx +24 -0
- package/{dist/wpdb/wpdb.interface.d.ts → lib/wpdb/wpdb.interface.ts} +20 -1
- package/{dist/wpdb/wpdb.js → lib/wpdb/wpdb.ts} +9 -5
- package/package.json +8 -43
- package/dist/acf-functions/core/acf-builder.d.ts +0 -51
- package/dist/acf-functions/core/acf-component-autoloader.d.ts +0 -11
- package/dist/acf-functions/core/acf-field-group-autoloader.d.ts +0 -10
- package/dist/acf-functions/field-props.d.ts +0 -196
- package/dist/acf-functions/field-props.js +0 -1
- package/dist/acf-functions/index.d.ts +0 -13
- package/dist/acf-functions/index.js +0 -13
- package/dist/acf-functions/services/define-field-group.js +0 -10
- package/dist/acf-functions/services/define-layout.js +0 -10
- package/dist/acf-functions/services/map-fields/helpers/map-choice-object.d.ts +0 -2
- package/dist/acf-functions/services/map-fields/helpers/map-choice-object.js +0 -18
- package/dist/acf-functions/services/map-fields/map-fields.d.ts +0 -21
- package/dist/acf-functions/types/acf-field-group.js +0 -1
- package/dist/acf-functions/types/acf-field.d.ts +0 -2813
- package/dist/acf-functions/types/acf-field.js +0 -1
- package/dist/acf-functions/types/acf-layout.d.ts +0 -19
- package/dist/acf-functions/types/acf-layout.js +0 -1
- package/dist/acf-functions/types/acf-values.js +0 -1
- package/dist/acf-functions/types/components/field-props.d.ts +0 -196
- package/dist/acf-functions/types/components/field-props.js +0 -1
- package/dist/acf-functions/types/components/nextpress-component.js +0 -1
- package/dist/entities/common.js +0 -1
- package/dist/entities/index.d.ts +0 -9
- package/dist/entities/index.js +0 -9
- package/dist/entities/option/option.d.ts +0 -19
- package/dist/entities/option/option.interface.js +0 -2
- package/dist/entities/post/post.d.ts +0 -50
- package/dist/entities/post/post.interface.js +0 -2
- package/dist/entities/post/post.js +0 -184
- package/dist/entities/term/term.d.ts +0 -28
- package/dist/entities/term/term.interface.js +0 -1
- package/dist/entities/term/term.js +0 -67
- package/dist/entities/user/user.d.ts +0 -27
- package/dist/entities/user/user.interface.js +0 -1
- package/dist/entities/user/user.js +0 -74
- package/dist/globals/entity-loader/entity-loader-base.d.ts +0 -65
- package/dist/globals/entity-loader/entity-loader.interface.js +0 -1
- package/dist/globals/entity-loader/option-loader.d.ts +0 -15
- package/dist/globals/entity-loader/option-loader.js +0 -31
- package/dist/globals/entity-loader/post-loader.d.ts +0 -21
- package/dist/globals/entity-loader/post-loader.js +0 -28
- package/dist/globals/entity-loader/term-loader.d.ts +0 -21
- package/dist/globals/entity-loader/term-loader.js +0 -28
- package/dist/globals/entity-loader/user-loader.d.ts +0 -21
- package/dist/globals/entity-loader/user-loader.js +0 -28
- package/dist/globals/get-field/get-field.d.ts +0 -18
- package/dist/globals/get-field/get-field.js +0 -44
- package/dist/globals/globals.d.ts +0 -18
- package/dist/globals/index.d.ts +0 -10
- package/dist/globals/index.js +0 -10
- package/dist/globals/nextpress-config/nextpress-config.d.ts +0 -4
- package/dist/globals/nextpress-config/nextpress-config.interface.js +0 -1
- package/dist/globals/nextpress-config/nextpress-config.js +0 -2
- package/dist/globals/queried-object/queried-object.d.ts +0 -62
- package/dist/globals/queried-object/queried-object.js +0 -56
- package/dist/repository/index.d.ts +0 -5
- package/dist/repository/index.js +0 -5
- package/dist/repository/optionquery/option-query-args.js +0 -1
- package/dist/repository/optionquery/option-query.d.ts +0 -12
- package/dist/repository/optionquery/option-query.js +0 -20
- package/dist/repository/postquery/post-query-args.js +0 -1
- package/dist/repository/postquery/post-query.d.ts +0 -12
- package/dist/repository/postquery/post-query.js +0 -272
- package/dist/repository/termquery/term-query-args.js +0 -1
- package/dist/repository/termquery/term-query.d.ts +0 -11
- package/dist/repository/termquery/term-query.js +0 -213
- package/dist/repository/userquery/user-query-args.js +0 -1
- package/dist/repository/userquery/user-query.d.ts +0 -12
- package/dist/router/helpers.d.ts +0 -14
- package/dist/router/index.d.ts +0 -17
- package/dist/router/index.js +0 -17
- package/dist/router/nextpress-layout.d.ts +0 -11
- package/dist/router/nextpress-proxy.d.ts +0 -8
- package/dist/router/nextpress-static-params.d.ts +0 -9
- package/dist/router/router.d.ts +0 -23
- package/dist/router/routes/api/api-get-admin-bar.d.ts +0 -8
- package/dist/router/routes/api/api-get-draft-mode.d.ts +0 -8
- package/dist/router/routes/api/api-get-field-groups.d.ts +0 -7
- package/dist/router/routes/api/api-post-revalidate.d.ts +0 -7
- package/dist/router/routes/api/helpers.d.ts +0 -8
- package/dist/router/routes/author-archive.d.ts +0 -25
- package/dist/router/routes/author-archive.js +0 -49
- package/dist/router/routes/not-found-page.d.ts +0 -15
- package/dist/router/routes/post-index-page.d.ts +0 -25
- package/dist/router/routes/post-index-page.js +0 -33
- package/dist/router/routes/singular-page.d.ts +0 -29
- package/dist/router/routes/singular-page.js +0 -51
- package/dist/router/routes/site-front-page.d.ts +0 -27
- package/dist/router/routes/site-front-page.js +0 -26
- package/dist/router/routes/term-archive.d.ts +0 -29
- package/dist/router/routes/term-archive.js +0 -65
- package/dist/router/types.js +0 -1
- package/dist/services/get-menu.d.ts +0 -13
- package/dist/services/get-theme-mods.d.ts +0 -7
- package/dist/services/index.d.ts +0 -10
- package/dist/services/index.js +0 -10
- package/dist/services/metadata/get-blogname.d.ts +0 -6
- package/dist/services/metadata/get-favicon-url.d.ts +0 -6
- package/dist/services/metadata/get-language-attribute.d.ts +0 -6
- package/dist/services/services.d.ts +0 -3
- package/dist/services/services.js +0 -3
- package/dist/services/utilities/capitalise-first-letter.d.ts +0 -7
- package/dist/services/utilities/esc-html.d.ts +0 -7
- package/dist/services/utilities/get-date-time-formatter.d.ts +0 -6
- package/dist/services/utilities/index.d.ts +0 -0
- package/dist/services/utilities/index.js +0 -1
- package/dist/services/utilities/kses-post.d.ts +0 -7
- package/dist/services/utilities/process-url.d.ts +0 -7
- package/dist/template-heirarchy/_autoloader/template-autoloader.d.ts +0 -9
- package/dist/template-heirarchy/archive/archive.d.ts +0 -16
- package/dist/template-heirarchy/archive/author.d.ts +0 -16
- package/dist/template-heirarchy/archive/category.d.ts +0 -16
- package/dist/template-heirarchy/archive/posttypearchive.d.ts +0 -24
- package/dist/template-heirarchy/archive/tag.d.ts +0 -16
- package/dist/template-heirarchy/archive/taxonomy.d.ts +0 -16
- package/dist/template-heirarchy/home/home.d.ts +0 -16
- package/dist/template-heirarchy/index.d.ts +0 -17
- package/dist/template-heirarchy/not-found.tsx/not-found.d.ts +0 -16
- package/dist/template-heirarchy/page/page.d.ts +0 -16
- package/dist/template-heirarchy/page/posttype.d.ts +0 -24
- package/dist/template-heirarchy/page/single.d.ts +0 -16
- package/dist/template-heirarchy/page/singular.d.ts +0 -16
- package/dist/ui/index.d.ts +0 -4
- package/dist/ui/index.js +0 -4
- package/dist/ui/render-attachment-image.d.ts +0 -12
- package/dist/ui/render-attachment-image.js +0 -24
- package/dist/ui/render-components.d.ts +0 -9
- package/dist/ui/render-components.js +0 -7
- package/dist/ui/render-the-admin-bar.d.ts +0 -8
- package/dist/ui/render-the-admin-bar.js +0 -36
- package/dist/ui/render-the-logo.d.ts +0 -10
- package/dist/ui/render-the-logo.js +0 -16
- package/dist/wpdb/index.d.ts +0 -0
- package/dist/wpdb/index.js +0 -1
- package/dist/wpdb/wpdb.d.ts +0 -3
- package/dist/wpdb/wpdb.interface.js +0 -5
- /package/{dist/acf-functions/types/acf-values.d.ts → lib/acf-functions/types/acf-values.ts} +0 -0
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { sql } from "kysely";
|
|
2
|
-
import * as phpSerialize from "php-serialize";
|
|
3
|
-
import { wpdb } from "@/wpdb/wpdb";
|
|
4
|
-
/**
|
|
5
|
-
* Executes database queries to retrieve post IDs and counts based on provided arguments.
|
|
6
|
-
*/
|
|
7
|
-
export class PostQuery {
|
|
8
|
-
constructor(args) {
|
|
9
|
-
this.args = args;
|
|
10
|
-
}
|
|
11
|
-
getCount() {
|
|
12
|
-
return this.postCount;
|
|
13
|
-
}
|
|
14
|
-
async getIds() {
|
|
15
|
-
var _a, _b, _c;
|
|
16
|
-
let builder = wpdb;
|
|
17
|
-
if (this.args.postAncestryOf) {
|
|
18
|
-
builder = builder.withRecursive('decendent_tree', (qb) => qb.selectFrom('wpPosts')
|
|
19
|
-
.select(['wpPosts.ID', 'wpPosts.postName', 'wpPosts.postParent'])
|
|
20
|
-
.where('wpPosts.postName', '=', this.args.postAncestryOf)
|
|
21
|
-
.unionAll(qb.selectFrom('wpPosts as p')
|
|
22
|
-
.select(['p.ID', 'p.postName', 'p.postParent'])
|
|
23
|
-
.innerJoin('decendent_tree as d', 'p.postParent', 'd.ID')));
|
|
24
|
-
}
|
|
25
|
-
let query = builder.selectFrom('wpPosts');
|
|
26
|
-
if (this.args.postAncestryOf) {
|
|
27
|
-
query = query.where('wpPosts.postName', 'in', (qb) => qb.selectFrom('decendent_tree').select('postName'));
|
|
28
|
-
}
|
|
29
|
-
// --- ID Filters ---
|
|
30
|
-
if (this.args.postId)
|
|
31
|
-
query = query.where('wpPosts.ID', '=', this.args.postId);
|
|
32
|
-
if (this.args.postIn)
|
|
33
|
-
query = query.where('wpPosts.ID', 'in', this.args.postIn);
|
|
34
|
-
if (this.args.postNotIn)
|
|
35
|
-
query = query.where('wpPosts.ID', 'not in', this.args.postNotIn);
|
|
36
|
-
if (this.args.path) {
|
|
37
|
-
query = query.where((eb) => eb.exists(eb.selectFrom('wpPostmeta')
|
|
38
|
-
.select('postId')
|
|
39
|
-
.whereRef('postId', '=', 'wpPosts.ID')
|
|
40
|
-
.where('wpPostmeta.metaKey', '=', '_nextpress_path')
|
|
41
|
-
.where('wpPostmeta.metaValue', '=', this.args.path)));
|
|
42
|
-
}
|
|
43
|
-
// --- Type Filters ---
|
|
44
|
-
if (this.args.postType) {
|
|
45
|
-
const types = Array.isArray(this.args.postType) ? this.args.postType : [this.args.postType];
|
|
46
|
-
query = query.where('wpPosts.postType', 'in', types);
|
|
47
|
-
}
|
|
48
|
-
if (this.args.postTypeNot) {
|
|
49
|
-
const types = Array.isArray(this.args.postTypeNot) ? this.args.postTypeNot : [this.args.postTypeNot];
|
|
50
|
-
query = query.where('wpPosts.postType', 'not in', types);
|
|
51
|
-
}
|
|
52
|
-
// --- Status Filters ---
|
|
53
|
-
if (this.args.postStatus) {
|
|
54
|
-
const statuses = Array.isArray(this.args.postStatus) ? this.args.postStatus : [this.args.postStatus];
|
|
55
|
-
query = query.where('wpPosts.postStatus', 'in', statuses);
|
|
56
|
-
}
|
|
57
|
-
// --- Content Filters ---
|
|
58
|
-
if (this.args.postSlug) {
|
|
59
|
-
const postSlugs = Array.isArray(this.args.postSlug) ? this.args.postSlug : [this.args.postSlug];
|
|
60
|
-
query = query.where('wpPosts.postName', 'in', postSlugs);
|
|
61
|
-
}
|
|
62
|
-
if (this.args.title)
|
|
63
|
-
query = query.where('wpPosts.postTitle', '=', this.args.title);
|
|
64
|
-
if (this.args.postMimeType)
|
|
65
|
-
query = query.where('wpPosts.postMimeType', 'like', `%${this.args.postMimeType}%`);
|
|
66
|
-
// --- Parent Filters ---
|
|
67
|
-
if (this.args.postParent !== undefined)
|
|
68
|
-
query = query.where('wpPosts.postParent', '=', this.args.postParent);
|
|
69
|
-
if (this.args.postParentIn)
|
|
70
|
-
query = query.where('wpPosts.postParent', 'in', this.args.postParentIn);
|
|
71
|
-
if (this.args.postParentNotIn)
|
|
72
|
-
query = query.where('wpPosts.postParent', 'not in', this.args.postParentNotIn);
|
|
73
|
-
// --- Term Filters ---
|
|
74
|
-
if (this.args.termId) {
|
|
75
|
-
query = query.innerJoin('wpTermRelationships', 'wpPosts.ID', 'wpTermRelationships.objectId')
|
|
76
|
-
.where('wpTermRelationships.termTaxonomyId', '=', this.args.termId);
|
|
77
|
-
}
|
|
78
|
-
if (this.args.termAnd) {
|
|
79
|
-
query = query.innerJoin('wpTermRelationships', 'wpPosts.ID', 'wpTermRelationships.objectId')
|
|
80
|
-
.where('wpTermRelationships.termTaxonomyId', 'in', this.args.termAnd)
|
|
81
|
-
.groupBy('wpPosts.ID')
|
|
82
|
-
.having((eb) => eb.fn.count('wpTermRelationships.termTaxonomyId'), '=', this.args.termAnd.length);
|
|
83
|
-
}
|
|
84
|
-
if (this.args.termIn) {
|
|
85
|
-
query = query.innerJoin('wpTermRelationships', 'wpPosts.ID', 'wpTermRelationships.objectId')
|
|
86
|
-
.where('wpTermRelationships.termTaxonomyId', 'in', this.args.termIn);
|
|
87
|
-
}
|
|
88
|
-
if (this.args.termNotIn) {
|
|
89
|
-
query = query.where('wpPosts.ID', 'not in', (qb) => qb.selectFrom('wpTermRelationships')
|
|
90
|
-
.select('wpTermRelationships.objectId')
|
|
91
|
-
.where('wpTermRelationships.termTaxonomyId', 'in', this.args.termNotIn));
|
|
92
|
-
}
|
|
93
|
-
if (this.args.termSlug) {
|
|
94
|
-
query = query.innerJoin('wpTermRelationships', 'wpPosts.ID', 'wpTermRelationships.objectId')
|
|
95
|
-
.innerJoin('wpTerms', 'wpTermRelationships.termTaxonomyId', 'wpTerms.termId')
|
|
96
|
-
.where('wpTerms.slug', '=', this.args.termSlug)
|
|
97
|
-
.groupBy('wpPosts.ID');
|
|
98
|
-
}
|
|
99
|
-
if (this.args.termSlugAnd) {
|
|
100
|
-
query = query.innerJoin('wpTermRelationships', 'wpPosts.ID', 'wpTermRelationships.objectId')
|
|
101
|
-
.innerJoin('wpTerms', 'wpTermRelationships.termTaxonomyId', 'wpTerms.termId')
|
|
102
|
-
.where('wpTerms.slug', 'in', this.args.termSlugAnd)
|
|
103
|
-
.groupBy('wpPosts.ID')
|
|
104
|
-
.having((eb) => eb.fn.count('wpTermRelationships.termTaxonomyId'), '=', this.args.termSlugAnd.length);
|
|
105
|
-
}
|
|
106
|
-
if (this.args.termSlugIn) {
|
|
107
|
-
query = query.innerJoin('wpTermRelationships', 'wpPosts.ID', 'wpTermRelationships.objectId')
|
|
108
|
-
.innerJoin('wpTerms', 'wpTermRelationships.termTaxonomyId', 'wpTerms.termId')
|
|
109
|
-
.where('wpTerms.slug', 'in', this.args.termSlugIn)
|
|
110
|
-
.groupBy('wpPosts.ID');
|
|
111
|
-
}
|
|
112
|
-
// --- Author Filters ---
|
|
113
|
-
if (this.args.authorId)
|
|
114
|
-
query = query.where('wpPosts.postAuthor', '=', this.args.authorId);
|
|
115
|
-
if (this.args.authorIn)
|
|
116
|
-
query = query.where('wpPosts.postAuthor', 'in', this.args.authorIn);
|
|
117
|
-
if (this.args.authorNotIn)
|
|
118
|
-
query = query.where('wpPosts.postAuthor', 'not in', this.args.authorNotIn);
|
|
119
|
-
if (this.args.authorName) {
|
|
120
|
-
query = query.innerJoin('wpUsers', 'wpPosts.postAuthor', 'wpUsers.ID')
|
|
121
|
-
.where('wpUsers.displayName', '=', this.args.authorName);
|
|
122
|
-
}
|
|
123
|
-
// --- Search Filters ---
|
|
124
|
-
if (this.args.search) {
|
|
125
|
-
const searchTerm = this.args.exact ? this.args.search : `%${this.args.search}%`;
|
|
126
|
-
const searchCols = this.args.searchColumns || ['postTitle', 'postContent', 'postExcerpt'];
|
|
127
|
-
const isExact = this.args.exact;
|
|
128
|
-
query = query.where((eb) => {
|
|
129
|
-
const orClauses = searchCols.map(col => eb(col, isExact ? '=' : 'like', searchTerm));
|
|
130
|
-
return eb.or(orClauses);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
// --- Date Filters ---
|
|
134
|
-
if (this.args.yyyymm) {
|
|
135
|
-
const mStr = String(this.args.yyyymm);
|
|
136
|
-
const y = Number(mStr.substring(0, 4));
|
|
137
|
-
const mon = Number(mStr.substring(4, 6));
|
|
138
|
-
query = query.where((eb) => eb.fn('YEAR', [eb.ref('wpPosts.postDate')]), '=', y)
|
|
139
|
-
.where((eb) => eb.fn('MONTH', [eb.ref('wpPosts.postDate')]), '=', mon);
|
|
140
|
-
}
|
|
141
|
-
if (this.args.year)
|
|
142
|
-
query = query.where((eb) => eb.fn('YEAR', [eb.ref('wpPosts.postDate')]), '=', this.args.year);
|
|
143
|
-
if (this.args.monthnum)
|
|
144
|
-
query = query.where((eb) => eb.fn('MONTH', [eb.ref('wpPosts.postDate')]), '=', this.args.monthnum);
|
|
145
|
-
if (this.args.w)
|
|
146
|
-
query = query.where((eb) => eb.fn('WEEK', [eb.ref('wpPosts.postDate')]), '=', this.args.w);
|
|
147
|
-
if (this.args.day)
|
|
148
|
-
query = query.where((eb) => eb.fn('DAY', [eb.ref('wpPosts.postDate')]), '=', this.args.day);
|
|
149
|
-
if (this.args.hour !== undefined)
|
|
150
|
-
query = query.where((eb) => eb.fn('HOUR', [eb.ref('wpPosts.postDate')]), '=', this.args.hour);
|
|
151
|
-
if (this.args.minute !== undefined)
|
|
152
|
-
query = query.where((eb) => eb.fn('MINUTE', [eb.ref('wpPosts.postDate')]), '=', this.args.minute);
|
|
153
|
-
if (this.args.second !== undefined)
|
|
154
|
-
query = query.where((eb) => eb.fn('SECOND', [eb.ref('wpPosts.postDate')]), '=', this.args.second);
|
|
155
|
-
// -- Calculate Total Count (Before Limits/Offsets) --
|
|
156
|
-
if (!this.args.noFoundRows) {
|
|
157
|
-
try {
|
|
158
|
-
const countQueryBase = query.clearSelect().select('wpPosts.ID').distinct();
|
|
159
|
-
const countResult = await wpdb.selectFrom(countQueryBase.as('sub'))
|
|
160
|
-
.select(sql `count(*)`.as('count'))
|
|
161
|
-
.executeTakeFirst();
|
|
162
|
-
this.postCount = countResult ? Number(countResult.count) : undefined;
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
console.error('WPPostQuery: Cannot get row count: ', error.message);
|
|
166
|
-
this.postCount = undefined;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this.postCount = undefined;
|
|
171
|
-
}
|
|
172
|
-
// -- Apply ORDER BY --
|
|
173
|
-
if (!this.args.ignoreStickyPosts) {
|
|
174
|
-
const rawStickyPostIds = await getOption('sticky_posts');
|
|
175
|
-
let stickyPosts = [];
|
|
176
|
-
try {
|
|
177
|
-
const parsed = phpSerialize.unserialize(rawStickyPostIds !== null && rawStickyPostIds !== void 0 ? rawStickyPostIds : 'a:0:{}');
|
|
178
|
-
stickyPosts = Object.values(parsed);
|
|
179
|
-
}
|
|
180
|
-
catch (error) {
|
|
181
|
-
console.warn('WPPostQuery: Failed to parse sticky_posts option. Defaulting to empty.', error);
|
|
182
|
-
}
|
|
183
|
-
if (stickyPosts.length > 0) {
|
|
184
|
-
query = query.orderBy(sql `CASE WHEN wp_posts.ID IN (${sql.join(stickyPosts)}) THEN 0 ELSE 1 END`, 'asc');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const orderDirection = this.args.order === 'ASC' ? 'asc' : 'desc';
|
|
188
|
-
const orderBy = this.args.orderBy || 'none';
|
|
189
|
-
switch (orderBy) {
|
|
190
|
-
case 'none': break;
|
|
191
|
-
case 'id':
|
|
192
|
-
query = query.orderBy('wpPosts.ID', orderDirection);
|
|
193
|
-
break;
|
|
194
|
-
case 'author':
|
|
195
|
-
query = query.orderBy('wpPosts.postAuthor', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
196
|
-
break;
|
|
197
|
-
case 'title':
|
|
198
|
-
query = query.orderBy('wpPosts.postTitle', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
199
|
-
break;
|
|
200
|
-
case 'name':
|
|
201
|
-
query = query.orderBy('wpPosts.postName', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
202
|
-
break;
|
|
203
|
-
case 'date':
|
|
204
|
-
query = query.orderBy('wpPosts.postDate', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
205
|
-
break;
|
|
206
|
-
case 'modified':
|
|
207
|
-
query = query.orderBy('wpPosts.postModified', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
208
|
-
break;
|
|
209
|
-
case 'parent':
|
|
210
|
-
query = query.orderBy('wpPosts.postParent', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
211
|
-
break;
|
|
212
|
-
case 'menuOrder':
|
|
213
|
-
query = query.orderBy('wpPosts.menuOrder', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
214
|
-
break;
|
|
215
|
-
case 'commentCount':
|
|
216
|
-
query = query.orderBy('wpPosts.commentCount', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
217
|
-
break;
|
|
218
|
-
case 'rand':
|
|
219
|
-
query = query.orderBy((eb) => eb.fn('RAND', [])).orderBy('wpPosts.ID', orderDirection);
|
|
220
|
-
break;
|
|
221
|
-
default:
|
|
222
|
-
if (orderBy.startsWith('RAND(')) {
|
|
223
|
-
const seed = parseInt(orderBy.replace(/\D/g, ''), 10);
|
|
224
|
-
query = query.orderBy((eb) => eb.fn('RAND', [eb.val(seed)])).orderBy('wpPosts.ID', orderDirection);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
query = query.orderBy('wpPosts.postDate', orderDirection).orderBy('wpPosts.ID', orderDirection);
|
|
228
|
-
}
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
// -- Apply LIMIT & OFFSET --
|
|
232
|
-
if (!this.args.noPaging) {
|
|
233
|
-
const perPage = (_a = this.args.postsPerPage) !== null && _a !== void 0 ? _a : 10;
|
|
234
|
-
if (perPage > -1) {
|
|
235
|
-
query = query.limit(perPage);
|
|
236
|
-
const page = (_b = this.args.page) !== null && _b !== void 0 ? _b : 1;
|
|
237
|
-
const baseOffset = (_c = this.args.offset) !== null && _c !== void 0 ? _c : 0;
|
|
238
|
-
const offsetAmount = ((page - 1) * perPage) + baseOffset;
|
|
239
|
-
if (offsetAmount > 0) {
|
|
240
|
-
query = query.offset(offsetAmount);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (this.args.metaQuery) {
|
|
245
|
-
let dynamicQuery = query;
|
|
246
|
-
for (let metaQuery of this.args.metaQuery) {
|
|
247
|
-
const uniqueAlias = `meta_${metaQuery.as}`;
|
|
248
|
-
dynamicQuery = dynamicQuery.leftJoin(`wpPostmeta as ${uniqueAlias}`, (join) => join
|
|
249
|
-
.onRef(`${uniqueAlias}.postId`, '=', 'wpPosts.ID')
|
|
250
|
-
.on(`${uniqueAlias}.metaKey`, '=', metaQuery.metaKey))
|
|
251
|
-
.select(`${uniqueAlias}.metaValue as ${metaQuery.as}`);
|
|
252
|
-
}
|
|
253
|
-
query = dynamicQuery;
|
|
254
|
-
}
|
|
255
|
-
try {
|
|
256
|
-
if (this.args.multiple !== false) {
|
|
257
|
-
return (await query
|
|
258
|
-
.select('wpPosts.ID as id')
|
|
259
|
-
.groupBy('wpPosts.ID')
|
|
260
|
-
.execute()).map(res => res.id);
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
return (await query
|
|
264
|
-
.select('wpPosts.ID as id')
|
|
265
|
-
.execute()).map(res => res.id);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
catch (error) {
|
|
269
|
-
throw new Error(`WPPostQuery: Cannot get posts: ${error.message}`, { cause: error });
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EntityQuery } from "../../globals/entity-loader/entity-loader.interface";
|
|
2
|
-
import { ITerm } from "../../entities/term/term.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Executes database queries to retrieve term IDs based on provided arguments.
|
|
5
|
-
*/
|
|
6
|
-
export declare class TermQuery implements EntityQuery<ITerm> {
|
|
7
|
-
private args;
|
|
8
|
-
constructor(args: TermQueryArgs);
|
|
9
|
-
getCount(): undefined;
|
|
10
|
-
getIds(): Promise<number[]>;
|
|
11
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { wpdb } from "@/wpdb/wpdb";
|
|
2
|
-
/**
|
|
3
|
-
* Executes database queries to retrieve term IDs based on provided arguments.
|
|
4
|
-
*/
|
|
5
|
-
export class TermQuery {
|
|
6
|
-
constructor(args) {
|
|
7
|
-
this.args = args;
|
|
8
|
-
}
|
|
9
|
-
getCount() {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
async getIds() {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
let builder = wpdb;
|
|
15
|
-
const isMultiple = this.args.multiple !== false;
|
|
16
|
-
// -- Build CTEs --
|
|
17
|
-
if (this.args.termId) {
|
|
18
|
-
const termIds = Array.isArray(this.args.termId) ? this.args.termId : [this.args.termId];
|
|
19
|
-
const baseQuery = (qb) => qb.selectFrom('wpTermTaxonomy')
|
|
20
|
-
.select(['termId', 'parent'])
|
|
21
|
-
.where((eb) => eb.or([
|
|
22
|
-
eb('termId', 'in', termIds),
|
|
23
|
-
eb('parent', 'in', termIds)
|
|
24
|
-
]));
|
|
25
|
-
if (isMultiple) {
|
|
26
|
-
builder = builder.withRecursive('included_branch_id', (qb) => baseQuery(qb).unionAll(qb.selectFrom('wpTermTaxonomy as t')
|
|
27
|
-
.select(['t.termId', 't.parent'])
|
|
28
|
-
.innerJoin('included_branch_id as f', 'f.termId', 't.parent')));
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
builder = builder.with('included_branch_id', baseQuery);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (this.args.termIdNot) {
|
|
35
|
-
const termIds = Array.isArray(this.args.termIdNot) ? this.args.termIdNot : [this.args.termIdNot];
|
|
36
|
-
const baseQuery = (qb) => qb.selectFrom('wpTermTaxonomy')
|
|
37
|
-
.select(['termId', 'parent'])
|
|
38
|
-
.where((eb) => eb.or([
|
|
39
|
-
eb('termId', 'in', termIds),
|
|
40
|
-
eb('parent', 'in', termIds)
|
|
41
|
-
]));
|
|
42
|
-
if (isMultiple) {
|
|
43
|
-
builder = builder.withRecursive('excluded_branch_id', (qb) => baseQuery(qb).unionAll(qb.selectFrom('wpTermTaxonomy as t')
|
|
44
|
-
.select(['t.termId', 't.parent'])
|
|
45
|
-
.innerJoin('excluded_branch_id as f', 'f.termId', 't.parent')));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
builder = builder.with('excluded_branch_id', baseQuery);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (this.args.termName) {
|
|
52
|
-
const names = Array.isArray(this.args.termName) ? this.args.termName : [this.args.termName];
|
|
53
|
-
const baseQuery = (qb) => qb.selectFrom('wpTermTaxonomy')
|
|
54
|
-
.innerJoin('wpTerms', 'wpTerms.termId', 'wpTermTaxonomy.termId')
|
|
55
|
-
.select(['wpTermTaxonomy.termId', 'wpTermTaxonomy.parent'])
|
|
56
|
-
.where('wpTerms.name', 'in', names);
|
|
57
|
-
if (isMultiple) {
|
|
58
|
-
builder = builder.withRecursive('included_branch_name', (qb) => baseQuery(qb).unionAll(qb.selectFrom('wpTermTaxonomy as t')
|
|
59
|
-
.select(['t.termId', 't.parent'])
|
|
60
|
-
.innerJoin('included_branch_name as f', 'f.termId', 't.parent')));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
builder = builder.with('included_branch_name', baseQuery);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (this.args.termSlug) {
|
|
67
|
-
const slugs = Array.isArray(this.args.termSlug) ? this.args.termSlug : [this.args.termSlug];
|
|
68
|
-
const baseQuery = (qb) => qb.selectFrom('wpTermTaxonomy')
|
|
69
|
-
.innerJoin('wpTerms', 'wpTerms.termId', 'wpTermTaxonomy.termId')
|
|
70
|
-
.select(['wpTermTaxonomy.termId', 'wpTermTaxonomy.parent'])
|
|
71
|
-
.where('wpTerms.slug', 'in', slugs);
|
|
72
|
-
if (isMultiple) {
|
|
73
|
-
builder = builder.withRecursive('included_branch_slug', (qb) => baseQuery(qb).unionAll(qb.selectFrom('wpTermTaxonomy as t')
|
|
74
|
-
.select(['t.termId', 't.parent'])
|
|
75
|
-
.innerJoin('included_branch_slug as f', 'f.termId', 't.parent')));
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
builder = builder.with('included_branch_slug', baseQuery);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (this.args.termSlugNot) {
|
|
82
|
-
const slugs = Array.isArray(this.args.termSlugNot) ? this.args.termSlugNot : [this.args.termSlugNot];
|
|
83
|
-
const baseQuery = (qb) => qb.selectFrom('wpTermTaxonomy')
|
|
84
|
-
.innerJoin('wpTerms', 'wpTerms.termId', 'wpTermTaxonomy.termId')
|
|
85
|
-
.select(['wpTermTaxonomy.termId', 'wpTermTaxonomy.parent'])
|
|
86
|
-
.where('wpTerms.slug', 'in', slugs);
|
|
87
|
-
if (isMultiple) {
|
|
88
|
-
builder = builder.withRecursive('excluded_branch_slug', (qb) => baseQuery(qb).unionAll(qb.selectFrom('wpTermTaxonomy as t')
|
|
89
|
-
.select(['t.termId', 't.parent'])
|
|
90
|
-
.innerJoin('excluded_branch_slug as f', 'f.termId', 't.parent')));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
builder = builder.with('excluded_branch_slug', baseQuery);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// -- Begin Main SELECT Statement --
|
|
97
|
-
let query = builder.selectFrom('wpTerms')
|
|
98
|
-
.innerJoin('wpTermTaxonomy', 'wpTerms.termId', 'wpTermTaxonomy.termId');
|
|
99
|
-
// -- Apply Filters (WHERE clauses) --
|
|
100
|
-
if (this.args.taxonomy) {
|
|
101
|
-
const taxonomies = Array.isArray(this.args.taxonomy) ? this.args.taxonomy : [this.args.taxonomy];
|
|
102
|
-
query = query.where('wpTermTaxonomy.taxonomy', 'in', taxonomies);
|
|
103
|
-
}
|
|
104
|
-
if (this.args.taxonomyId) {
|
|
105
|
-
const ids = Array.isArray(this.args.taxonomyId) ? this.args.taxonomyId : [this.args.taxonomyId];
|
|
106
|
-
query = query.where('wpTermTaxonomy.termTaxonomyId', 'in', ids);
|
|
107
|
-
}
|
|
108
|
-
if (this.args.termId)
|
|
109
|
-
query = query.where('wpTerms.termId', 'in', (qb) => qb.selectFrom('included_branch_id').select('termId'));
|
|
110
|
-
if (this.args.termIdNot)
|
|
111
|
-
query = query.where('wpTerms.termId', 'not in', (qb) => qb.selectFrom('excluded_branch_id').select('termId'));
|
|
112
|
-
if (this.args.termName)
|
|
113
|
-
query = query.where('wpTerms.termId', 'in', (qb) => qb.selectFrom('included_branch_name').select('termId'));
|
|
114
|
-
if (this.args.termSlug)
|
|
115
|
-
query = query.where('wpTerms.termId', 'in', (qb) => qb.selectFrom('included_branch_slug').select('termId'));
|
|
116
|
-
if (this.args.termSlugNot)
|
|
117
|
-
query = query.where('wpTerms.termId', 'not in', (qb) => qb.selectFrom('excluded_branch_slug').select('termId'));
|
|
118
|
-
if (this.args.hideEmpty !== false)
|
|
119
|
-
query = query.where('wpTermTaxonomy.count', '>', 0);
|
|
120
|
-
if (this.args.parent !== undefined) {
|
|
121
|
-
query = query.where('wpTermTaxonomy.parent', '=', this.args.parent);
|
|
122
|
-
}
|
|
123
|
-
if (this.args.childless) {
|
|
124
|
-
query = query.where('wpTerms.termId', 'not in', (qb) => qb.selectFrom('wpTermTaxonomy').select('wpTermTaxonomy.parent').where('wpTermTaxonomy.parent', '>', 0));
|
|
125
|
-
}
|
|
126
|
-
if (this.args.search) {
|
|
127
|
-
const searchStr = `%${this.args.search}%`;
|
|
128
|
-
query = query.where((eb) => eb.or([
|
|
129
|
-
eb('wpTerms.name', 'like', searchStr),
|
|
130
|
-
eb('wpTerms.slug', 'like', searchStr)
|
|
131
|
-
]));
|
|
132
|
-
}
|
|
133
|
-
if (this.args.nameLike) {
|
|
134
|
-
query = query.where('wpTerms.name', 'like', this.args.nameLike);
|
|
135
|
-
}
|
|
136
|
-
if (this.args.descriptionLike) {
|
|
137
|
-
query = query.where('wpTermTaxonomy.description', 'like', this.args.descriptionLike);
|
|
138
|
-
}
|
|
139
|
-
if (this.args.path) {
|
|
140
|
-
query = query.where((eb) => eb.exists(eb.selectFrom('wpTermmeta')
|
|
141
|
-
.select('wpTerms.termId')
|
|
142
|
-
.whereRef('wpTermmeta.termId', '=', 'wpTerms.termId')
|
|
143
|
-
.where('wpTermmeta.metaKey', '=', '_nextpress_path')
|
|
144
|
-
.where('wpTermmeta.metaValue', '=', this.args.path)));
|
|
145
|
-
}
|
|
146
|
-
// -- Apply ORDER BY --
|
|
147
|
-
const orderDirection = this.args.order === 'DESC' ? 'desc' : 'asc';
|
|
148
|
-
const orderBy = this.args.orderBy || 'none';
|
|
149
|
-
switch (orderBy) {
|
|
150
|
-
case 'none': break;
|
|
151
|
-
case 'term_id':
|
|
152
|
-
query = query.orderBy('wpTerms.termId', orderDirection);
|
|
153
|
-
break;
|
|
154
|
-
case 'name':
|
|
155
|
-
query = query.orderBy('wpTerms.name', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
156
|
-
break;
|
|
157
|
-
case 'slug':
|
|
158
|
-
query = query.orderBy('wpTerms.slug', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
159
|
-
break;
|
|
160
|
-
case 'term_group':
|
|
161
|
-
query = query.orderBy('wpTerms.termGroup', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
162
|
-
break;
|
|
163
|
-
case 'description':
|
|
164
|
-
query = query.orderBy('wpTermTaxonomy.description', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
165
|
-
break;
|
|
166
|
-
case 'parent':
|
|
167
|
-
query = query.orderBy('wpTermTaxonomy.parent', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
168
|
-
break;
|
|
169
|
-
case 'count':
|
|
170
|
-
query = query.orderBy('wpTermTaxonomy.count', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
171
|
-
break;
|
|
172
|
-
default:
|
|
173
|
-
query = query.orderBy('wpTerms.name', orderDirection).orderBy('wpTerms.termId', orderDirection);
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
// -- Apply LIMIT & OFFSET --
|
|
177
|
-
const limit = (_a = this.args.number) !== null && _a !== void 0 ? _a : 0;
|
|
178
|
-
if (limit > 0) {
|
|
179
|
-
query = query.limit(limit);
|
|
180
|
-
}
|
|
181
|
-
const offsetAmount = (_b = this.args.offset) !== null && _b !== void 0 ? _b : 0;
|
|
182
|
-
if (offsetAmount > 0) {
|
|
183
|
-
query = query.offset(offsetAmount);
|
|
184
|
-
}
|
|
185
|
-
if (this.args.metaQuery) {
|
|
186
|
-
let dynamicQuery = query;
|
|
187
|
-
for (let metaQuery of this.args.metaQuery) {
|
|
188
|
-
const uniqueAlias = `meta_${metaQuery.as}`;
|
|
189
|
-
dynamicQuery = dynamicQuery.leftJoin(`wpTermmeta as ${uniqueAlias}`, (join) => join
|
|
190
|
-
.onRef(`${uniqueAlias}.termId`, '=', 'wpTerms.termId')
|
|
191
|
-
.on(`${uniqueAlias}.metaKey`, '=', metaQuery.metaKey))
|
|
192
|
-
.select(`${uniqueAlias}.metaValue as ${metaQuery.as}`);
|
|
193
|
-
}
|
|
194
|
-
query = dynamicQuery;
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
if (isMultiple) {
|
|
198
|
-
return (await query
|
|
199
|
-
.select('wpTerms.termId')
|
|
200
|
-
.groupBy('wpTerms.termId')
|
|
201
|
-
.execute()).map((res) => res.termId);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
return (await query
|
|
205
|
-
.select('wpTerms.termId')
|
|
206
|
-
.execute()).map((res) => res.termId);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
throw new Error(`WPTermQuery: Cannot get terms: ${error.message}`, { cause: error });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IUser } from "../../entities/user/user.interface";
|
|
2
|
-
import { EntityQuery } from "../../globals/entity-loader/entity-loader.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Executes database queries to retrieve user IDs and counts based on provided arguments.
|
|
5
|
-
*/
|
|
6
|
-
export declare class UserQuery implements EntityQuery<IUser> {
|
|
7
|
-
private args;
|
|
8
|
-
private userCount?;
|
|
9
|
-
constructor(args: UserQueryArgs);
|
|
10
|
-
getCount(): number | undefined;
|
|
11
|
-
getIds(): Promise<number[]>;
|
|
12
|
-
}
|
package/dist/router/helpers.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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[];
|
package/dist/router/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './nextpress-proxy';
|
|
3
|
-
export * from './nextpress-layout';
|
|
4
|
-
export * from './nextpress-static-params';
|
|
5
|
-
export * from './router';
|
|
6
|
-
export * from './helpers';
|
|
7
|
-
export * from './routes/post-index-page';
|
|
8
|
-
export * from './routes/site-front-page';
|
|
9
|
-
export * from './routes/author-archive';
|
|
10
|
-
export * from './routes/singular-page';
|
|
11
|
-
export * from './routes/term-archive';
|
|
12
|
-
export * from './routes/not-found-page';
|
|
13
|
-
export * from './routes/api/api-get-draft-mode';
|
|
14
|
-
export * from './routes/api/api-post-revalidate';
|
|
15
|
-
export * from './routes/api/api-get-field-groups';
|
|
16
|
-
export * from './routes/api/api-get-admin-bar';
|
|
17
|
-
export * from './routes/api/helpers';
|
package/dist/router/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './nextpress-proxy';
|
|
3
|
-
export * from './nextpress-layout';
|
|
4
|
-
export * from './nextpress-static-params';
|
|
5
|
-
export * from './router';
|
|
6
|
-
export * from './helpers';
|
|
7
|
-
export * from './routes/post-index-page';
|
|
8
|
-
export * from './routes/site-front-page';
|
|
9
|
-
export * from './routes/author-archive';
|
|
10
|
-
export * from './routes/singular-page';
|
|
11
|
-
export * from './routes/term-archive';
|
|
12
|
-
export * from './routes/not-found-page';
|
|
13
|
-
export * from './routes/api/api-get-draft-mode';
|
|
14
|
-
export * from './routes/api/api-post-revalidate';
|
|
15
|
-
export * from './routes/api/api-get-field-groups';
|
|
16
|
-
export * from './routes/api/api-get-admin-bar';
|
|
17
|
-
export * from './routes/api/helpers';
|
|
@@ -1,11 +0,0 @@
|
|
|
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,8 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
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>;
|
package/dist/router/router.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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 declare function NextPressPage({ params }: NextpressRouterProps): Promise<import("react").JSX.Element>;
|
|
@@ -1,8 +0,0 @@
|
|
|
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>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { NextRequest } from "next/server";
|
|
2
|
-
/**
|
|
3
|
-
* Processes GET requests to validate WordPress session and enable draft mode.
|
|
4
|
-
*
|
|
5
|
-
* @param {NextRequest} request - Incoming request.
|
|
6
|
-
* @returns {Promise<never>} Redirects to target URL.
|
|
7
|
-
*/
|
|
8
|
-
export declare function apiGetDraftMode(request: NextRequest): Promise<never>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NextResponse } from "next/server";
|
|
2
|
-
/**
|
|
3
|
-
* Processes GET requests to retrieve built ACF field groups.
|
|
4
|
-
*
|
|
5
|
-
* @returns {Promise<NextResponse>} Response containing field groups or error.
|
|
6
|
-
*/
|
|
7
|
-
export declare function apiGetFieldGroups(): Promise<NextResponse>;
|