nextpress-core 1.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/lib/acf-functions/core/acf-builder.ts +105 -0
- package/lib/acf-functions/core/acf-component-autoloader.ts +33 -0
- package/lib/acf-functions/core/acf-field-group-autoloader.ts +28 -0
- package/lib/acf-functions/services/define-field-group.ts +10 -0
- package/lib/acf-functions/services/define-layout.ts +10 -0
- package/lib/acf-functions/services/map-fields/helpers/map-choice-object.ts +20 -0
- package/lib/acf-functions/services/map-fields/map-fields.ts +359 -0
- package/lib/acf-functions/types/acf-field-group.d.ts +118 -0
- package/lib/acf-functions/types/acf-field.d.ts +2851 -0
- package/lib/acf-functions/types/acf-layout.d.ts +20 -0
- package/lib/acf-functions/types/acf-values.d.ts +4 -0
- package/lib/acf-functions/types/components/field-props.d.ts +189 -0
- package/lib/acf-functions/types/components/nextpress-component.d.ts +11 -0
- package/lib/ambient.d.ts +15 -0
- package/lib/entities/common.d.ts +30 -0
- package/lib/entities/option/option.interface.d.ts +8 -0
- package/lib/entities/option/option.ts +43 -0
- package/lib/entities/post/post.interface.d.ts +72 -0
- package/lib/entities/post/post.ts +209 -0
- package/lib/entities/term/term.interface.d.ts +8 -0
- package/lib/entities/term/term.ts +82 -0
- package/lib/entities/user/user.interface.d.ts +10 -0
- package/lib/entities/user/user.ts +86 -0
- package/lib/globals/entity-loader/entity-loader-base.ts +141 -0
- package/lib/globals/entity-loader/entity-loader.d.ts +50 -0
- package/lib/globals/entity-loader/option-loader.ts +56 -0
- package/lib/globals/entity-loader/post-loader.ts +59 -0
- package/lib/globals/entity-loader/term-loader.ts +59 -0
- package/lib/globals/entity-loader/user-loader.ts +60 -0
- package/lib/globals/get-field/get-field.ts +75 -0
- package/lib/globals/globals.ts +25 -0
- package/lib/globals/nextpress-config/nextpress-config.interface.d.ts +18 -0
- package/lib/globals/nextpress-config/nextpress-config.ts +7 -0
- package/lib/globals/queried-object/queried-object.ts +124 -0
- package/lib/repository/optionquery/option-query-args.d.ts +21 -0
- package/lib/repository/optionquery/option-query.ts +29 -0
- package/lib/repository/postquery/post-query-args.d.ts +108 -0
- package/lib/repository/postquery/post-query.ts +281 -0
- package/lib/repository/termquery/term-query-args.d.ts +61 -0
- package/lib/repository/termquery/term-query.ts +243 -0
- package/lib/repository/userquery/user-query-args.d.ts +75 -0
- package/lib/repository/userquery/user-query.ts +195 -0
- package/lib/router/helpers.ts +20 -0
- package/lib/router/nextpress-layout.tsx +48 -0
- package/lib/router/nextpress-proxy.ts +45 -0
- package/lib/router/nextpress-static-params.ts +62 -0
- package/lib/router/router.tsx +61 -0
- package/lib/router/routes/api/api-get-admin-bar.ts +29 -0
- package/lib/router/routes/api/api-get-draft-mode.ts +47 -0
- package/lib/router/routes/api/api-get-field-groups.ts +29 -0
- package/lib/router/routes/api/api-post-revalidate.ts +30 -0
- package/lib/router/routes/api/helpers.ts +17 -0
- package/lib/router/routes/author-archive.tsx +75 -0
- package/lib/router/routes/not-found-page.tsx +22 -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/lib/router/types.d.ts +9 -0
- package/lib/services/get-menu.ts +104 -0
- package/lib/services/get-theme-mods.ts +16 -0
- package/lib/services/metadata/get-blogname.ts +9 -0
- package/lib/services/metadata/get-favicon-url.ts +13 -0
- package/lib/services/metadata/get-language-attribute.ts +9 -0
- package/lib/services/services.ts +7 -0
- package/lib/services/utilities/capitalise-first-letter.ts +10 -0
- package/lib/services/utilities/esc-html.ts +12 -0
- package/lib/services/utilities/get-date-time-formatter.ts +49 -0
- package/lib/services/utilities/index.ts +0 -0
- package/lib/services/utilities/kses-post.ts +13 -0
- package/lib/services/utilities/process-url.ts +15 -0
- package/lib/template-heirarchy/_autoloader/template-autoloader.ts +54 -0
- package/lib/template-heirarchy/archive/archive.tsx +28 -0
- package/lib/template-heirarchy/archive/author.tsx +28 -0
- package/lib/template-heirarchy/archive/category.tsx +29 -0
- package/lib/template-heirarchy/archive/posttypearchive.tsx +33 -0
- package/lib/template-heirarchy/archive/tag.tsx +30 -0
- package/lib/template-heirarchy/archive/taxonomy.tsx +28 -0
- package/lib/template-heirarchy/home/home.tsx +28 -0
- package/lib/template-heirarchy/index.tsx +30 -0
- package/lib/template-heirarchy/not-found.tsx/not-found.tsx +28 -0
- package/lib/template-heirarchy/page/page.tsx +28 -0
- package/lib/template-heirarchy/page/posttype.tsx +34 -0
- package/lib/template-heirarchy/page/single.tsx +28 -0
- package/lib/template-heirarchy/page/singular.tsx +28 -0
- package/lib/ui/render-attachment-image.tsx +29 -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/lib/wpdb/wpdb.interface.d.ts +171 -0
- package/lib/wpdb/wpdb.ts +36 -0
- package/package.json +38 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Metadata } from "next";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
import { loadMetadata, loadTemplate } from "../_autoloader/template-autoloader";
|
|
4
|
+
import { IndexMetadata, IndexTemplate } from "..";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loads the metadata for the NotFound template.
|
|
8
|
+
* Fallback: Index
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<Metadata>} The merged metadata object.
|
|
11
|
+
*/
|
|
12
|
+
export async function NotFoundMetadata(): Promise<Metadata> {
|
|
13
|
+
const metadata = await loadMetadata('NotFound');
|
|
14
|
+
return {...(await IndexMetadata()), ...metadata};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders the NotFound template. Falls back to the Index template if not found.
|
|
19
|
+
* Fallback: Index
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<JSX.Element>} The rendered template component.
|
|
22
|
+
*/
|
|
23
|
+
export async function NotFoundTemplate(): Promise<JSX.Element> {
|
|
24
|
+
const NotFound = await loadTemplate('NotFound');
|
|
25
|
+
if (!NotFound) return <IndexTemplate/>
|
|
26
|
+
|
|
27
|
+
return <NotFound/>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Metadata } from "next";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
import { loadMetadata, loadTemplate } from "../_autoloader/template-autoloader";
|
|
4
|
+
import { SingularMetadata, SingularTemplate } from "./singular";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loads the metadata for the Page template.
|
|
8
|
+
* Fallback: Singular
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<Metadata>} The merged metadata object.
|
|
11
|
+
*/
|
|
12
|
+
export async function PageMetadata(): Promise<Metadata> {
|
|
13
|
+
const metadata = await loadMetadata('Page');
|
|
14
|
+
return {...(await SingularMetadata()), ...metadata};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders the Page template. Falls back to the Singular template if not found.
|
|
19
|
+
* Fallback: Singular
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<JSX.Element>} The rendered template component.
|
|
22
|
+
*/
|
|
23
|
+
export async function PageTemplate(): Promise<JSX.Element> {
|
|
24
|
+
const Page = await loadTemplate('Page');
|
|
25
|
+
if (!Page) return <SingularTemplate/>
|
|
26
|
+
|
|
27
|
+
return <Page/>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Metadata } from "next";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
import { loadMetadata, loadTemplate } from "../_autoloader/template-autoloader";
|
|
4
|
+
import { SingularMetadata, SingularTemplate } from "./singular";
|
|
5
|
+
import { capitalizeFirstLetter } from "@/services/utilities/capitalise-first-letter";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Loads the metadata for a Post Type template based on the provided post type string.
|
|
9
|
+
* Fallback: Singular
|
|
10
|
+
*
|
|
11
|
+
* @param {object} props - The properties for loading metadata.
|
|
12
|
+
* @param {string} props.postType - The post type to load metadata for.
|
|
13
|
+
* @returns {Promise<Metadata>} The merged metadata object.
|
|
14
|
+
*/
|
|
15
|
+
export async function PostTypeMetadata({postType}: {postType: string}): Promise<Metadata> {
|
|
16
|
+
const metadata = await loadMetadata(capitalizeFirstLetter(postType));
|
|
17
|
+
return {...(await SingularMetadata()), ...metadata};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Renders a Post Type template based on the provided post type string. Falls back to Singular template if not found.
|
|
22
|
+
* Fallback: Singular
|
|
23
|
+
*
|
|
24
|
+
* @param {object} props - The properties for rendering the template.
|
|
25
|
+
* @param {string} props.postType - The post type to load the template for.
|
|
26
|
+
* @returns {Promise<JSX.Element>} The rendered template component.
|
|
27
|
+
*/
|
|
28
|
+
export async function PostTypeTemplate({postType}: {postType: string}): Promise<JSX.Element> {
|
|
29
|
+
const PostType = await loadTemplate(capitalizeFirstLetter(postType));
|
|
30
|
+
if (!PostType) return <SingularTemplate/>
|
|
31
|
+
|
|
32
|
+
return <PostType/>;
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Metadata } from "next";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
import { loadMetadata, loadTemplate } from "../_autoloader/template-autoloader";
|
|
4
|
+
import { SingularMetadata, SingularTemplate } from "./singular";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loads the metadata for the Single template.
|
|
8
|
+
* Fallback: Singular
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<Metadata>} The merged metadata object.
|
|
11
|
+
*/
|
|
12
|
+
export async function SingleMetadata(): Promise<Metadata> {
|
|
13
|
+
const metadata = await loadMetadata('Single');
|
|
14
|
+
return {...(await SingularMetadata()), ...metadata};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders the Single template. Falls back to the Singular template if not found.
|
|
19
|
+
* Fallback: Singular
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<JSX.Element>} The rendered template component.
|
|
22
|
+
*/
|
|
23
|
+
export async function SingleTemplate(): Promise<JSX.Element> {
|
|
24
|
+
const Single = await loadTemplate('Single');
|
|
25
|
+
if (!Single) return <SingularTemplate/>
|
|
26
|
+
|
|
27
|
+
return <Single/>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Metadata } from "next";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
import { loadMetadata, loadTemplate } from "../_autoloader/template-autoloader";
|
|
4
|
+
import { IndexMetadata, IndexTemplate } from "..";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loads the metadata for the Singular template.
|
|
8
|
+
* Fallback: Index
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<Metadata>} The merged metadata object.
|
|
11
|
+
*/
|
|
12
|
+
export async function SingularMetadata(): Promise<Metadata> {
|
|
13
|
+
const metadata = await loadMetadata('Singular');
|
|
14
|
+
return {...(await IndexMetadata()), ...metadata}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders the Singular template. Falls back to the Index template if not found.
|
|
19
|
+
* Fallback: Index
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<JSX.Element>} The rendered template component.
|
|
22
|
+
*/
|
|
23
|
+
export async function SingularTemplate(): Promise<JSX.Element> {
|
|
24
|
+
const Singular = await loadTemplate('Singular');
|
|
25
|
+
if (!Singular) return <IndexTemplate/>
|
|
26
|
+
|
|
27
|
+
return <Singular {...queriedObject} />;
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ClassValue } from "clsx";
|
|
2
|
+
import Image from "next/image";
|
|
3
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
4
|
+
|
|
5
|
+
type Props = Omit<ComponentPropsWithoutRef<typeof Image>, "src" | "alt" | "height" | "width"> & {
|
|
6
|
+
attachmentId: number;
|
|
7
|
+
className?: ClassValue;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Renders a WordPress media attachment using the Next.js Image component.
|
|
12
|
+
*/
|
|
13
|
+
export async function RenderAttachmentImage({ attachmentId, className, ...rest }: Props) {
|
|
14
|
+
const image = await getPost(attachmentId);
|
|
15
|
+
if (!image) return;
|
|
16
|
+
|
|
17
|
+
const { src, alt, height, width } = image.imageAttributes;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Image
|
|
21
|
+
src={src || ''}
|
|
22
|
+
alt={alt || ''}
|
|
23
|
+
height={height}
|
|
24
|
+
width={width}
|
|
25
|
+
className={className}
|
|
26
|
+
{...rest}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResolvedFlexibleContent } from "../acf-functions/types/components/field-props";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
layouts: ResolvedFlexibleContent<any>,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Dynamically resolves and renders an array of mapped ACF Layout components from a resolved flexible content field.
|
|
9
|
+
*/
|
|
10
|
+
export async function RenderComponents({ layouts }: Props) {
|
|
11
|
+
return layouts.map((layout, index) => <layout.Component key={index} {...layout.content}/>)
|
|
12
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { usePathname } from "next/navigation";
|
|
4
|
+
import Script from "next/script";
|
|
5
|
+
import { wpKsesPost } from "@/services/utilities/kses-post";
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
loggedInUserId?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type AdminBarResponse = {
|
|
12
|
+
html: string,
|
|
13
|
+
assets: {
|
|
14
|
+
css: {
|
|
15
|
+
admin_bar: string,
|
|
16
|
+
dashicons: string
|
|
17
|
+
},
|
|
18
|
+
js: {
|
|
19
|
+
admin_bar: string
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Renders the WordPress admin bar for authenticated administrators browsing the Next.js frontend.
|
|
26
|
+
*/
|
|
27
|
+
export async function RenderTheAdminBar({ loggedInUserId }: Props) {
|
|
28
|
+
const [adminBar, setAdminBar] = useState<AdminBarResponse | null>(null);
|
|
29
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
30
|
+
|
|
31
|
+
const path = usePathname();
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
fetch(`/api/admin-bar?user_id=${loggedInUserId}&path=${encodeURIComponent(path)}`)
|
|
35
|
+
.then((request) => {
|
|
36
|
+
if (!request.ok) {
|
|
37
|
+
throw new Error(`Failed to fetch admin bar: ${request.status}`);
|
|
38
|
+
}
|
|
39
|
+
return request.json();
|
|
40
|
+
})
|
|
41
|
+
.then((response) => {
|
|
42
|
+
setAdminBar(response);
|
|
43
|
+
setTimeout(() => setIsMounted(true), 50);
|
|
44
|
+
})
|
|
45
|
+
.catch((error) => {
|
|
46
|
+
console.error("Failed to load admin bar", error.message);
|
|
47
|
+
})
|
|
48
|
+
}, [loggedInUserId, path]);
|
|
49
|
+
|
|
50
|
+
if (!adminBar) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<link
|
|
57
|
+
rel="stylesheet"
|
|
58
|
+
href={adminBar.assets.css.admin_bar}
|
|
59
|
+
precedence="high"
|
|
60
|
+
/>
|
|
61
|
+
<link
|
|
62
|
+
rel="stylesheet"
|
|
63
|
+
href={adminBar.assets.css.dashicons}
|
|
64
|
+
precedence="high"
|
|
65
|
+
/>
|
|
66
|
+
<Script src={adminBar.assets.js.admin_bar}/>
|
|
67
|
+
|
|
68
|
+
<div
|
|
69
|
+
className={`fixed top-0 left-0 right-0 transform transition-all duration-300 ease-in-out ${
|
|
70
|
+
isMounted
|
|
71
|
+
? "scale-y-100"
|
|
72
|
+
: "scale-y-0"
|
|
73
|
+
}`}
|
|
74
|
+
>
|
|
75
|
+
{wpKsesPost(adminBar.html)}
|
|
76
|
+
</div>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getThemeMods } from "@/services/get-theme-mods";
|
|
2
|
+
import { getBlogname } from "@/services/metadata/get-blogname";
|
|
3
|
+
import { RenderAttachmentImage } from "./render-attachment-image";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
className?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders the custom site logo defined in the WordPress Customizer.
|
|
11
|
+
*
|
|
12
|
+
* Fallback: Renders the text-based Site Title if no custom logo is assigned in WordPress.
|
|
13
|
+
*/
|
|
14
|
+
export async function RenderTheLogo({ className }: Props) {
|
|
15
|
+
const logoId = Number(await getThemeMods('custom_logo')) ?? 0;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={className}>
|
|
19
|
+
{logoId ?
|
|
20
|
+
<RenderAttachmentImage className="h-full w-full object-contain object-center" attachmentId={logoId} sizes="512px"/>
|
|
21
|
+
: <span className="text-4xl font-bold">{await getBlogname()}</span>}
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by kysely-codegen.
|
|
3
|
+
* Please do not edit it manually.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ColumnType } from "kysely";
|
|
7
|
+
|
|
8
|
+
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
|
|
9
|
+
? ColumnType<S, I | undefined, U>
|
|
10
|
+
: ColumnType<T, T | undefined, T>;
|
|
11
|
+
|
|
12
|
+
export interface WpCommentmeta {
|
|
13
|
+
commentId: Generated<number>;
|
|
14
|
+
metaId: Generated<number>;
|
|
15
|
+
metaKey: string | null;
|
|
16
|
+
metaValue: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface WpComment {
|
|
20
|
+
commentAgent: Generated<string>;
|
|
21
|
+
commentApproved: Generated<string>;
|
|
22
|
+
commentAuthor: string;
|
|
23
|
+
commentAuthorEmail: Generated<string>;
|
|
24
|
+
commentAuthorIP: Generated<string>;
|
|
25
|
+
commentAuthorUrl: Generated<string>;
|
|
26
|
+
commentContent: string;
|
|
27
|
+
commentDate: Generated<Date>;
|
|
28
|
+
commentDateGmt: Generated<Date>;
|
|
29
|
+
commentID: Generated<number>;
|
|
30
|
+
commentKarma: Generated<number>;
|
|
31
|
+
commentParent: Generated<number>;
|
|
32
|
+
commentPostID: Generated<number>;
|
|
33
|
+
commentType: Generated<string>;
|
|
34
|
+
userId: Generated<number>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface WpLink {
|
|
38
|
+
linkDescription: Generated<string>;
|
|
39
|
+
linkId: Generated<number>;
|
|
40
|
+
linkImage: Generated<string>;
|
|
41
|
+
linkName: Generated<string>;
|
|
42
|
+
linkNotes: string;
|
|
43
|
+
linkOwner: Generated<number>;
|
|
44
|
+
linkRating: Generated<number>;
|
|
45
|
+
linkRel: Generated<string>;
|
|
46
|
+
linkRss: Generated<string>;
|
|
47
|
+
linkTarget: Generated<string>;
|
|
48
|
+
linkUpdated: Generated<Date>;
|
|
49
|
+
linkUrl: Generated<string>;
|
|
50
|
+
linkVisible: Generated<string>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface WpNextpressPostmeta {
|
|
54
|
+
metaId: Generated<number>;
|
|
55
|
+
metaKey: string | null;
|
|
56
|
+
metaValue: string | null;
|
|
57
|
+
objectId: Generated<number>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface WpNextpressTermmeta {
|
|
61
|
+
metaId: Generated<number>;
|
|
62
|
+
metaKey: string | null;
|
|
63
|
+
metaValue: string | null;
|
|
64
|
+
objectId: Generated<number>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface WpOption {
|
|
68
|
+
autoload: Generated<string>;
|
|
69
|
+
optionId: Generated<number>;
|
|
70
|
+
optionName: Generated<string>;
|
|
71
|
+
optionValue: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface WpPostmeta {
|
|
75
|
+
metaId: Generated<number>;
|
|
76
|
+
metaKey: string | null;
|
|
77
|
+
metaValue: string | null;
|
|
78
|
+
postId: Generated<number>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface WpPost {
|
|
82
|
+
commentCount: Generated<number>;
|
|
83
|
+
commentStatus: Generated<string>;
|
|
84
|
+
guid: Generated<string>;
|
|
85
|
+
ID: Generated<number>;
|
|
86
|
+
menuOrder: Generated<number>;
|
|
87
|
+
pinged: string;
|
|
88
|
+
pingStatus: Generated<string>;
|
|
89
|
+
postAuthor: Generated<number>;
|
|
90
|
+
postContent: string;
|
|
91
|
+
postContentFiltered: string;
|
|
92
|
+
postDate: Generated<Date>;
|
|
93
|
+
postDateGmt: Generated<Date>;
|
|
94
|
+
postExcerpt: string;
|
|
95
|
+
postMimeType: Generated<string>;
|
|
96
|
+
postModified: Generated<Date>;
|
|
97
|
+
postModifiedGmt: Generated<Date>;
|
|
98
|
+
postName: Generated<string>;
|
|
99
|
+
postParent: Generated<number>;
|
|
100
|
+
postPassword: Generated<string>;
|
|
101
|
+
postStatus: Generated<string>;
|
|
102
|
+
postTitle: string;
|
|
103
|
+
postType: Generated<string>;
|
|
104
|
+
toPing: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface WpTermmeta {
|
|
108
|
+
metaId: Generated<number>;
|
|
109
|
+
metaKey: string | null;
|
|
110
|
+
metaValue: string | null;
|
|
111
|
+
termId: Generated<number>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface WpTermRelationship {
|
|
115
|
+
objectId: Generated<number>;
|
|
116
|
+
termOrder: Generated<number>;
|
|
117
|
+
termTaxonomyId: Generated<number>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface WpTerm {
|
|
121
|
+
name: Generated<string>;
|
|
122
|
+
slug: Generated<string>;
|
|
123
|
+
termGroup: Generated<number>;
|
|
124
|
+
termId: Generated<number>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface WpTermTaxonomy {
|
|
128
|
+
count: Generated<number>;
|
|
129
|
+
description: string;
|
|
130
|
+
parent: Generated<number>;
|
|
131
|
+
taxonomy: Generated<string>;
|
|
132
|
+
termId: Generated<number>;
|
|
133
|
+
termTaxonomyId: Generated<number>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface WpUsermeta {
|
|
137
|
+
metaKey: string | null;
|
|
138
|
+
metaValue: string | null;
|
|
139
|
+
umetaId: Generated<number>;
|
|
140
|
+
userId: Generated<number>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface WpUser {
|
|
144
|
+
displayName: Generated<string>;
|
|
145
|
+
ID: Generated<number>;
|
|
146
|
+
userActivationKey: Generated<string>;
|
|
147
|
+
userEmail: Generated<string>;
|
|
148
|
+
userLogin: Generated<string>;
|
|
149
|
+
userNicename: Generated<string>;
|
|
150
|
+
userPass: Generated<string>;
|
|
151
|
+
userRegistered: Generated<Date>;
|
|
152
|
+
userStatus: Generated<number>;
|
|
153
|
+
userUrl: Generated<string>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface DB {
|
|
157
|
+
wpCommentmeta: WpCommentmeta;
|
|
158
|
+
wpComments: WpComment;
|
|
159
|
+
wpLinks: WpLink;
|
|
160
|
+
wpNextpressPostmeta: WpNextpressPostmeta;
|
|
161
|
+
wpNextpressTermmeta: WpNextpressTermmeta;
|
|
162
|
+
wpOptions: WpOption;
|
|
163
|
+
wpPostmeta: WpPostmeta;
|
|
164
|
+
wpPosts: WpPost;
|
|
165
|
+
wpTermmeta: WpTermmeta;
|
|
166
|
+
wpTermRelationships: WpTermRelationship;
|
|
167
|
+
wpTerms: WpTerm;
|
|
168
|
+
wpTermTaxonomy: WpTermTaxonomy;
|
|
169
|
+
wpUsermeta: WpUsermeta;
|
|
170
|
+
wpUsers: WpUser;
|
|
171
|
+
}
|
package/lib/wpdb/wpdb.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DB } from './wpdb.interface'
|
|
2
|
+
import { createPool } from 'mysql2'
|
|
3
|
+
import { CamelCasePlugin, DeduplicateJoinsPlugin, Kysely, MysqlDialect } from 'kysely'
|
|
4
|
+
|
|
5
|
+
const dialect = new MysqlDialect({
|
|
6
|
+
pool: createPool({
|
|
7
|
+
user: 'root',
|
|
8
|
+
host: 'db',
|
|
9
|
+
password: process.env.MYSQL_ROOT_PASSWORD,
|
|
10
|
+
database: process.env.MYSQL_DATABASE,
|
|
11
|
+
waitForConnections: true,
|
|
12
|
+
connectionLimit: 150,
|
|
13
|
+
maxIdle: 150,
|
|
14
|
+
idleTimeout: 60000,
|
|
15
|
+
queueLimit: 0,
|
|
16
|
+
enableKeepAlive: true,
|
|
17
|
+
keepAliveInitialDelay: 0,
|
|
18
|
+
}),
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const wpdb = new Kysely<DB>({
|
|
22
|
+
dialect,
|
|
23
|
+
plugins: [new CamelCasePlugin(), new DeduplicateJoinsPlugin()],
|
|
24
|
+
// log(event) {
|
|
25
|
+
// if (process.env.NODE_ENV !== 'development') return;
|
|
26
|
+
|
|
27
|
+
// if (event.level === 'query') {
|
|
28
|
+
// console.log(`\n[${event.queryDurationMillis.toFixed(2)}ms] QUERY EXECUTION`);
|
|
29
|
+
// console.log(`SQL: ${event.query.sql}`);
|
|
30
|
+
// console.log(`PARAMS: ${JSON.stringify(event.query.parameters)}`);
|
|
31
|
+
// }
|
|
32
|
+
// if (event.level === 'error') {
|
|
33
|
+
// console.error(`DB ERROR:`, event.error);
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nextpress-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Nextpress Core",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
"./*": {
|
|
11
|
+
"import": "./lib/*.{ts,tsx}"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"html-react-parser": "^6.1.2",
|
|
19
|
+
"isomorphic-dompurify": "^3.14.0",
|
|
20
|
+
"kysely": "^0.29.2",
|
|
21
|
+
"mysql2": "^3.22.3",
|
|
22
|
+
"next": "16.2.6",
|
|
23
|
+
"php-serialize": "^5.1.3",
|
|
24
|
+
"react": "19.2.4",
|
|
25
|
+
"react-dom": "19.2.4"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@microsoft/api-extractor": "^7.58.9",
|
|
29
|
+
"@tailwindcss/postcss": "^4",
|
|
30
|
+
"@types/node": "^20.19.41",
|
|
31
|
+
"@types/react": "^19",
|
|
32
|
+
"@types/react-dom": "^19",
|
|
33
|
+
"babel-plugin-react-compiler": "1.0.0",
|
|
34
|
+
"cross-env": "^10.1.0",
|
|
35
|
+
"tailwindcss": "^4",
|
|
36
|
+
"typescript": "^5"
|
|
37
|
+
}
|
|
38
|
+
}
|