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,74 +0,0 @@
|
|
|
1
|
-
import { unserialize } from "php-serialize";
|
|
2
|
-
import { wpdb } from "@/wpdb/wpdb";
|
|
3
|
-
export class User {
|
|
4
|
-
constructor(ID) {
|
|
5
|
-
this.ID = ID;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves array of User instances by IDs.
|
|
9
|
-
*
|
|
10
|
-
* @param {number[]} ids - Array of user IDs to retrieve.
|
|
11
|
-
* @returns {Promise<User[]>} Promise resolving to array of User instances.
|
|
12
|
-
*/
|
|
13
|
-
static async get(ids) {
|
|
14
|
-
var _a;
|
|
15
|
-
ids = ids.filter(Boolean);
|
|
16
|
-
if (!ids || !ids.length)
|
|
17
|
-
return [];
|
|
18
|
-
const usersData = await wpdb
|
|
19
|
-
.selectFrom('wpUsers')
|
|
20
|
-
.where('ID', 'in', ids)
|
|
21
|
-
.selectAll()
|
|
22
|
-
.execute();
|
|
23
|
-
const metaData = await wpdb
|
|
24
|
-
.selectFrom('wpUsermeta')
|
|
25
|
-
.where('userId', 'in', ids)
|
|
26
|
-
.where('metaKey', 'in', [
|
|
27
|
-
'wp_capabilities',
|
|
28
|
-
'show_admin_bar_front'
|
|
29
|
-
])
|
|
30
|
-
.select(['userId', 'metaKey', 'metaValue'])
|
|
31
|
-
.execute();
|
|
32
|
-
const metaByUserId = new Map();
|
|
33
|
-
for (const row of metaData) {
|
|
34
|
-
const userId = Number(row.userId);
|
|
35
|
-
if (!metaByUserId.has(userId)) {
|
|
36
|
-
metaByUserId.set(userId, new Map());
|
|
37
|
-
}
|
|
38
|
-
(_a = metaByUserId.get(userId)) === null || _a === void 0 ? void 0 : _a.set(row.metaKey || '', row.metaValue || '');
|
|
39
|
-
}
|
|
40
|
-
const userDataMap = new Map(usersData.map(user => [Number(user.ID), user]));
|
|
41
|
-
return ids.map(id => {
|
|
42
|
-
const instance = new User(id);
|
|
43
|
-
instance.userData = userDataMap.get(id);
|
|
44
|
-
instance.metaMap = metaByUserId.get(id) || new Map();
|
|
45
|
-
return instance;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
get roles() {
|
|
49
|
-
var _a;
|
|
50
|
-
const rawCapabilities = (_a = this.metaMap) === null || _a === void 0 ? void 0 : _a.get('wp_capabilities');
|
|
51
|
-
if (!rawCapabilities)
|
|
52
|
-
return [];
|
|
53
|
-
try {
|
|
54
|
-
return Object.keys(unserialize(rawCapabilities));
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
console.warn('Error while getting user: Could not unserialize php: ', error.message);
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
get showAdminBar() {
|
|
62
|
-
var _a;
|
|
63
|
-
return ((_a = this.metaMap) === null || _a === void 0 ? void 0 : _a.get('show_admin_bar_front')) === 'true';
|
|
64
|
-
}
|
|
65
|
-
get displayName() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['displayName']) !== null && _b !== void 0 ? _b : ''; }
|
|
66
|
-
get userActivationKey() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userActivationKey']) !== null && _b !== void 0 ? _b : ''; }
|
|
67
|
-
get userEmail() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userEmail']) !== null && _b !== void 0 ? _b : ''; }
|
|
68
|
-
get userLogin() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userLogin']) !== null && _b !== void 0 ? _b : ''; }
|
|
69
|
-
get userNicename() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userNicename']) !== null && _b !== void 0 ? _b : ''; }
|
|
70
|
-
get userPass() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userPass']) !== null && _b !== void 0 ? _b : ''; }
|
|
71
|
-
get userRegistered() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userRegistered']) !== null && _b !== void 0 ? _b : new Date(); }
|
|
72
|
-
get userStatus() { var _a; return ((_a = this.userData) === null || _a === void 0 ? void 0 : _a['userStatus']) ? Number(this.userData['userStatus']) : 0; }
|
|
73
|
-
get userUrl() { var _a, _b; return (_b = (_a = this.userData) === null || _a === void 0 ? void 0 : _a['userUrl']) !== null && _b !== void 0 ? _b : ''; }
|
|
74
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { EntityLoader, EntityQuery } from "./entity-loader.interface";
|
|
2
|
-
/**
|
|
3
|
-
* Constructor type for entity queries.
|
|
4
|
-
*/
|
|
5
|
-
type QueryConstructor<TArgs> = new (args: TArgs) => EntityQuery<TArgs>;
|
|
6
|
-
export interface ILoaderStorage<TEntity> {
|
|
7
|
-
loadQueue: Set<number>;
|
|
8
|
-
entityCache: Map<number, TEntity>;
|
|
9
|
-
promisedEntities: Map<number, Promise<TEntity[]>>;
|
|
10
|
-
}
|
|
11
|
-
export declare abstract class EntityLoaderBase<TEntity, TArgs> implements EntityLoader<TEntity, TArgs> {
|
|
12
|
-
/** Query class used to fetch entity IDs. */
|
|
13
|
-
protected abstract queryClass: QueryConstructor<TArgs>;
|
|
14
|
-
/**
|
|
15
|
-
* Fetches entities from the database by ID.
|
|
16
|
-
*
|
|
17
|
-
* @param {number[]} ids Array of entity IDs.
|
|
18
|
-
*
|
|
19
|
-
* @returns {Promise<TEntity[]>} Array of fetched entities.
|
|
20
|
-
* @throws {Error} If database fetch fails.
|
|
21
|
-
*/
|
|
22
|
-
protected abstract fetchFromDatabase(ids: number[]): Promise<TEntity[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Gets the ID of an entity.
|
|
25
|
-
*
|
|
26
|
-
* @param {TEntity} entity The entity.
|
|
27
|
-
*
|
|
28
|
-
* @returns {number} The entity ID.
|
|
29
|
-
*/
|
|
30
|
-
protected abstract getEntityId(entity: TEntity): number;
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves the local state for the loader from the global cache.
|
|
33
|
-
*
|
|
34
|
-
* @returns {ILoaderStorage<TEntity>} The loader storage.
|
|
35
|
-
*/
|
|
36
|
-
private getLocalState;
|
|
37
|
-
/**
|
|
38
|
-
* Adds IDs to the loading queue.
|
|
39
|
-
*
|
|
40
|
-
* @param {number[]} ids Array of IDs to prime.
|
|
41
|
-
*/
|
|
42
|
-
prime(ids: number[]): void;
|
|
43
|
-
/**
|
|
44
|
-
* Finds entity IDs matching the arguments and queues them for loading.
|
|
45
|
-
*
|
|
46
|
-
* @param {TArgs} args Query arguments.
|
|
47
|
-
*
|
|
48
|
-
* @returns {Promise<{ ids: number[]; count: number }>} Matching IDs and total count.
|
|
49
|
-
* @throws {Error} If query execution fails.
|
|
50
|
-
*/
|
|
51
|
-
findAndPrime(args: TArgs): Promise<{
|
|
52
|
-
ids: number[];
|
|
53
|
-
count: number;
|
|
54
|
-
}>;
|
|
55
|
-
/**
|
|
56
|
-
* Retrieves entities by ID.
|
|
57
|
-
*
|
|
58
|
-
* @param {number[]} ids Array of entity IDs.
|
|
59
|
-
*
|
|
60
|
-
* @returns {Promise<TEntity[]>} Array of entities.
|
|
61
|
-
* @throws {Error} If entity fetching fails.
|
|
62
|
-
*/
|
|
63
|
-
get(ids: number[]): Promise<TEntity[]>;
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { IOption } from "../../entities/option/option.interface";
|
|
2
|
-
import { OptionQueryArgs } from "../../repository/optionquery/option-query-args";
|
|
3
|
-
import { EntityLoader } from "./entity-loader.interface";
|
|
4
|
-
declare global {
|
|
5
|
-
/** Global instance of the OptionLoader. */
|
|
6
|
-
var optionLoader: EntityLoader<IOption, OptionQueryArgs>;
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves an option value by name.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} name The option name.
|
|
11
|
-
*
|
|
12
|
-
* @returns {Promise<string | undefined>} The option value or undefined.
|
|
13
|
-
*/
|
|
14
|
-
var getOption: (name: string) => Promise<string | undefined>;
|
|
15
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { OptionQuery } from "@/repository/optionquery/option-query";
|
|
2
|
-
import { Option } from "../../entities/option/option";
|
|
3
|
-
import { EntityLoaderBase } from "./entity-loader-base";
|
|
4
|
-
class OptionLoader extends EntityLoaderBase {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.queryClass = OptionQuery;
|
|
8
|
-
}
|
|
9
|
-
static instance() {
|
|
10
|
-
if (!this._instance) {
|
|
11
|
-
this._instance = new OptionLoader();
|
|
12
|
-
}
|
|
13
|
-
return this._instance;
|
|
14
|
-
}
|
|
15
|
-
async fetchFromDatabase(ids) {
|
|
16
|
-
return await Option.get(ids);
|
|
17
|
-
}
|
|
18
|
-
getEntityId(option) {
|
|
19
|
-
return option.optionId;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
globalThis.optionLoader = OptionLoader.instance();
|
|
23
|
-
globalThis.getOption = async (name) => {
|
|
24
|
-
var _a;
|
|
25
|
-
const foundOptions = await optionLoader.findAndPrime({
|
|
26
|
-
column: 'optionName',
|
|
27
|
-
operand: '=',
|
|
28
|
-
value: name
|
|
29
|
-
});
|
|
30
|
-
return (_a = (await optionLoader.get(foundOptions.ids))[0]) === null || _a === void 0 ? void 0 : _a.optionValue;
|
|
31
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { IPost } from "../../entities/post/post.interface";
|
|
2
|
-
import { EntityLoader } from "./entity-loader.interface";
|
|
3
|
-
declare global {
|
|
4
|
-
/** Global instance of the PostLoader. */
|
|
5
|
-
var postLoader: EntityLoader<IPost, PostQueryArgs>;
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves posts by their IDs.
|
|
8
|
-
*
|
|
9
|
-
* @param {number[]} ids Array of post IDs.
|
|
10
|
-
* @returns {Promise<IPost[]>} Array of posts.
|
|
11
|
-
*/
|
|
12
|
-
var getPosts: (ids: number[]) => Promise<IPost[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves a single post by ID.
|
|
15
|
-
*
|
|
16
|
-
* @param {number} id The post ID.
|
|
17
|
-
* @returns {Promise<IPost | undefined>} The post or undefined.
|
|
18
|
-
*/
|
|
19
|
-
var getPost: (id: number) => Promise<IPost | undefined>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Post } from "@/entities/post/post";
|
|
2
|
-
import { EntityLoaderBase } from "./entity-loader-base";
|
|
3
|
-
import { PostQuery } from "@/repository/postquery/post-query";
|
|
4
|
-
class PostLoader extends EntityLoaderBase {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.queryClass = PostQuery;
|
|
8
|
-
}
|
|
9
|
-
static instance() {
|
|
10
|
-
if (!this._instance) {
|
|
11
|
-
this._instance = new PostLoader();
|
|
12
|
-
}
|
|
13
|
-
return this._instance;
|
|
14
|
-
}
|
|
15
|
-
async fetchFromDatabase(ids) {
|
|
16
|
-
return await Post.get(ids);
|
|
17
|
-
}
|
|
18
|
-
getEntityId(post) {
|
|
19
|
-
return post.ID;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
globalThis.postLoader = PostLoader.instance();
|
|
23
|
-
globalThis.getPosts = async (ids) => {
|
|
24
|
-
return await postLoader.get(ids);
|
|
25
|
-
};
|
|
26
|
-
globalThis.getPost = async (id) => {
|
|
27
|
-
return (await postLoader.get([id]))[0];
|
|
28
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ITerm } from "../../entities/term/term.interface";
|
|
2
|
-
import { EntityLoader } from "./entity-loader.interface";
|
|
3
|
-
declare global {
|
|
4
|
-
/** Global instance of the TermLoader. */
|
|
5
|
-
var termLoader: EntityLoader<ITerm, TermQueryArgs>;
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves terms by their IDs.
|
|
8
|
-
*
|
|
9
|
-
* @param {number[]} ids Array of term IDs.
|
|
10
|
-
* @returns {Promise<ITerm[]>} Array of terms.
|
|
11
|
-
*/
|
|
12
|
-
var getTerms: (ids: number[]) => Promise<ITerm[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves a single term by ID.
|
|
15
|
-
*
|
|
16
|
-
* @param {number} id The term ID.
|
|
17
|
-
* @returns {Promise<ITerm | undefined>} The term or undefined.
|
|
18
|
-
*/
|
|
19
|
-
var getTerm: (id: number) => Promise<ITerm | undefined>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Term } from "@/entities/term/term";
|
|
2
|
-
import { EntityLoaderBase } from "./entity-loader-base";
|
|
3
|
-
import { TermQuery } from "@/repository/termquery/term-query";
|
|
4
|
-
class TermLoader extends EntityLoaderBase {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.queryClass = TermQuery;
|
|
8
|
-
}
|
|
9
|
-
static instance() {
|
|
10
|
-
if (!this._instance) {
|
|
11
|
-
this._instance = new TermLoader();
|
|
12
|
-
}
|
|
13
|
-
return this._instance;
|
|
14
|
-
}
|
|
15
|
-
async fetchFromDatabase(ids) {
|
|
16
|
-
return await Term.get(ids);
|
|
17
|
-
}
|
|
18
|
-
getEntityId(term) {
|
|
19
|
-
return term.termId;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
globalThis.termLoader = TermLoader.instance();
|
|
23
|
-
globalThis.getTerms = async (ids) => {
|
|
24
|
-
return await termLoader.get(ids);
|
|
25
|
-
};
|
|
26
|
-
globalThis.getTerm = async (id) => {
|
|
27
|
-
return (await termLoader.get([id]))[0];
|
|
28
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { IUser } from "../../entities/user/user.interface";
|
|
2
|
-
import { EntityLoader } from "./entity-loader.interface";
|
|
3
|
-
declare global {
|
|
4
|
-
/** Global instance of the UserLoader. */
|
|
5
|
-
var userLoader: EntityLoader<IUser, UserQueryArgs>;
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves users by their IDs.
|
|
8
|
-
*
|
|
9
|
-
* @param {number[]} ids Array of user IDs.
|
|
10
|
-
* @returns {Promise<IUser[]>} Array of users.
|
|
11
|
-
*/
|
|
12
|
-
var getUsers: (ids: number[]) => Promise<IUser[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves a single user by ID.
|
|
15
|
-
*
|
|
16
|
-
* @param {number} id The user ID.
|
|
17
|
-
* @returns {Promise<IUser | undefined>} The user or undefined.
|
|
18
|
-
*/
|
|
19
|
-
var getUser: (id: number) => Promise<IUser | undefined>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { User } from "@/entities/user/user";
|
|
2
|
-
import { EntityLoaderBase } from "./entity-loader-base";
|
|
3
|
-
import { UserQuery } from "@/repository/userquery/user-query";
|
|
4
|
-
class UserLoader extends EntityLoaderBase {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.queryClass = UserQuery;
|
|
8
|
-
}
|
|
9
|
-
static instance() {
|
|
10
|
-
if (!this._instance) {
|
|
11
|
-
this._instance = new UserLoader();
|
|
12
|
-
}
|
|
13
|
-
return this._instance;
|
|
14
|
-
}
|
|
15
|
-
async fetchFromDatabase(ids) {
|
|
16
|
-
return await User.get(ids);
|
|
17
|
-
}
|
|
18
|
-
getEntityId(user) {
|
|
19
|
-
return user.ID;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
globalThis.userLoader = UserLoader.instance();
|
|
23
|
-
globalThis.getUsers = async (ids) => {
|
|
24
|
-
return await userLoader.get(ids);
|
|
25
|
-
};
|
|
26
|
-
globalThis.getUser = async (id) => {
|
|
27
|
-
return (await userLoader.get([id]))[0];
|
|
28
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { NextpressFieldGroup } from "@/acf-functions/types/acf-field-group";
|
|
2
|
-
import { FieldProps } from "@/acf-functions/types/components/field-props";
|
|
3
|
-
import { IFieldLocation } from "../../entities/common";
|
|
4
|
-
/** Specifies location to retrieve fields from. */
|
|
5
|
-
type Location = IFieldLocation | 'options';
|
|
6
|
-
declare global {
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves, parses, and maps an Advanced Custom Fields (ACF) value to its corresponding component properties.
|
|
9
|
-
*
|
|
10
|
-
* @param {T} fieldGroup The configuration object defining the ACF field group and its schema.
|
|
11
|
-
* @param {K} selector The key name of the field to retrieve.
|
|
12
|
-
* @param {Location} [location] The database entity or context from which to load the field data. Accepts an `IFieldLocation` object or the string `'options'`. Defaults to the current queried object if omitted.
|
|
13
|
-
*
|
|
14
|
-
* @returns {Promise<FieldProps<T>[K]>} A promise resolving to the mapped field properties.
|
|
15
|
-
*/
|
|
16
|
-
var getField: <T extends NextpressFieldGroup, K extends keyof FieldProps<T> & string>(fieldGroup: T, selector: K, location?: Location) => Promise<FieldProps<T>[K]>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { mapField } from "../../acf-functions/services/map-fields/map-fields";
|
|
2
|
-
globalThis.getField = async (fieldGroup, selector, location) => {
|
|
3
|
-
var _a;
|
|
4
|
-
if (!location) {
|
|
5
|
-
switch (queriedObject.objectType) {
|
|
6
|
-
case 'post':
|
|
7
|
-
location = await getThePost();
|
|
8
|
-
break;
|
|
9
|
-
// TODO: Add support for Term and User
|
|
10
|
-
// case 'term':
|
|
11
|
-
// location = await getTheTerm();
|
|
12
|
-
// break;
|
|
13
|
-
// case 'user':
|
|
14
|
-
// location = await getTheUser();
|
|
15
|
-
// break;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (!location)
|
|
19
|
-
return [];
|
|
20
|
-
const values = (_a = await (async () => {
|
|
21
|
-
if (location === 'options') {
|
|
22
|
-
const prefix = 'options_';
|
|
23
|
-
const foundOptions = await optionLoader.findAndPrime({
|
|
24
|
-
column: 'optionName',
|
|
25
|
-
operand: 'like',
|
|
26
|
-
value: `${prefix}%`
|
|
27
|
-
});
|
|
28
|
-
const options = await optionLoader.get(foundOptions.ids);
|
|
29
|
-
return options.map(option => ({
|
|
30
|
-
key: option.optionName.slice(prefix.length),
|
|
31
|
-
value: option.optionValue
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
return await location.getFields(selector);
|
|
35
|
-
})()) !== null && _a !== void 0 ? _a : [];
|
|
36
|
-
const valueMap = values.reduce((map, value) => {
|
|
37
|
-
map.set(value.key, value.value);
|
|
38
|
-
return map;
|
|
39
|
-
}, new Map());
|
|
40
|
-
const field = fieldGroup.fields.find(field => field.name === selector);
|
|
41
|
-
if (!field)
|
|
42
|
-
return;
|
|
43
|
-
return mapField(field, valueMap);
|
|
44
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import './nextpress-config/nextpress-config';
|
|
2
|
-
import './entity-loader/post-loader';
|
|
3
|
-
import './entity-loader/term-loader';
|
|
4
|
-
import './entity-loader/user-loader';
|
|
5
|
-
import './entity-loader/option-loader';
|
|
6
|
-
import './get-field/get-field';
|
|
7
|
-
/**
|
|
8
|
-
* Initializes and returns request-scoped storage for the application state.
|
|
9
|
-
* Uses React cache to prevent state bleeding across requests.
|
|
10
|
-
*
|
|
11
|
-
* @returns {{ currentState: any, loaderStates: Record<string, any> }} Object containing current queried object state and loader states.
|
|
12
|
-
*/
|
|
13
|
-
export declare const queriedObjectState: () => {
|
|
14
|
-
currentState: any;
|
|
15
|
-
loaderStates: Record<string, any>;
|
|
16
|
-
};
|
|
17
|
-
import './queried-object/queried-object';
|
|
18
|
-
export {};
|
package/dist/globals/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './globals';
|
|
2
|
-
export * from './nextpress-config/nextpress-config';
|
|
3
|
-
export * from './get-field/get-field';
|
|
4
|
-
export * from './queried-object/queried-object';
|
|
5
|
-
export * from './entity-loader/entity-loader-base';
|
|
6
|
-
export * from './entity-loader/option-loader';
|
|
7
|
-
export * from './entity-loader/user-loader';
|
|
8
|
-
export * from './entity-loader/post-loader';
|
|
9
|
-
export * from './entity-loader/term-loader';
|
|
10
|
-
export * from './entity-loader/entity-loader.interface';
|
package/dist/globals/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './globals';
|
|
2
|
-
export * from './nextpress-config/nextpress-config';
|
|
3
|
-
export * from './get-field/get-field';
|
|
4
|
-
export * from './queried-object/queried-object';
|
|
5
|
-
export * from './entity-loader/entity-loader-base';
|
|
6
|
-
export * from './entity-loader/option-loader';
|
|
7
|
-
export * from './entity-loader/user-loader';
|
|
8
|
-
export * from './entity-loader/post-loader';
|
|
9
|
-
export * from './entity-loader/term-loader';
|
|
10
|
-
export * from './entity-loader/entity-loader.interface';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { IPost } from "../../entities/post/post.interface";
|
|
2
|
-
import { ITerm } from "../../entities/term/term.interface";
|
|
3
|
-
import { IUser } from "../../entities/user/user.interface";
|
|
4
|
-
/**
|
|
5
|
-
* Represents the state of the queried object.
|
|
6
|
-
*/
|
|
7
|
-
interface IQueriedObject {
|
|
8
|
-
/** Type of the queried object. */
|
|
9
|
-
objectType: 'post' | 'term' | 'user' | null;
|
|
10
|
-
/** Array of post IDs associated with the query. */
|
|
11
|
-
posts: number[];
|
|
12
|
-
/** Current page number. */
|
|
13
|
-
page: number;
|
|
14
|
-
/** Total page count. */
|
|
15
|
-
pageCount: number;
|
|
16
|
-
/** ID of the main queried term. */
|
|
17
|
-
mainTerm?: number;
|
|
18
|
-
/** Array of term IDs associated with the query. */
|
|
19
|
-
terms: number[];
|
|
20
|
-
/** ID of the queried user. */
|
|
21
|
-
user?: number;
|
|
22
|
-
}
|
|
23
|
-
declare global {
|
|
24
|
-
/** The current queried object. */
|
|
25
|
-
var queriedObject: IQueriedObject;
|
|
26
|
-
/**
|
|
27
|
-
* Retrieves the first post from the queried object.
|
|
28
|
-
* @returns {Promise<IPost | undefined>} The post.
|
|
29
|
-
*/
|
|
30
|
-
var getThePost: () => Promise<IPost | undefined>;
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves all posts from the queried object.
|
|
33
|
-
* @returns {Promise<IPost[]>} Array of posts.
|
|
34
|
-
*/
|
|
35
|
-
var getThePosts: () => Promise<IPost[]>;
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves the current page number.
|
|
38
|
-
* @returns {number} Page number.
|
|
39
|
-
*/
|
|
40
|
-
var getThePage: () => number;
|
|
41
|
-
/**
|
|
42
|
-
* Retrieves the total page count.
|
|
43
|
-
* @returns {number} Page count.
|
|
44
|
-
*/
|
|
45
|
-
var getThePageCount: () => number;
|
|
46
|
-
/**
|
|
47
|
-
* Retrieves the main term from the queried object.
|
|
48
|
-
* @returns {Promise<ITerm | undefined>} The term.
|
|
49
|
-
*/
|
|
50
|
-
var getTheTerm: () => Promise<ITerm | undefined>;
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves all terms from the queried object.
|
|
53
|
-
* @returns {Promise<ITerm[]>} Array of terms.
|
|
54
|
-
*/
|
|
55
|
-
var getTheTerms: () => Promise<ITerm[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Retrieves the user from the queried object.
|
|
58
|
-
* @returns {Promise<IUser | undefined>} The user.
|
|
59
|
-
*/
|
|
60
|
-
var getTheUser: () => Promise<IUser | undefined>;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { queriedObjectState } from "../globals";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a blank queried object state.
|
|
4
|
-
*
|
|
5
|
-
* @returns {IQueriedObject} Blank state object.
|
|
6
|
-
*/
|
|
7
|
-
const createBlankState = () => ({
|
|
8
|
-
objectType: null,
|
|
9
|
-
posts: [],
|
|
10
|
-
page: 1,
|
|
11
|
-
pageCount: 1,
|
|
12
|
-
terms: [],
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(globalThis, 'queriedObject', {
|
|
15
|
-
configurable: true,
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get() {
|
|
18
|
-
const state = queriedObjectState();
|
|
19
|
-
return state.currentState || createBlankState();
|
|
20
|
-
},
|
|
21
|
-
set(newData) {
|
|
22
|
-
const store = queriedObjectState();
|
|
23
|
-
if (newData.posts)
|
|
24
|
-
postLoader.prime(newData.posts);
|
|
25
|
-
if (newData.mainTerm)
|
|
26
|
-
termLoader.prime([newData.mainTerm]);
|
|
27
|
-
if (newData.terms)
|
|
28
|
-
termLoader.prime(newData.terms);
|
|
29
|
-
if (newData.user)
|
|
30
|
-
userLoader.prime([newData.user]);
|
|
31
|
-
if (!store.currentState)
|
|
32
|
-
store.currentState = {};
|
|
33
|
-
Object.assign(store.currentState, newData);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
globalThis.getThePost = async () => {
|
|
37
|
-
return (await postLoader.get(globalThis.queriedObject.posts))[0];
|
|
38
|
-
};
|
|
39
|
-
globalThis.getThePosts = () => {
|
|
40
|
-
return postLoader.get(globalThis.queriedObject.posts);
|
|
41
|
-
};
|
|
42
|
-
globalThis.getThePage = () => globalThis.queriedObject.page;
|
|
43
|
-
globalThis.getThePageCount = () => globalThis.queriedObject.pageCount;
|
|
44
|
-
globalThis.getTheTerm = async () => {
|
|
45
|
-
if (!globalThis.queriedObject.mainTerm)
|
|
46
|
-
return;
|
|
47
|
-
return (await termLoader.get([globalThis.queriedObject.mainTerm]))[0];
|
|
48
|
-
};
|
|
49
|
-
globalThis.getTheTerms = () => {
|
|
50
|
-
return termLoader.get(globalThis.queriedObject.terms);
|
|
51
|
-
};
|
|
52
|
-
globalThis.getTheUser = async () => {
|
|
53
|
-
if (!globalThis.queriedObject.user)
|
|
54
|
-
return;
|
|
55
|
-
return (await userLoader.get([globalThis.queriedObject.user]))[0];
|
|
56
|
-
};
|
package/dist/repository/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EntityQuery } from "../../globals/entity-loader/entity-loader.interface";
|
|
2
|
-
import { OptionQueryArgs } from "./option-query-args";
|
|
3
|
-
import { IOption } from "../../entities/option/option.interface";
|
|
4
|
-
/**
|
|
5
|
-
* Executes database queries to retrieve option IDs (or keys) based on provided arguments.
|
|
6
|
-
*/
|
|
7
|
-
export declare class OptionQuery implements EntityQuery<IOption> {
|
|
8
|
-
private args;
|
|
9
|
-
constructor(args: OptionQueryArgs);
|
|
10
|
-
getCount(): number | undefined;
|
|
11
|
-
getIds(): Promise<number[]>;
|
|
12
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { wpdb } from "@/wpdb/wpdb";
|
|
2
|
-
/**
|
|
3
|
-
* Executes database queries to retrieve option IDs (or keys) based on provided arguments.
|
|
4
|
-
*/
|
|
5
|
-
export class OptionQuery {
|
|
6
|
-
constructor(args) {
|
|
7
|
-
this.args = args;
|
|
8
|
-
}
|
|
9
|
-
getCount() {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
async getIds() {
|
|
13
|
-
const operand = this.args.operand || '=';
|
|
14
|
-
return (await wpdb
|
|
15
|
-
.selectFrom('wpOptions')
|
|
16
|
-
.select('optionId')
|
|
17
|
-
.where(this.args.column, operand, this.args.value)
|
|
18
|
-
.execute()).map(option => option.optionId);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EntityQuery } from "../../globals/entity-loader/entity-loader.interface";
|
|
2
|
-
import { IPost } from "../../entities/post/post.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Executes database queries to retrieve post IDs and counts based on provided arguments.
|
|
5
|
-
*/
|
|
6
|
-
export declare class PostQuery implements EntityQuery<IPost> {
|
|
7
|
-
private args;
|
|
8
|
-
private postCount?;
|
|
9
|
-
constructor(args: PostQueryArgs);
|
|
10
|
-
getCount(): number | undefined;
|
|
11
|
-
getIds(): Promise<number[]>;
|
|
12
|
-
}
|