@rnaga/wp-node
Version:
👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**
246 lines (245 loc) • 11.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wpTables = exports.wpUsers = exports.wpUserMeta = exports.wpTermTaxonomy = exports.wpTermRelationships = exports.wpTerms = exports.wpTermMeta = exports.wpSiteMeta = exports.wpSite = exports.wpSignups = exports.wpRegistrationLog = exports.wpPosts = exports.wpPostMeta = exports.wpOptions = exports.wpLinks = exports.wpComments = exports.wpCommentMeta = exports.wpBlogs = exports.wpBlogMeta = void 0;
const zod_1 = require("zod");
const date_1 = require("./date");
const common_1 = require("../common");
//import { undefinedIfEmptyString } from "./helpers";
// Define the schema for the `wp_blogmeta` table
exports.wpBlogMeta = zod_1.z.object({
meta_id: zod_1.z.number().int().nonnegative(),
blog_id: zod_1.z.number().int().nonnegative().default(0),
meta_key: zod_1.z.string().trim().max(255).nullable(),
meta_value: zod_1.z.string().trim().nullable(),
});
// Define the schema for the `wp_blogs` table
exports.wpBlogs = zod_1.z.object({
blog_id: zod_1.z.number().int().nonnegative(),
site_id: zod_1.z.number().int().nonnegative().default(0),
domain: zod_1.z.string().max(200).trim().default(""),
path: zod_1.z.string().max(100).trim().default("/"),
registered: date_1.mySQLDate,
last_updated: date_1.mySQLDate,
public: zod_1.z.number().max(1).nonnegative().default(1),
archived: zod_1.z.number().max(1).nonnegative().default(0),
mature: zod_1.z.number().max(1).nonnegative().default(0),
spam: zod_1.z.number().max(1).nonnegative().default(0),
deleted: zod_1.z.number().max(1).nonnegative().default(0),
lang_id: zod_1.z.number().int().default(0),
});
// Define the schema for the `wp_commentmeta` table
exports.wpCommentMeta = zod_1.z.object({
meta_id: zod_1.z.number().int().nonnegative(),
comment_id: zod_1.z.number().int().nonnegative().default(0),
meta_key: zod_1.z.string().max(255).trim().nullable(),
meta_value: zod_1.z.string().trim().nullable(),
});
// Define the schema for the `wp_comments` table
exports.wpComments = zod_1.z.object({
comment_ID: zod_1.z.number().int().nonnegative(),
comment_post_ID: zod_1.z.number().int().nonnegative().default(0),
comment_author: zod_1.z.string().trim().max(245).default(""),
// comment_author: z.union([
// z.string().max(245).trim().transform(undefinedIfEmptyString),
// z.string().max(0).optional(),
// ]),
comment_author_email: zod_1.z.union([
zod_1.z.email().max(100).trim(),
zod_1.z.string().max(0).optional(),
]),
comment_author_url: zod_1.z.union([
zod_1.z.string().max(100).trim().default(""),
zod_1.z.string().max(0).optional(),
]),
comment_author_IP: zod_1.z.union([
zod_1.z.string().trim().max(100).default(""),
zod_1.z.string().max(0).optional(),
]),
comment_date: date_1.mySQLDate,
comment_date_gmt: date_1.mySQLDate,
comment_content: zod_1.z.string().trim().max(65525).default(""),
comment_karma: zod_1.z.number().int().default(0),
comment_approved: zod_1.z.union([
zod_1.z.number().max(1).nonnegative().default(1),
zod_1.z.enum(["0", "1", "spam", "trash", "post-trashed", "approve", "hold"]),
]),
comment_agent: zod_1.z.string().max(255).trim().default(""),
comment_type: zod_1.z.string().max(20).trim().min(1).default("comment"),
comment_parent: zod_1.z.number().int().nonnegative().default(0),
user_id: zod_1.z.number().int().nonnegative().default(0),
});
// Define the schema for the `wp_links` table
exports.wpLinks = zod_1.z.object({
link_id: zod_1.z.number().int().nonnegative(),
link_url: zod_1.z.string().max(255).trim(),
link_name: zod_1.z.string().max(255).trim(),
link_image: zod_1.z.string().max(255).trim().default(""),
link_target: zod_1.z.string().max(25).trim().default(""),
link_description: zod_1.z.string().max(255).trim().default(""),
link_visible: zod_1.z.string().max(20).trim().default("Y"),
link_owner: zod_1.z.number().int().nonnegative().default(1),
link_rating: zod_1.z.number().int().default(0),
link_updated: date_1.mySQLDate,
link_rel: zod_1.z.string().max(255).trim().default(""),
link_notes: zod_1.z.string().trim().optional().default(""),
link_rss: zod_1.z.union([
zod_1.z.string().max(255).trim(), //.transform(undefinedIfEmptyString),
zod_1.z.string().max(0).optional().default(""),
]),
});
// Define the schema for the `wp_options` table
exports.wpOptions = zod_1.z.object({
option_id: zod_1.z.number().int().nonnegative(),
option_name: zod_1.z.string().max(191).trim().default(""),
option_value: zod_1.z.string().trim(),
autoload: zod_1.z.string().max(20).trim().default("yes"),
});
// Define the schema for the `wp_postmeta` table
exports.wpPostMeta = zod_1.z.object({
meta_id: zod_1.z.number().int().nonnegative(),
post_id: zod_1.z.number().int().nonnegative().default(0),
meta_key: zod_1.z.string().max(255).trim().nullable(),
meta_value: zod_1.z.string().trim().nullable(),
});
// Define the schema for the `wp_posts` table
exports.wpPosts = zod_1.z.object({
ID: zod_1.z.number().int().nonnegative(),
post_author: zod_1.z.number().int().nonnegative().default(0),
post_date: date_1.mySQLDate,
post_date_gmt: date_1.mySQLDate,
post_content: zod_1.z.string().trim().default(""),
post_title: zod_1.z.string().max(65535).trim().default(""), // text type max length in MySQL
post_excerpt: zod_1.z.string().max(65535).trim().default(""), // text type max length in MySQL
post_status: zod_1.z.string().max(20).trim().default("publish"),
comment_status: zod_1.z.string().max(20).trim().default("open"),
ping_status: zod_1.z.string().max(20).trim().default("open"),
post_password: zod_1.z.string().max(255).trim().default(""),
post_name: zod_1.z.string().max(200).trim().default(""),
to_ping: zod_1.z.string().max(65535).trim().default(""), // text type max length in MySQL
pinged: zod_1.z.string().max(65535).trim().default(""), // text type max length in MySQL
post_modified: date_1.mySQLDate,
post_modified_gmt: date_1.mySQLDate,
post_content_filtered: zod_1.z.string().trim().default(""),
post_parent: zod_1.z.number().int().nonnegative().default(0),
guid: zod_1.z.string().max(255).trim().default(""),
menu_order: zod_1.z.number().int().default(0),
post_type: zod_1.z.string().max(20).trim().default("post"),
post_mime_type: zod_1.z.string().max(100).trim().default(""),
comment_count: zod_1.z.number().int().nonnegative().default(0),
});
// Define the schema for the `wp_registration_log` table
exports.wpRegistrationLog = zod_1.z.object({
ID: zod_1.z.number().int().nonnegative(),
email: zod_1.z.email().trim(),
IP: zod_1.z.union([zod_1.z.string().trim(), zod_1.z.string().max(0).optional()]),
blog_id: zod_1.z.number().int().nonnegative(),
date_registered: date_1.mySQLDate,
});
// Define the schema for the `wp_signups` table
exports.wpSignups = zod_1.z.object({
signup_id: zod_1.z.number().int().nonnegative(),
domain: zod_1.z.string().max(200).trim().default(""),
path: zod_1.z.string().max(100).trim().default(""),
title: zod_1.z.string().trim(),
user_login: zod_1.z.string().max(60).trim().default(""),
user_email: zod_1.z.email().max(100).trim().default(""),
registered: date_1.mySQLDate,
activated: date_1.mySQLDate,
active: zod_1.z.number().max(1).nonnegative().default(0),
activation_key: zod_1.z.string().max(50).trim().default(""),
meta: zod_1.z
.string()
.trim()
.nullable()
.transform((v) => common_1.formatting.primitive(v)),
});
// Define the schema for the `wp_site` table
exports.wpSite = zod_1.z.object({
id: zod_1.z.number().int().nonnegative(),
domain: zod_1.z.string().max(200).trim().default(""),
path: zod_1.z.string().max(100).trim().default(""),
});
// Define the schema for the `wp_sitemeta` table
exports.wpSiteMeta = zod_1.z.object({
meta_id: zod_1.z.number().int().nonnegative(),
site_id: zod_1.z.number().int().nonnegative().default(0),
meta_key: zod_1.z.string().max(255).trim().nullable(),
meta_value: zod_1.z.string().trim().nullable(),
});
// Define the schema for the `wp_termmeta` table
exports.wpTermMeta = zod_1.z.object({
meta_id: zod_1.z.number().int().nonnegative(),
term_id: zod_1.z.number().int().nonnegative().default(0),
meta_key: zod_1.z.string().max(255).trim().nullable(),
meta_value: zod_1.z.string().trim().nullable(),
});
// Define the schema for the `wp_terms` table
exports.wpTerms = zod_1.z.object({
term_id: zod_1.z.number().int().nonnegative(),
name: zod_1.z.string().max(200).trim(),
slug: zod_1.z
.string()
.max(200)
.transform((v) => common_1.formatting.slug(v)),
term_group: zod_1.z.number().default(0),
});
// Define the schema for the `wp_term_relationships` table
exports.wpTermRelationships = zod_1.z.object({
object_id: zod_1.z.number().int().nonnegative().default(0),
term_taxonomy_id: zod_1.z.number().int().nonnegative().default(0),
term_order: zod_1.z.number().int().default(0),
});
// Define the schema for the `wp_term_taxonomy` table
exports.wpTermTaxonomy = zod_1.z.object({
term_taxonomy_id: zod_1.z.number().int().nonnegative(),
term_id: zod_1.z.number().int().nonnegative().default(0),
taxonomy: zod_1.z.string().max(32).trim().default(""),
description: zod_1.z.string().trim().default(""),
parent: zod_1.z.number().int().nonnegative().default(0),
count: zod_1.z.number().int().nonnegative().default(0),
});
// Define the schema for the `wp_usermeta` table
exports.wpUserMeta = zod_1.z.object({
umeta_id: zod_1.z.number().int().nonnegative(),
user_id: zod_1.z.number().int().nonnegative().default(0),
meta_key: zod_1.z.string().max(255).trim().nullable(),
meta_value: zod_1.z.string().trim().nullable(),
});
// Define the schema for the `wp_users` table
exports.wpUsers = zod_1.z.object({
ID: zod_1.z.number().int().nonnegative(),
user_login: zod_1.z.string().max(60).trim().toLowerCase().default(""),
user_pass: zod_1.z.string().max(255).trim().default(""),
user_nicename: zod_1.z.string().max(50).trim().default(""),
user_email: zod_1.z.email().max(100).trim().default(""),
user_url: zod_1.z.union([
zod_1.z.string().max(100).trim().default(""),
zod_1.z.string().max(0).optional(),
]),
user_registered: date_1.mySQLDateWithZeroDefaultDate,
user_activation_key: zod_1.z.string().max(255).trim().default(""),
user_status: zod_1.z.number().int().default(0),
display_name: zod_1.z.string().max(250).trim().default(""),
spam: zod_1.z.number().max(1).nonnegative().default(0),
deleted: zod_1.z.number().max(1).nonnegative().default(0),
});
exports.wpTables = {
blogmeta: exports.wpBlogMeta,
blogs: exports.wpBlogs,
commentmeta: exports.wpCommentMeta,
comments: exports.wpComments,
links: exports.wpLinks,
options: exports.wpOptions,
postmeta: exports.wpPostMeta,
posts: exports.wpPosts,
registration_log: exports.wpRegistrationLog,
signups: exports.wpSignups,
site: exports.wpSite,
sitemeta: exports.wpSiteMeta,
termmeta: exports.wpTermMeta,
term_relationships: exports.wpTermRelationships,
term_taxonomy: exports.wpTermTaxonomy,
terms: exports.wpTerms,
users: exports.wpUsers,
usermeta: exports.wpUserMeta,
};