UNPKG

@rnaga/wp-node

Version:

👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**

111 lines (110 loc) • 3.91 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.defineWPConfig = void 0; const defaults = __importStar(require("../../defaults")); const val = __importStar(require("../../validators")); //type DefineWPConfig = types.DeepPartial<Exclude<types.Config, "database">>; const defineWPConfig = (config //DefineWPConfig ) => { const postTypes = [ ...defaults.postTypes, ...Object.keys(config.postTypeObject ?? {}), ]; const postTypeObject = { ...defaults.postTypeObject, ...config.postTypeObject, }; const postStatuses = [ ...defaults.postStatuses, ...Object.keys(config.postStatusObject ?? {}), ]; const postStatusObject = { ...defaults.postStatusObject, ...config.postStatusObject, }; const taxonomyNames = [ ...defaults.taxonomyNames, ...Object.keys(config.taxonomies ?? {}), ]; const taxonomies = { ...defaults.taxonomies, ...config.taxonomies }; return val.config.config.parse({ constants: { ALLOW_UNFILTERED_UPLOADS: false, DISALLOW_FILE_EDIT: true, DISALLOW_UNFILTERED_HTML: true, TRASHED_SUFFIX_TO_POST_NAME_FOR_POST: "__trashed", LINK_USE_SSL: true, WP_LOG_LEVEL: config.logLevel ?? "info", ...config.constants, }, extensions: { misc: defaults.miscExtensions, audio: defaults.audioExtensions, video: defaults.videoExtensions, ...config.extensions, }, options: { // wp_protect_special_option protected: ["alloptions", "notoptions"], defaults: defaults.defaultOptionKeys, ...config.options, }, multisite: { enabled: false, defaultBlogId: 0, defaultSiteId: 0, defaultSitemetaKeys: defaults.defaultSitemetaKeys, subdirectoryReservedNames: defaults.subdirectoryReservedNames, ...config.multisite, }, tablePrefix: "wp_", posts: { typeNames: postTypes, types: postTypeObject, statusNames: postStatuses, statuses: postStatusObject, }, taxonomy: { names: taxonomyNames, settings: taxonomies, }, roles: defaults.roles, database: config.database, staticAssetsPath: config.staticAssetsPath, }); }; exports.defineWPConfig = defineWPConfig;