@rnaga/wp-node 1.1.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/application.d.ts +76 -0
- package/application.d.ts.map +1 -0
- package/application.js +132 -0
- package/common/async-constructor.d.ts +2 -0
- package/common/async-constructor.d.ts.map +1 -0
- package/common/async-constructor.js +7 -0
- package/common/config/define-post-status.config.d.ts +4 -0
- package/common/config/define-post-status.config.d.ts.map +1 -0
- package/common/config/define-post-status.config.js +26 -0
- package/common/config/define-post-type.config.d.ts +4 -0
- package/common/config/define-post-type.config.d.ts.map +1 -0
- package/common/config/define-post-type.config.js +39 -0
- package/common/config/define-taxonomies.config.d.ts +4 -0
- package/common/config/define-taxonomies.config.d.ts.map +1 -0
- package/common/config/define-taxonomies.config.js +26 -0
- package/common/config/define-wp.config..d.ts +12 -0
- package/common/config/define-wp.config..d.ts.map +1 -0
- package/common/config/define-wp.config..js +110 -0
- package/common/config/index.d.ts +5 -0
- package/common/config/index.d.ts.map +1 -0
- package/common/config/index.js +20 -0
- package/common/date.d.ts +19 -0
- package/common/date.d.ts.map +1 -0
- package/common/date.js +116 -0
- package/common/define-hooks.d.ts +4 -0
- package/common/define-hooks.d.ts.map +1 -0
- package/common/define-hooks.js +16 -0
- package/common/diff.d.ts +3 -0
- package/common/diff.d.ts.map +1 -0
- package/common/diff.js +23 -0
- package/common/files.d.ts +14 -0
- package/common/files.d.ts.map +1 -0
- package/common/files.js +160 -0
- package/common/formatting.d.ts +47 -0
- package/common/formatting.d.ts.map +1 -0
- package/common/formatting.js +218 -0
- package/common/hierarchy.d.ts +21 -0
- package/common/hierarchy.d.ts.map +1 -0
- package/common/hierarchy.js +78 -0
- package/common/hooks-command.d.ts +7 -0
- package/common/hooks-command.d.ts.map +1 -0
- package/common/hooks-command.js +21 -0
- package/common/index.d.ts +11 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +49 -0
- package/common/password.d.ts +4 -0
- package/common/password.d.ts.map +1 -0
- package/common/password.js +224 -0
- package/common/php-serialize.d.ts +3 -0
- package/common/php-serialize.d.ts.map +1 -0
- package/common/php-serialize.js +17 -0
- package/common/validating.d.ts +10 -0
- package/common/validating.d.ts.map +1 -0
- package/common/validating.js +65 -0
- package/config.d.ts +99 -0
- package/config.d.ts.map +1 -0
- package/config.js +76 -0
- package/constants/async-init.d.ts +2 -0
- package/constants/async-init.d.ts.map +1 -0
- package/constants/async-init.js +4 -0
- package/constants/component.d.ts +3 -0
- package/constants/component.d.ts.map +1 -0
- package/constants/component.js +5 -0
- package/constants/database.d.ts +2 -0
- package/constants/database.d.ts.map +1 -0
- package/constants/database.js +9 -0
- package/constants/default-database-tables.d.ts +7 -0
- package/constants/default-database-tables.d.ts.map +1 -0
- package/constants/default-database-tables.js +26 -0
- package/constants/index.d.ts +9 -0
- package/constants/index.d.ts.map +1 -0
- package/constants/index.js +24 -0
- package/constants/role-capabilities.d.ts +3 -0
- package/constants/role-capabilities.d.ts.map +1 -0
- package/constants/role-capabilities.js +67 -0
- package/constants/role-capability-actions.d.ts +2 -0
- package/constants/role-capability-actions.d.ts.map +1 -0
- package/constants/role-capability-actions.js +90 -0
- package/constants/role-names.d.ts +2 -0
- package/constants/role-names.d.ts.map +1 -0
- package/constants/role-names.js +12 -0
- package/constants/scope.d.ts +6 -0
- package/constants/scope.d.ts.map +1 -0
- package/constants/scope.js +9 -0
- package/core/async-init-reflect.d.ts +5 -0
- package/core/async-init-reflect.d.ts.map +1 -0
- package/core/async-init-reflect.js +18 -0
- package/core/blog.d.ts +20 -0
- package/core/blog.d.ts.map +1 -0
- package/core/blog.js +123 -0
- package/core/capabilities.d.ts +12 -0
- package/core/capabilities.d.ts.map +1 -0
- package/core/capabilities.js +625 -0
- package/core/comment.d.ts +111 -0
- package/core/comment.d.ts.map +1 -0
- package/core/comment.js +173 -0
- package/core/components.d.ts +13 -0
- package/core/components.d.ts.map +1 -0
- package/core/components.js +129 -0
- package/core/context.d.ts +38 -0
- package/core/context.d.ts.map +1 -0
- package/core/context.js +77 -0
- package/core/current.d.ts +33 -0
- package/core/current.d.ts.map +1 -0
- package/core/current.js +229 -0
- package/core/date-time.d.ts +18 -0
- package/core/date-time.d.ts.map +1 -0
- package/core/date-time.js +71 -0
- package/core/hooks/action.d.ts +16 -0
- package/core/hooks/action.d.ts.map +1 -0
- package/core/hooks/action.js +44 -0
- package/core/hooks/actions/init.d.ts +5 -0
- package/core/hooks/actions/init.d.ts.map +1 -0
- package/core/hooks/actions/init.js +28 -0
- package/core/hooks/default-hooks.d.ts +7 -0
- package/core/hooks/default-hooks.d.ts.map +1 -0
- package/core/hooks/default-hooks.js +19 -0
- package/core/hooks/filter.d.ts +12 -0
- package/core/hooks/filter.d.ts.map +1 -0
- package/core/hooks/filter.js +76 -0
- package/core/hooks/filters/capabilities.d.ts +16 -0
- package/core/hooks/filters/capabilities.d.ts.map +1 -0
- package/core/hooks/filters/capabilities.js +395 -0
- package/core/hooks/hooks-command.d.ts +9 -0
- package/core/hooks/hooks-command.d.ts.map +1 -0
- package/core/hooks/hooks-command.js +28 -0
- package/core/hooks/hooks-reflect.d.ts +42 -0
- package/core/hooks/hooks-reflect.d.ts.map +1 -0
- package/core/hooks/hooks-reflect.js +73 -0
- package/core/hooks/hooks.d.ts +61 -0
- package/core/hooks/hooks.d.ts.map +1 -0
- package/core/hooks/hooks.js +82 -0
- package/core/hooks/index.d.ts +4 -0
- package/core/hooks/index.d.ts.map +1 -0
- package/core/hooks/index.js +19 -0
- package/core/installer.d.ts +56 -0
- package/core/installer.d.ts.map +1 -0
- package/core/installer.js +395 -0
- package/core/logger.d.ts +22 -0
- package/core/logger.d.ts.map +1 -0
- package/core/logger.js +65 -0
- package/core/meta.d.ts +20 -0
- package/core/meta.d.ts.map +1 -0
- package/core/meta.js +123 -0
- package/core/options.d.ts +20 -0
- package/core/options.d.ts.map +1 -0
- package/core/options.js +148 -0
- package/core/post.d.ts +39 -0
- package/core/post.d.ts.map +1 -0
- package/core/post.js +164 -0
- package/core/query.d.ts +14 -0
- package/core/query.d.ts.map +1 -0
- package/core/query.js +39 -0
- package/core/role.d.ts +21 -0
- package/core/role.d.ts.map +1 -0
- package/core/role.js +71 -0
- package/core/roles.d.ts +16 -0
- package/core/roles.d.ts.map +1 -0
- package/core/roles.js +84 -0
- package/core/schema.d.ts +13 -0
- package/core/schema.d.ts.map +1 -0
- package/core/schema.js +83 -0
- package/core/site.d.ts +28 -0
- package/core/site.d.ts.map +1 -0
- package/core/site.js +105 -0
- package/core/tables.d.ts +18 -0
- package/core/tables.d.ts.map +1 -0
- package/core/tables.js +64 -0
- package/core/taxonomy.d.ts +23 -0
- package/core/taxonomy.d.ts.map +1 -0
- package/core/taxonomy.js +83 -0
- package/core/term.d.ts +104 -0
- package/core/term.d.ts.map +1 -0
- package/core/term.js +136 -0
- package/core/user.d.ts +32 -0
- package/core/user.d.ts.map +1 -0
- package/core/user.js +273 -0
- package/core/utils/blog.util.d.ts +14 -0
- package/core/utils/blog.util.d.ts.map +1 -0
- package/core/utils/blog.util.js +97 -0
- package/core/utils/comment.util.d.ts +23 -0
- package/core/utils/comment.util.d.ts.map +1 -0
- package/core/utils/comment.util.js +312 -0
- package/core/utils/crud.util.d.ts +40 -0
- package/core/utils/crud.util.d.ts.map +1 -0
- package/core/utils/crud.util.js +97 -0
- package/core/utils/date-time.util.d.ts +9 -0
- package/core/utils/date-time.util.d.ts.map +1 -0
- package/core/utils/date-time.util.js +29 -0
- package/core/utils/link.util.d.ts +23 -0
- package/core/utils/link.util.d.ts.map +1 -0
- package/core/utils/link.util.js +148 -0
- package/core/utils/meta.util.d.ts +13 -0
- package/core/utils/meta.util.d.ts.map +1 -0
- package/core/utils/meta.util.js +73 -0
- package/core/utils/post.util.d.ts +34 -0
- package/core/utils/post.util.d.ts.map +1 -0
- package/core/utils/post.util.js +272 -0
- package/core/utils/query.util.d.ts +36 -0
- package/core/utils/query.util.d.ts.map +1 -0
- package/core/utils/query.util.js +168 -0
- package/core/utils/revision.util.d.ts +67 -0
- package/core/utils/revision.util.d.ts.map +1 -0
- package/core/utils/revision.util.js +105 -0
- package/core/utils/roles.util.d.ts +30 -0
- package/core/utils/roles.util.d.ts.map +1 -0
- package/core/utils/roles.util.js +189 -0
- package/core/utils/signup.util.d.ts +33 -0
- package/core/utils/signup.util.d.ts.map +1 -0
- package/core/utils/signup.util.js +227 -0
- package/core/utils/site.util.d.ts +22 -0
- package/core/utils/site.util.d.ts.map +1 -0
- package/core/utils/site.util.js +122 -0
- package/core/utils/taxonomy.util.d.ts +19 -0
- package/core/utils/taxonomy.util.d.ts.map +1 -0
- package/core/utils/taxonomy.util.js +52 -0
- package/core/utils/term.util.d.ts +13 -0
- package/core/utils/term.util.d.ts.map +1 -0
- package/core/utils/term.util.js +113 -0
- package/core/utils/trx.util.d.ts +24 -0
- package/core/utils/trx.util.d.ts.map +1 -0
- package/core/utils/trx.util.js +86 -0
- package/core/utils/user-self-registration.util.d.ts +46 -0
- package/core/utils/user-self-registration.util.d.ts.map +1 -0
- package/core/utils/user-self-registration.util.js +171 -0
- package/core/utils/user.util.d.ts +153 -0
- package/core/utils/user.util.d.ts.map +1 -0
- package/core/utils/user.util.js +550 -0
- package/core/utils/utils.d.ts +36 -0
- package/core/utils/utils.d.ts.map +1 -0
- package/core/utils/utils.js +85 -0
- package/core/validator.d.ts +11 -0
- package/core/validator.d.ts.map +1 -0
- package/core/validator.js +40 -0
- package/core/vars.d.ts +19 -0
- package/core/vars.d.ts.map +1 -0
- package/core/vars.js +54 -0
- package/crud/blog.crud.d.ts +56 -0
- package/crud/blog.crud.d.ts.map +1 -0
- package/crud/blog.crud.js +301 -0
- package/crud/comment.crud.d.ts +104 -0
- package/crud/comment.crud.d.ts.map +1 -0
- package/crud/comment.crud.js +431 -0
- package/crud/crud.d.ts +63 -0
- package/crud/crud.d.ts.map +1 -0
- package/crud/crud.js +278 -0
- package/crud/error.d.ts +23 -0
- package/crud/error.d.ts.map +1 -0
- package/crud/error.js +51 -0
- package/crud/meta.crud.d.ts +69 -0
- package/crud/meta.crud.d.ts.map +1 -0
- package/crud/meta.crud.js +244 -0
- package/crud/options.crud.d.ts +37 -0
- package/crud/options.crud.d.ts.map +1 -0
- package/crud/options.crud.js +178 -0
- package/crud/post.crud.d.ts +225 -0
- package/crud/post.crud.d.ts.map +1 -0
- package/crud/post.crud.js +589 -0
- package/crud/revision.crud.d.ts +76 -0
- package/crud/revision.crud.d.ts.map +1 -0
- package/crud/revision.crud.js +155 -0
- package/crud/roles.crud.d.ts +50 -0
- package/crud/roles.crud.d.ts.map +1 -0
- package/crud/roles.crud.js +198 -0
- package/crud/settings.crud.d.ts +50 -0
- package/crud/settings.crud.d.ts.map +1 -0
- package/crud/settings.crud.js +153 -0
- package/crud/site.crud.d.ts +62 -0
- package/crud/site.crud.d.ts.map +1 -0
- package/crud/site.crud.js +241 -0
- package/crud/sitemeta.crud.d.ts +55 -0
- package/crud/sitemeta.crud.d.ts.map +1 -0
- package/crud/sitemeta.crud.js +97 -0
- package/crud/term.crud.d.ts +85 -0
- package/crud/term.crud.d.ts.map +1 -0
- package/crud/term.crud.js +285 -0
- package/crud/user-self-registration.crud.d.ts +57 -0
- package/crud/user-self-registration.crud.d.ts.map +1 -0
- package/crud/user-self-registration.crud.js +173 -0
- package/crud/user.crud.d.ts +147 -0
- package/crud/user.crud.d.ts.map +1 -0
- package/crud/user.crud.js +626 -0
- package/database.d.ts +18 -0
- package/database.d.ts.map +1 -0
- package/database.js +80 -0
- package/decorators/async-init.d.ts +2 -0
- package/decorators/async-init.d.ts.map +1 -0
- package/decorators/async-init.js +7 -0
- package/decorators/component.d.ts +12 -0
- package/decorators/component.d.ts.map +1 -0
- package/decorators/component.js +47 -0
- package/decorators/hooks.d.ts +5 -0
- package/decorators/hooks.d.ts.map +1 -0
- package/decorators/hooks.js +30 -0
- package/defaults/extensions.d.ts +4 -0
- package/defaults/extensions.d.ts.map +1 -0
- package/defaults/extensions.js +34 -0
- package/defaults/index.d.ts +11 -0
- package/defaults/index.d.ts.map +1 -0
- package/defaults/index.js +49 -0
- package/defaults/options.d.ts +6 -0
- package/defaults/options.d.ts.map +1 -0
- package/defaults/options.js +267 -0
- package/defaults/post-status.d.ts +10 -0
- package/defaults/post-status.d.ts.map +1 -0
- package/defaults/post-status.js +83 -0
- package/defaults/post-types.d.ts +4 -0
- package/defaults/post-types.d.ts.map +1 -0
- package/defaults/post-types.js +72 -0
- package/defaults/roles.d.ts +31 -0
- package/defaults/roles.d.ts.map +1 -0
- package/defaults/roles.js +213 -0
- package/defaults/seeder.d.ts +34 -0
- package/defaults/seeder.d.ts.map +1 -0
- package/defaults/seeder.js +201 -0
- package/defaults/sitemeta.d.ts +2 -0
- package/defaults/sitemeta.d.ts.map +1 -0
- package/defaults/sitemeta.js +38 -0
- package/defaults/subdirectory-reserved-names.d.ts +2 -0
- package/defaults/subdirectory-reserved-names.d.ts.map +1 -0
- package/defaults/subdirectory-reserved-names.js +16 -0
- package/defaults/taxonomies.d.ts +5 -0
- package/defaults/taxonomies.d.ts.map +1 -0
- package/defaults/taxonomies.js +57 -0
- package/defaults/timezone.d.ts +2 -0
- package/defaults/timezone.d.ts.map +1 -0
- package/defaults/timezone.js +353 -0
- package/package.json +51 -0
- package/query-builder/alias.d.ts +24 -0
- package/query-builder/alias.d.ts.map +1 -0
- package/query-builder/alias.js +64 -0
- package/query-builder/blogs.query.d.ts +22 -0
- package/query-builder/blogs.query.d.ts.map +1 -0
- package/query-builder/blogs.query.js +85 -0
- package/query-builder/comments.query.d.ts +35 -0
- package/query-builder/comments.query.d.ts.map +1 -0
- package/query-builder/comments.query.js +211 -0
- package/query-builder/common.query.d.ts +18 -0
- package/query-builder/common.query.d.ts.map +1 -0
- package/query-builder/common.query.js +58 -0
- package/query-builder/index.d.ts +12 -0
- package/query-builder/index.d.ts.map +1 -0
- package/query-builder/index.js +27 -0
- package/query-builder/meta.query.d.ts +45 -0
- package/query-builder/meta.query.d.ts.map +1 -0
- package/query-builder/meta.query.js +188 -0
- package/query-builder/options.query.d.ts +19 -0
- package/query-builder/options.query.d.ts.map +1 -0
- package/query-builder/options.query.js +57 -0
- package/query-builder/posts.query.d.ts +30 -0
- package/query-builder/posts.query.d.ts.map +1 -0
- package/query-builder/posts.query.js +208 -0
- package/query-builder/query-builder.d.ts +21 -0
- package/query-builder/query-builder.d.ts.map +1 -0
- package/query-builder/query-builder.js +70 -0
- package/query-builder/query-builders.d.ts +18 -0
- package/query-builder/query-builders.d.ts.map +1 -0
- package/query-builder/query-builders.js +64 -0
- package/query-builder/site.query.d.ts +22 -0
- package/query-builder/site.query.d.ts.map +1 -0
- package/query-builder/site.query.js +85 -0
- package/query-builder/terms.query.d.ts +47 -0
- package/query-builder/terms.query.d.ts.map +1 -0
- package/query-builder/terms.query.js +233 -0
- package/query-builder/users.query.d.ts +37 -0
- package/query-builder/users.query.d.ts.map +1 -0
- package/query-builder/users.query.js +188 -0
- package/schema-builder/proxy.d.ts +10 -0
- package/schema-builder/proxy.d.ts.map +1 -0
- package/schema-builder/proxy.js +19 -0
- package/schema-builder/schema-builder.d.ts +21 -0
- package/schema-builder/schema-builder.d.ts.map +1 -0
- package/schema-builder/schema-builder.js +207 -0
- package/schema-builder/schema.d.ts +20 -0
- package/schema-builder/schema.d.ts.map +1 -0
- package/schema-builder/schema.js +527 -0
- package/transactions/blog.trx.d.ts +37 -0
- package/transactions/blog.trx.d.ts.map +1 -0
- package/transactions/blog.trx.js +296 -0
- package/transactions/comment.trx.d.ts +22 -0
- package/transactions/comment.trx.d.ts.map +1 -0
- package/transactions/comment.trx.js +311 -0
- package/transactions/index.d.ts +15 -0
- package/transactions/index.d.ts.map +1 -0
- package/transactions/index.js +30 -0
- package/transactions/link.trx.d.ts +22 -0
- package/transactions/link.trx.d.ts.map +1 -0
- package/transactions/link.trx.js +208 -0
- package/transactions/meta.trx.d.ts +30 -0
- package/transactions/meta.trx.d.ts.map +1 -0
- package/transactions/meta.trx.js +197 -0
- package/transactions/options.trx.d.ts +31 -0
- package/transactions/options.trx.d.ts.map +1 -0
- package/transactions/options.trx.js +192 -0
- package/transactions/post.trx.d.ts +48 -0
- package/transactions/post.trx.d.ts.map +1 -0
- package/transactions/post.trx.js +906 -0
- package/transactions/registration-log.trx.d.ts +14 -0
- package/transactions/registration-log.trx.d.ts.map +1 -0
- package/transactions/registration-log.trx.js +103 -0
- package/transactions/revision.trx.d.ts +32 -0
- package/transactions/revision.trx.d.ts.map +1 -0
- package/transactions/revision.trx.js +278 -0
- package/transactions/roles.trx.d.ts +20 -0
- package/transactions/roles.trx.d.ts.map +1 -0
- package/transactions/roles.trx.js +144 -0
- package/transactions/seeder.trx.d.ts +43 -0
- package/transactions/seeder.trx.d.ts.map +1 -0
- package/transactions/seeder.trx.js +530 -0
- package/transactions/signup.trx.d.ts +53 -0
- package/transactions/signup.trx.d.ts.map +1 -0
- package/transactions/signup.trx.js +305 -0
- package/transactions/site.trx.d.ts +21 -0
- package/transactions/site.trx.d.ts.map +1 -0
- package/transactions/site.trx.js +167 -0
- package/transactions/term.trx.d.ts +51 -0
- package/transactions/term.trx.d.ts.map +1 -0
- package/transactions/term.trx.js +838 -0
- package/transactions/trx.d.ts +9 -0
- package/transactions/trx.d.ts.map +1 -0
- package/transactions/trx.js +20 -0
- package/transactions/user.trx.d.ts +45 -0
- package/transactions/user.trx.d.ts.map +1 -0
- package/transactions/user.trx.js +535 -0
- package/types/capabilities.d.ts +71 -0
- package/types/common.d.ts +16 -0
- package/types/component.d.ts +3 -0
- package/types/config.d.ts +33 -0
- package/types/crud.d.ts +230 -0
- package/types/database.d.ts +50 -0
- package/types/hooks/actions.d.ts +67 -0
- package/types/hooks/command.d.ts +17 -0
- package/types/hooks/filters.d.ts +86 -0
- package/types/hooks/index.d.ts +11 -0
- package/types/index.d.ts +18 -0
- package/types/logging.d.ts +1 -0
- package/types/meta.d.ts +9 -0
- package/types/options.d.ts +3 -0
- package/types/post.d.ts +54 -0
- package/types/query-builder.d.ts +11 -0
- package/types/role.d.ts +34 -0
- package/types/schema.d.ts +11 -0
- package/types/schema.d.ts.map +1 -0
- package/types/schema.js +2 -0
- package/types/taxonomy.d.ts +29 -0
- package/types/timezone.d.ts +3 -0
- package/types/transactions.d.ts +32 -0
- package/types/user.d.ts +12 -0
- package/types/validating.d.ts +9 -0
- package/types/validating.d.ts.map +1 -0
- package/types/validating.js +2 -0
- package/validators/config.d.ts +948 -0
- package/validators/config.d.ts.map +1 -0
- package/validators/config.js +149 -0
- package/validators/crud.d.ts +571 -0
- package/validators/crud.d.ts.map +1 -0
- package/validators/crud.js +281 -0
- package/validators/database.d.ts +958 -0
- package/validators/database.d.ts.map +1 -0
- package/validators/database.js +245 -0
- package/validators/date.d.ts +4 -0
- package/validators/date.d.ts.map +1 -0
- package/validators/date.js +15 -0
- package/validators/helpers.d.ts +16 -0
- package/validators/helpers.d.ts.map +1 -0
- package/validators/helpers.js +86 -0
- package/validators/index.d.ts +10 -0
- package/validators/index.d.ts.map +1 -0
- package/validators/index.js +48 -0
- package/validators/options.d.ts +303 -0
- package/validators/options.d.ts.map +1 -0
- package/validators/options.js +106 -0
- package/validators/post-status.d.ts +42 -0
- package/validators/post-status.d.ts.map +1 -0
- package/validators/post-status.js +18 -0
- package/validators/query.d.ts +534 -0
- package/validators/query.d.ts.map +1 -0
- package/validators/query.js +110 -0
- package/validators/roles.d.ts +22 -0
- package/validators/roles.d.ts.map +1 -0
- package/validators/roles.js +9 -0
- package/validators/sitemeta.d.ts +105 -0
- package/validators/sitemeta.d.ts.map +1 -0
- package/validators/sitemeta.js +39 -0
- package/validators/transactions/blog.d.ts +225 -0
- package/validators/transactions/blog.d.ts.map +1 -0
- package/validators/transactions/blog.js +63 -0
- package/validators/transactions/comment.d.ts +155 -0
- package/validators/transactions/comment.d.ts.map +1 -0
- package/validators/transactions/comment.js +68 -0
- package/validators/transactions/index.d.ts +11 -0
- package/validators/transactions/index.d.ts.map +1 -0
- package/validators/transactions/index.js +26 -0
- package/validators/transactions/link.d.ts +128 -0
- package/validators/transactions/link.d.ts.map +1 -0
- package/validators/transactions/link.js +60 -0
- package/validators/transactions/meta.d.ts +23 -0
- package/validators/transactions/meta.d.ts.map +1 -0
- package/validators/transactions/meta.js +18 -0
- package/validators/transactions/post.d.ts +234 -0
- package/validators/transactions/post.d.ts.map +1 -0
- package/validators/transactions/post.js +100 -0
- package/validators/transactions/roles.d.ts +18 -0
- package/validators/transactions/roles.d.ts.map +1 -0
- package/validators/transactions/roles.js +13 -0
- package/validators/transactions/signup.d.ts +35 -0
- package/validators/transactions/signup.d.ts.map +1 -0
- package/validators/transactions/signup.js +51 -0
- package/validators/transactions/site.d.ts +36 -0
- package/validators/transactions/site.d.ts.map +1 -0
- package/validators/transactions/site.js +49 -0
- package/validators/transactions/term.d.ts +57 -0
- package/validators/transactions/term.d.ts.map +1 -0
- package/validators/transactions/term.js +44 -0
- package/validators/transactions/user.d.ts +182 -0
- package/validators/transactions/user.d.ts.map +1 -0
- package/validators/transactions/user.js +104 -0
|
@@ -0,0 +1,906 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.PostTrx = void 0;
|
|
49
|
+
const zod_1 = require("zod");
|
|
50
|
+
const common_1 = require("../common");
|
|
51
|
+
const config_1 = require("../config");
|
|
52
|
+
const components_1 = require("../core/components");
|
|
53
|
+
const current_1 = require("../core/current");
|
|
54
|
+
const options_1 = require("../core/options");
|
|
55
|
+
const comment_util_1 = require("../core/utils/comment.util");
|
|
56
|
+
const date_time_util_1 = require("../core/utils/date-time.util");
|
|
57
|
+
const link_util_1 = require("../core/utils/link.util");
|
|
58
|
+
const post_util_1 = require("../core/utils/post.util");
|
|
59
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
60
|
+
const taxonomy_util_1 = require("../core/utils/taxonomy.util");
|
|
61
|
+
const validator_1 = require("../core/validator");
|
|
62
|
+
const database_1 = __importDefault(require("../database"));
|
|
63
|
+
const component_1 = require("../decorators/component");
|
|
64
|
+
const val = __importStar(require("../validators"));
|
|
65
|
+
const comment_trx_1 = require("./comment.trx");
|
|
66
|
+
const meta_trx_1 = require("./meta.trx");
|
|
67
|
+
const options_trx_1 = require("./options.trx");
|
|
68
|
+
const revision_trx_1 = require("./revision.trx");
|
|
69
|
+
const term_trx_1 = require("./term.trx");
|
|
70
|
+
const trx_1 = require("./trx");
|
|
71
|
+
const logger_1 = require("../core/logger");
|
|
72
|
+
let PostTrx = class PostTrx extends trx_1.Trx {
|
|
73
|
+
database;
|
|
74
|
+
logger;
|
|
75
|
+
components;
|
|
76
|
+
config;
|
|
77
|
+
postUtil;
|
|
78
|
+
taxonomyUtil;
|
|
79
|
+
commentUtil;
|
|
80
|
+
constructor(database, logger, components, config, postUtil, taxonomyUtil, commentUtil // private validator: Validator
|
|
81
|
+
) {
|
|
82
|
+
super(components);
|
|
83
|
+
this.database = database;
|
|
84
|
+
this.logger = logger;
|
|
85
|
+
this.components = components;
|
|
86
|
+
this.config = config;
|
|
87
|
+
this.postUtil = postUtil;
|
|
88
|
+
this.taxonomyUtil = taxonomyUtil;
|
|
89
|
+
this.commentUtil = commentUtil;
|
|
90
|
+
}
|
|
91
|
+
// update_posts_count
|
|
92
|
+
async updateCount() {
|
|
93
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
94
|
+
const counts = await queryUtil.posts((query) => {
|
|
95
|
+
query.countPublished();
|
|
96
|
+
}, val.query.resultCount); //z.array(z.object({ count: z.number() })));
|
|
97
|
+
const count = counts?.count ?? 0;
|
|
98
|
+
const optionsTrx = this.components.get(options_trx_1.OptionsTrx);
|
|
99
|
+
await optionsTrx.insert("post_count", `${count}`);
|
|
100
|
+
}
|
|
101
|
+
// part of remove_user_from_blog
|
|
102
|
+
async changeAuthor(fromUserId, toUserId) {
|
|
103
|
+
const trx = await this.database.transaction;
|
|
104
|
+
try {
|
|
105
|
+
await trx
|
|
106
|
+
.table(this.tables.get("posts"))
|
|
107
|
+
.where("post_author", fromUserId)
|
|
108
|
+
.update({
|
|
109
|
+
post_author: toUserId,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
await trx.rollback();
|
|
114
|
+
throw new Error(`Failed to change author from: ${fromUserId} to: ${toUserId} - ${e}`);
|
|
115
|
+
}
|
|
116
|
+
await trx.commit();
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
// wp_insert_post
|
|
120
|
+
async upsert(input) {
|
|
121
|
+
const current = this.components.get(current_1.Current);
|
|
122
|
+
const options = this.components.get(options_1.Options);
|
|
123
|
+
const dateTimeUtil = this.components.get(date_time_util_1.DateTimeUtil);
|
|
124
|
+
let update = false;
|
|
125
|
+
let previousStatus = "new";
|
|
126
|
+
let postBefore = undefined;
|
|
127
|
+
let desiredPostSlug = undefined;
|
|
128
|
+
// Update
|
|
129
|
+
if (input.ID && 0 < input.ID) {
|
|
130
|
+
update = true;
|
|
131
|
+
postBefore = await this.postUtil.get(input.ID);
|
|
132
|
+
if (!postBefore.props) {
|
|
133
|
+
throw new Error(`Post not found - ${input.ID}`);
|
|
134
|
+
}
|
|
135
|
+
input.guid = postBefore.props.guid;
|
|
136
|
+
previousStatus = postBefore.props.post_status;
|
|
137
|
+
desiredPostSlug = await postBefore.meta.get("_wp_desired_post_slug");
|
|
138
|
+
// Combine input with existing record
|
|
139
|
+
input = {
|
|
140
|
+
...postBefore.props,
|
|
141
|
+
post_categeory: ((await postBefore.terms("category")) ?? []).map((v) => v.term_id),
|
|
142
|
+
tags_input: ((await postBefore.terms("post_tag")) ?? []).map((v) => v.term_id),
|
|
143
|
+
...input,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const parsedInput = val.trx.postUpsert.parse(input);
|
|
147
|
+
const postDate = dateTimeUtil.get(input.post_date);
|
|
148
|
+
const data = {
|
|
149
|
+
ID: parsedInput.ID ?? 0,
|
|
150
|
+
context: parsedInput.context,
|
|
151
|
+
file: parsedInput.file,
|
|
152
|
+
guid: parsedInput.guid,
|
|
153
|
+
post_date: postDate.mySQLDatetime,
|
|
154
|
+
post_date_gmt: postDate.mySQLGMTDatetime,
|
|
155
|
+
meta_input: parsedInput.meta_input,
|
|
156
|
+
post_status: parsedInput.post_status ?? "draft",
|
|
157
|
+
post_type: parsedInput.post_type ?? "post",
|
|
158
|
+
post_title: parsedInput.post_title,
|
|
159
|
+
post_content: parsedInput.post_content,
|
|
160
|
+
post_excerpt: parsedInput.post_excerpt,
|
|
161
|
+
post_name: parsedInput.post_name,
|
|
162
|
+
post_parent: parsedInput.post_parent,
|
|
163
|
+
pinged: parsedInput.pinged,
|
|
164
|
+
import_id: parsedInput.import_id,
|
|
165
|
+
post_content_filtered: parsedInput.post_content_filtered,
|
|
166
|
+
tags_input: parsedInput.tags_input,
|
|
167
|
+
tax_input: parsedInput.tax_input,
|
|
168
|
+
};
|
|
169
|
+
data.post_name =
|
|
170
|
+
parsedInput.post_name ??
|
|
171
|
+
(update && postBefore && postBefore.props
|
|
172
|
+
? postBefore.props.post_name
|
|
173
|
+
: "");
|
|
174
|
+
const postTypeObject = this.postUtil.getTypeObject(data.post_type);
|
|
175
|
+
// Check empry fields
|
|
176
|
+
if (["editor", "title", "excerpt"].every((v) => postTypeObject?.supports.includes(v)) &&
|
|
177
|
+
!parsedInput.post_content &&
|
|
178
|
+
!parsedInput.post_title &&
|
|
179
|
+
!parsedInput.post_excerpt) {
|
|
180
|
+
throw new Error("Content, title, and excerpt are empty.");
|
|
181
|
+
}
|
|
182
|
+
if (data.post_type == "attachment" &&
|
|
183
|
+
!["inherit", "private", "trash", "auto-draft"].includes(data.post_status)) {
|
|
184
|
+
data.post_status = "inherit";
|
|
185
|
+
}
|
|
186
|
+
let postCategory = [];
|
|
187
|
+
if (Array.isArray(parsedInput.post_categeory)) {
|
|
188
|
+
postCategory = parsedInput.post_categeory.filter((v) => v > 0);
|
|
189
|
+
}
|
|
190
|
+
else if (update && !parsedInput.post_categeory) {
|
|
191
|
+
postCategory = !postBefore
|
|
192
|
+
? []
|
|
193
|
+
: (await postBefore.terms("category"))?.map((term) => term.term_id) ??
|
|
194
|
+
[];
|
|
195
|
+
}
|
|
196
|
+
// Make sure we set a valid category.
|
|
197
|
+
if (0 >= postCategory.length &&
|
|
198
|
+
"post" === data.post_type &&
|
|
199
|
+
"auto-draft" !== data.post_status) {
|
|
200
|
+
const defaultCategory = (await options.get("default_category")) ?? [];
|
|
201
|
+
if (!Array.isArray(defaultCategory)) {
|
|
202
|
+
postCategory = [defaultCategory];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
data.post_categeory = postCategory;
|
|
206
|
+
/*
|
|
207
|
+
* Don't allow contributors to set the post slug for pending review posts.
|
|
208
|
+
*
|
|
209
|
+
* For new posts check the primitive capability, for updates check the meta capability.
|
|
210
|
+
*/
|
|
211
|
+
if ("pending" === data.post_status &&
|
|
212
|
+
((!update &&
|
|
213
|
+
postTypeObject?.capabilities &&
|
|
214
|
+
!(await current.user?.can(postTypeObject.capabilities["publish_posts"]))) ||
|
|
215
|
+
(update && !(await current.user?.can("publish_post", data.ID))))) {
|
|
216
|
+
data.post_name = "";
|
|
217
|
+
}
|
|
218
|
+
const validator = this.components.get(validator_1.Validator);
|
|
219
|
+
/*
|
|
220
|
+
* Create a valid post name. Drafts and pending posts are allowed to have
|
|
221
|
+
* an empty post name.
|
|
222
|
+
*/
|
|
223
|
+
if (0 >= data.post_name.length) {
|
|
224
|
+
if (!["draft", "pending", "auto-draft"].includes(data.post_status)) {
|
|
225
|
+
data.post_name =
|
|
226
|
+
validator.fieldSafe("posts", "post_title", data.post_title) ?? "";
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
data.post_name = "";
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
// New post, or slug has changed.
|
|
234
|
+
data.post_name =
|
|
235
|
+
validator.fieldSafe("posts", "post_title", data.post_name) ?? "";
|
|
236
|
+
}
|
|
237
|
+
data.post_modified = data.post_date;
|
|
238
|
+
data.post_modified_gmt = data.post_date_gmt;
|
|
239
|
+
if (update) {
|
|
240
|
+
const currentDateTime = dateTimeUtil.get();
|
|
241
|
+
data.post_modified = currentDateTime.mySQLDatetime;
|
|
242
|
+
data.post_modified_gmt = currentDateTime.mySQLGMTDatetime;
|
|
243
|
+
}
|
|
244
|
+
if ("attachment" !== data.post_type) {
|
|
245
|
+
const postDate = dateTimeUtil.get(data.post_date_gmt);
|
|
246
|
+
if ("publish" === data.post_status && postDate.isFuture()) {
|
|
247
|
+
data.post_status = "future";
|
|
248
|
+
}
|
|
249
|
+
else if ("future" === data.post_status && !postDate.isFuture()) {
|
|
250
|
+
data.post_status = "publish";
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Comment status.
|
|
254
|
+
data.comment_status = parsedInput.comment_status
|
|
255
|
+
? parsedInput.comment_status
|
|
256
|
+
: update
|
|
257
|
+
? "closed"
|
|
258
|
+
: await this.commentUtil.getDefaultStatus(data.post_type);
|
|
259
|
+
// These variables are needed by compact() later.
|
|
260
|
+
data.post_author =
|
|
261
|
+
parsedInput.post_author > 0
|
|
262
|
+
? parsedInput.post_author
|
|
263
|
+
: current.user?.props?.ID ?? -1;
|
|
264
|
+
data.ping_status =
|
|
265
|
+
parsedInput.ping_status ??
|
|
266
|
+
this.commentUtil.getDefaultStatus(data.post_type, "pingback");
|
|
267
|
+
data.to_ping = data.to_ping
|
|
268
|
+
? validator.fieldSafe("posts", "to_ping", parsedInput.to_ping)
|
|
269
|
+
: "";
|
|
270
|
+
/*
|
|
271
|
+
* The 'wp_insert_post_parent' filter expects all variables to be present.
|
|
272
|
+
* Previously, these variables would have already been extracted
|
|
273
|
+
*/
|
|
274
|
+
data.menu_order = parsedInput.menu_order ?? 0;
|
|
275
|
+
data.post_password = parsedInput.post_password ?? "";
|
|
276
|
+
if ("private" === data.post_status) {
|
|
277
|
+
data.post_password = "";
|
|
278
|
+
}
|
|
279
|
+
const postNameTrashedSuffix = this.config.config.constants.TRASHED_SUFFIX_TO_POST_NAME_FOR_POST;
|
|
280
|
+
/*
|
|
281
|
+
* If the post is being untrashed and it has a desired slug stored in post meta,
|
|
282
|
+
* reassign it.
|
|
283
|
+
*/
|
|
284
|
+
if ("trash" === previousStatus && "trash" !== data.post_status) {
|
|
285
|
+
data.post_name = data.post_name.endsWith(postNameTrashedSuffix)
|
|
286
|
+
? data.post_name.replace(postNameTrashedSuffix, "")
|
|
287
|
+
: data.post_name;
|
|
288
|
+
if (desiredPostSlug) {
|
|
289
|
+
data.post_name = desiredPostSlug;
|
|
290
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
291
|
+
await metaTrx.remove("post", {
|
|
292
|
+
objectId: data.ID,
|
|
293
|
+
key: "_wp_desired_post_slug",
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// When trashing an existing post, change its slug to allow non-trashed posts to use it.
|
|
298
|
+
if ("trash" === data.post_status &&
|
|
299
|
+
"trash" !== previousStatus &&
|
|
300
|
+
"new" !== previousStatus &&
|
|
301
|
+
postBefore?.props?.post_name &&
|
|
302
|
+
!postBefore.props.post_name.endsWith(postNameTrashedSuffix)) {
|
|
303
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
304
|
+
await metaTrx.upsert("post", data.ID, "_wp_desired_post_slug", data.post_name);
|
|
305
|
+
data.post_name = `${postBefore.props.post_name}${postNameTrashedSuffix}`;
|
|
306
|
+
}
|
|
307
|
+
data.post_name = await this.postUtil.getUniqueSlug(data.post_name, data.ID);
|
|
308
|
+
// Don't unslash.
|
|
309
|
+
data.post_mime_type = parsedInput.post_mime_type ?? "";
|
|
310
|
+
let dataUpsert = {};
|
|
311
|
+
try {
|
|
312
|
+
dataUpsert = validator.execAny(update ? val.trx.postUpdate : val.trx.postInsert, Object.entries(data)
|
|
313
|
+
.map(([key, value]) => ({
|
|
314
|
+
[key]: common_1.formatting.unslash(value),
|
|
315
|
+
}))
|
|
316
|
+
.reduce((obj, item) => ({ ...obj, ...item }), {}));
|
|
317
|
+
}
|
|
318
|
+
catch (e) {
|
|
319
|
+
this.logger.warn(`parse error: ${e}`, { data });
|
|
320
|
+
throw e;
|
|
321
|
+
}
|
|
322
|
+
if (!dataUpsert) {
|
|
323
|
+
throw new Error(`Invalid post data - ${JSON.stringify(data)}`);
|
|
324
|
+
}
|
|
325
|
+
dataUpsert.post_date = data.post_date;
|
|
326
|
+
dataUpsert.post_date_gmt = data.post_date_gmt;
|
|
327
|
+
let trx = await this.database.transaction;
|
|
328
|
+
try {
|
|
329
|
+
if (update) {
|
|
330
|
+
await trx
|
|
331
|
+
.table(this.tables.get("posts"))
|
|
332
|
+
.where("ID", data.ID)
|
|
333
|
+
.update(dataUpsert);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
await trx
|
|
337
|
+
.insert(dataUpsert)
|
|
338
|
+
.into(this.tables.get("posts"))
|
|
339
|
+
.then((v) => {
|
|
340
|
+
data.ID = v[0];
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
catch (e) {
|
|
345
|
+
await trx.rollback();
|
|
346
|
+
throw new Error(`Failed to insert post - ${e}`);
|
|
347
|
+
}
|
|
348
|
+
await trx.commit();
|
|
349
|
+
const post = await this.postUtil.get(data.ID);
|
|
350
|
+
if (!post.props) {
|
|
351
|
+
throw new Error(`Post Not Found - ${data.ID}`);
|
|
352
|
+
}
|
|
353
|
+
const postId = post.props.ID;
|
|
354
|
+
// Set slug with title
|
|
355
|
+
if (0 >= data.post_name.length &&
|
|
356
|
+
!["draft", "pending", "auto-draft"].includes(data.post_status)) {
|
|
357
|
+
data.post_name = await this.postUtil.getUniqueSlug(common_1.formatting.slug(data.post_title), post);
|
|
358
|
+
trx = await this.database.transaction;
|
|
359
|
+
try {
|
|
360
|
+
await trx.table(this.tables.get("posts")).where("ID", postId).update({
|
|
361
|
+
post_name: data.post_name,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch (e) {
|
|
365
|
+
await trx.rollback();
|
|
366
|
+
throw new Error(`Failed to update slug - ${e}`);
|
|
367
|
+
}
|
|
368
|
+
await trx.commit();
|
|
369
|
+
}
|
|
370
|
+
// Sync categories
|
|
371
|
+
const taxonomyCategory = await this.taxonomyUtil.get("category");
|
|
372
|
+
if (!taxonomyCategory.isDefault &&
|
|
373
|
+
taxonomyCategory.props?.objectType == data.post_type) {
|
|
374
|
+
await this.syncCategories(post.props.ID, data.post_categeory);
|
|
375
|
+
}
|
|
376
|
+
// Sync tags
|
|
377
|
+
const taxonomyPostTag = await this.taxonomyUtil.get("post_tag");
|
|
378
|
+
if (data.tags_input &&
|
|
379
|
+
!taxonomyPostTag.isDefault &&
|
|
380
|
+
taxonomyPostTag.props?.objectType == data.post_type) {
|
|
381
|
+
await this.syncTerms(postId, data.tags_input);
|
|
382
|
+
}
|
|
383
|
+
let taxonomyInput = data.tax_input;
|
|
384
|
+
// Add default term for all associated custom taxonomies.
|
|
385
|
+
if ("auto-draft" !== data.post_status) {
|
|
386
|
+
for (const taxonomy of await this.taxonomyUtil.getList({
|
|
387
|
+
objectType: post.props.post_type,
|
|
388
|
+
})) {
|
|
389
|
+
if (!taxonomy.props?.default_term) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
// Filter out empty terms.
|
|
393
|
+
if (taxonomyInput && taxonomyInput[taxonomy.name]) {
|
|
394
|
+
taxonomyInput[taxonomy.name] = taxonomyInput[taxonomy.name].filter((v) => typeof v == "number" || v.length > 0);
|
|
395
|
+
}
|
|
396
|
+
// Passed custom taxonomy list overwrites the existing list if not empty.
|
|
397
|
+
const terms = ((await this.components.get(query_util_1.QueryUtil).terms((query) => {
|
|
398
|
+
query.withObjectIds([postId]).where("taxonomy", taxonomy.name);
|
|
399
|
+
})) ?? []).map((v) => v.term_id);
|
|
400
|
+
if (terms.length > 0 &&
|
|
401
|
+
(!taxonomyInput || !taxonomyInput[taxonomy.name])) {
|
|
402
|
+
taxonomyInput = { ...taxonomyInput, [taxonomy.name]: terms };
|
|
403
|
+
}
|
|
404
|
+
// Set default term id
|
|
405
|
+
if (taxonomy.props.default_term &&
|
|
406
|
+
(!taxonomyInput || !taxonomyInput[taxonomy.name])) {
|
|
407
|
+
taxonomyInput = {
|
|
408
|
+
...taxonomyInput,
|
|
409
|
+
[taxonomy.name]: [taxonomy.props.default_term],
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
for (const [taxonomyName, tags] of Object.entries(taxonomyInput ?? {})) {
|
|
415
|
+
const taxonomy = await this.taxonomyUtil.get(taxonomyName);
|
|
416
|
+
if (taxonomy.isDefault) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (taxonomy.props?.capabilities?.["assign_terms"] &&
|
|
420
|
+
(await current.user?.can(taxonomy.props?.capabilities["assign_terms"]))) {
|
|
421
|
+
await this.syncTerms(postId, tags, taxonomy.name);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
425
|
+
const metaInput = data.meta_input;
|
|
426
|
+
if (metaInput) {
|
|
427
|
+
for (const [key, value] of Object.entries(metaInput)) {
|
|
428
|
+
await metaTrx.upsert("post", postId, key, value, {
|
|
429
|
+
serialize: typeof value == "object" || Array.isArray(value),
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// Set GUID.
|
|
434
|
+
if (0 >= post.props.guid.length) {
|
|
435
|
+
const linkUtil = this.components.get(link_util_1.LinkUtil);
|
|
436
|
+
trx = await this.database.transaction;
|
|
437
|
+
try {
|
|
438
|
+
await trx
|
|
439
|
+
.table(this.tables.get("posts"))
|
|
440
|
+
.where("ID", postId)
|
|
441
|
+
.update({
|
|
442
|
+
guid: await linkUtil.getPermalink(post),
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
catch (e) {
|
|
446
|
+
await trx.rollback();
|
|
447
|
+
throw new Error(`Failed to udpate guid - ${e}`);
|
|
448
|
+
}
|
|
449
|
+
await trx.commit();
|
|
450
|
+
}
|
|
451
|
+
if ("attachment" === data.post_type) {
|
|
452
|
+
if (0 < data.file.length) {
|
|
453
|
+
await this.syncAttachedFile(postId, data.file);
|
|
454
|
+
}
|
|
455
|
+
if (0 < data.context.length) {
|
|
456
|
+
await metaTrx.upsert("post", postId, "_wp_attachment_context", data.context);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return postId;
|
|
460
|
+
}
|
|
461
|
+
// wp_delete_post
|
|
462
|
+
async remove(postId, force = false) {
|
|
463
|
+
const EMPTY_TRASH_DAYS = this.config.config.constants.EMPTY_TRASH_DAYS;
|
|
464
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
465
|
+
const posts = await queryUtil.posts((query) => {
|
|
466
|
+
query.where("ID", postId);
|
|
467
|
+
});
|
|
468
|
+
if (!posts) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
const post = await this.postUtil.get(postId);
|
|
472
|
+
if (!post.props) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
const postType = post.props.post_type;
|
|
476
|
+
if (!force &&
|
|
477
|
+
("post" === postType || "page" === postType) &&
|
|
478
|
+
"trash" === (await this.postUtil.getStatus(post)) &&
|
|
479
|
+
EMPTY_TRASH_DAYS > 0) {
|
|
480
|
+
return await this.trash(postId);
|
|
481
|
+
}
|
|
482
|
+
if ("attachment" === postType) {
|
|
483
|
+
return await this.removeAttachment(postId, force);
|
|
484
|
+
}
|
|
485
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
486
|
+
await metaTrx.remove("post", {
|
|
487
|
+
objectId: postId,
|
|
488
|
+
key: "_wp_trash_meta_status",
|
|
489
|
+
});
|
|
490
|
+
await metaTrx.remove("post", {
|
|
491
|
+
objectId: postId,
|
|
492
|
+
key: "_wp_trash_meta_time",
|
|
493
|
+
});
|
|
494
|
+
const taxonomyUtil = this.components.get(taxonomy_util_1.TaxonomyUtil);
|
|
495
|
+
const taxonomies = await taxonomyUtil.getList({
|
|
496
|
+
objectType: postType,
|
|
497
|
+
});
|
|
498
|
+
const termTrx = this.components.get(term_trx_1.TermTrx);
|
|
499
|
+
await termTrx.removeObjectTermRelationships(postId, taxonomies.map((taxonomy) => taxonomy.name));
|
|
500
|
+
const postTypeObject = this.postUtil.getTypeObject(postType);
|
|
501
|
+
if (postTypeObject?.hierarchical) {
|
|
502
|
+
// Point children of this page to its parent, also clean the cache of affected children.
|
|
503
|
+
const children = await queryUtil.posts((query) => {
|
|
504
|
+
query.where("ID", postId).where("post_type", postType);
|
|
505
|
+
});
|
|
506
|
+
if (children) {
|
|
507
|
+
const trx = await this.database.transaction;
|
|
508
|
+
try {
|
|
509
|
+
await trx
|
|
510
|
+
.table(this.tables.get("posts"))
|
|
511
|
+
.where("post_parent", postId)
|
|
512
|
+
.where("post_type", postType)
|
|
513
|
+
.update({
|
|
514
|
+
post_parent: post.props.post_parent,
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
catch (e) {
|
|
518
|
+
await trx.rollback();
|
|
519
|
+
throw new Error(`Failed to update post - ${e}`);
|
|
520
|
+
}
|
|
521
|
+
await trx.commit();
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const revisionsIds = ((await queryUtil.posts((query) => {
|
|
525
|
+
query.where("post_parent", postId).where("post_type", "revision");
|
|
526
|
+
})) ?? []).map((post) => post.ID);
|
|
527
|
+
const revisionTrx = this.components.get(revision_trx_1.RevisionTrx);
|
|
528
|
+
for (const revisionId of revisionsIds) {
|
|
529
|
+
await revisionTrx.remove(revisionId);
|
|
530
|
+
}
|
|
531
|
+
// Point all attachments to this post up one level.
|
|
532
|
+
let trx = await this.database.transaction;
|
|
533
|
+
try {
|
|
534
|
+
await trx
|
|
535
|
+
.table(this.tables.get("posts"))
|
|
536
|
+
.where("post_parent", postId)
|
|
537
|
+
.where("post_type", "attachment")
|
|
538
|
+
.update({
|
|
539
|
+
post_parent: post.props.post_parent,
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
catch (e) {
|
|
543
|
+
await trx.rollback();
|
|
544
|
+
throw new Error(`Failed to update attachment - ${e} `);
|
|
545
|
+
}
|
|
546
|
+
await trx.commit();
|
|
547
|
+
const commentIds = ((await queryUtil.comments((query) => {
|
|
548
|
+
const { column } = query.alias;
|
|
549
|
+
query
|
|
550
|
+
.where("post_ID", postId)
|
|
551
|
+
.builder.orderBy(column("comments", "comment_ID"), "desc");
|
|
552
|
+
})) ?? []).map((comment) => comment.comment_ID);
|
|
553
|
+
const commentTrx = this.components.get(comment_trx_1.CommentTrx);
|
|
554
|
+
for (const commentId of commentIds) {
|
|
555
|
+
await commentTrx.remove(commentId, true);
|
|
556
|
+
}
|
|
557
|
+
await metaTrx.removeObject("post", postId);
|
|
558
|
+
trx = await this.database.transaction;
|
|
559
|
+
try {
|
|
560
|
+
await trx.table(this.tables.get("posts")).where("ID", postId).del();
|
|
561
|
+
}
|
|
562
|
+
catch (e) {
|
|
563
|
+
await trx.rollback();
|
|
564
|
+
throw new Error(`Failed to delete post - ${e}`);
|
|
565
|
+
}
|
|
566
|
+
await trx.commit();
|
|
567
|
+
return post;
|
|
568
|
+
}
|
|
569
|
+
// wp_insert_attachment
|
|
570
|
+
async insertAttachment(input, args) {
|
|
571
|
+
const { file, parentPostId } = args ?? {};
|
|
572
|
+
input = {
|
|
573
|
+
...input,
|
|
574
|
+
file: file ?? input.file,
|
|
575
|
+
post_parent: parentPostId ?? input.post_parent,
|
|
576
|
+
post_type: "attachment",
|
|
577
|
+
};
|
|
578
|
+
return this.upsert(input);
|
|
579
|
+
}
|
|
580
|
+
// wp_update_attachment_metadata
|
|
581
|
+
async syncAttachmentMetadata(postId, args) {
|
|
582
|
+
const { data, remove = false } = args;
|
|
583
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
584
|
+
const key = "_wp_attachment_metadata";
|
|
585
|
+
if (true !== remove) {
|
|
586
|
+
await metaTrx.upsert("post", postId, key, data, {
|
|
587
|
+
serialize: true,
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
await metaTrx.remove("post", {
|
|
592
|
+
objectId: postId,
|
|
593
|
+
key,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
// wp_delete_attachment
|
|
598
|
+
async removeAttachment(postId, force = false) {
|
|
599
|
+
const EMPTY_TRASH_DAYS = this.config.config.constants.EMPTY_TRASH_DAYS;
|
|
600
|
+
const MEDIA_TRASH = this.config.config.constants.MEDIA_TRASH;
|
|
601
|
+
const post = await this.postUtil.get(postId);
|
|
602
|
+
if (!post.props || "attachment" == post.props.post_status) {
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
if (!force &&
|
|
606
|
+
EMPTY_TRASH_DAYS > 0 &&
|
|
607
|
+
MEDIA_TRASH &&
|
|
608
|
+
"trash" !== post.props.post_status) {
|
|
609
|
+
return await this.trash(postId);
|
|
610
|
+
}
|
|
611
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
612
|
+
await metaTrx.remove("post", {
|
|
613
|
+
objectId: postId,
|
|
614
|
+
key: "_wp_trash_meta_status",
|
|
615
|
+
});
|
|
616
|
+
await metaTrx.remove("post", {
|
|
617
|
+
objectId: postId,
|
|
618
|
+
key: "_wp_trash_meta_time",
|
|
619
|
+
});
|
|
620
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
621
|
+
// const attachmentMeta = await queryUtil.meta(
|
|
622
|
+
// "post",
|
|
623
|
+
// (query) => {
|
|
624
|
+
// query
|
|
625
|
+
// .withIds([postId])
|
|
626
|
+
// .withKeys(["_wp_attachment_metadata"])
|
|
627
|
+
// .builder.first();
|
|
628
|
+
// },
|
|
629
|
+
// val.database.wpPostMeta
|
|
630
|
+
// );
|
|
631
|
+
// const backupSize = await queryUtil.meta(
|
|
632
|
+
// "post",
|
|
633
|
+
// (query) => {
|
|
634
|
+
// query
|
|
635
|
+
// .withIds([postId])
|
|
636
|
+
// .withKeys(["_wp_attachment_backup_sizes"])
|
|
637
|
+
// .builder.first();
|
|
638
|
+
// },
|
|
639
|
+
// val.database.wpPostMeta
|
|
640
|
+
// );
|
|
641
|
+
// const file = await this.postUtil.getAttachedFile(postId);
|
|
642
|
+
// wp_delete_object_term_relationships
|
|
643
|
+
const termTrx = this.components.get(term_trx_1.TermTrx);
|
|
644
|
+
await termTrx.removeObjectTermRelationships(postId, [
|
|
645
|
+
"category",
|
|
646
|
+
"post_tag",
|
|
647
|
+
]);
|
|
648
|
+
//await termTrx.syncObject(postId, [], "category");
|
|
649
|
+
//await termTrx.syncObject(postId, [], "post_tag");
|
|
650
|
+
const taxonomyUtil = this.components.get(taxonomy_util_1.TaxonomyUtil);
|
|
651
|
+
const taxonomies = await taxonomyUtil.getList({
|
|
652
|
+
objectType: post.props.post_type,
|
|
653
|
+
});
|
|
654
|
+
for (const taxonomy of taxonomies) {
|
|
655
|
+
if (!["category", "post_tag"].includes(taxonomy.name)) {
|
|
656
|
+
await termTrx.removeObjectTermRelationships(postId, [taxonomy.name]);
|
|
657
|
+
///await termTrx.syncObject(postId, [], taxonomy.name);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
// Delete all for any posts.
|
|
661
|
+
await metaTrx.remove("post", {
|
|
662
|
+
key: "_thumbnail_id",
|
|
663
|
+
value: `${postId}`,
|
|
664
|
+
deleteAll: true,
|
|
665
|
+
});
|
|
666
|
+
const comments = (await queryUtil.comments((query) => {
|
|
667
|
+
const { column } = query.alias;
|
|
668
|
+
query
|
|
669
|
+
.where("post_ID", postId)
|
|
670
|
+
.builder.orderBy(column("comments", "comment_ID"), "desc");
|
|
671
|
+
})) ?? [];
|
|
672
|
+
const commentTrx = this.components.get(comment_trx_1.CommentTrx);
|
|
673
|
+
for (const comment of comments) {
|
|
674
|
+
await commentTrx.remove(comment.comment_ID, true);
|
|
675
|
+
}
|
|
676
|
+
await metaTrx.removeObject("post", postId);
|
|
677
|
+
const trx = await this.database.transaction;
|
|
678
|
+
try {
|
|
679
|
+
await trx.table(this.tables.get("posts")).where("ID", postId).del();
|
|
680
|
+
}
|
|
681
|
+
catch (e) {
|
|
682
|
+
await trx.rollback();
|
|
683
|
+
throw new Error(`Failed to delete post - ${e}`);
|
|
684
|
+
}
|
|
685
|
+
await trx.commit();
|
|
686
|
+
// wp_delete_attachment_files
|
|
687
|
+
return post;
|
|
688
|
+
}
|
|
689
|
+
// wp_untrash_post
|
|
690
|
+
async untrash(postId) {
|
|
691
|
+
const post = await this.postUtil.get(postId);
|
|
692
|
+
if (!post.props || "trash" !== post.props.post_status) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
const previousStatus = await post.meta.get("_wp_trash_meta_status");
|
|
696
|
+
const newStatus = "attachment" === post.props.post_type
|
|
697
|
+
? "inherit"
|
|
698
|
+
: previousStatus
|
|
699
|
+
? previousStatus
|
|
700
|
+
: "draft";
|
|
701
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
702
|
+
await metaTrx.remove("post", {
|
|
703
|
+
objectId: postId,
|
|
704
|
+
key: "_wp_trash_meta_status",
|
|
705
|
+
});
|
|
706
|
+
await metaTrx.remove("post", {
|
|
707
|
+
objectId: postId,
|
|
708
|
+
key: "_wp_trash_meta_time",
|
|
709
|
+
});
|
|
710
|
+
const postUpdated = await this.upsert({
|
|
711
|
+
ID: postId,
|
|
712
|
+
post_status: newStatus,
|
|
713
|
+
});
|
|
714
|
+
if (!postUpdated) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
await this.untrashComments(post);
|
|
718
|
+
return post;
|
|
719
|
+
}
|
|
720
|
+
// wp_untrash_post_comments
|
|
721
|
+
async untrashComments(postIdOrPost) {
|
|
722
|
+
let post;
|
|
723
|
+
if (typeof postIdOrPost == "number") {
|
|
724
|
+
post = await this.postUtil.get(postIdOrPost);
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
post = postIdOrPost;
|
|
728
|
+
}
|
|
729
|
+
if (!post.props) {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
const postId = post.props.ID;
|
|
733
|
+
const commentStatuses = await post.meta.get("_wp_trash_meta_comments_status");
|
|
734
|
+
if (!commentStatuses) {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
const groupByStatus = new Map();
|
|
738
|
+
for (const [k, v] of Object.entries(commentStatuses)) {
|
|
739
|
+
groupByStatus.set(`${v}`, [
|
|
740
|
+
...(groupByStatus.get(`${v}`) ?? []),
|
|
741
|
+
parseInt(k),
|
|
742
|
+
]);
|
|
743
|
+
}
|
|
744
|
+
for (const [k, v] of groupByStatus.entries()) {
|
|
745
|
+
const trx = await this.database.transaction;
|
|
746
|
+
try {
|
|
747
|
+
await trx
|
|
748
|
+
.table(this.tables.get("comments"))
|
|
749
|
+
.whereIn("comment_ID", v)
|
|
750
|
+
.update({
|
|
751
|
+
comment_approved: k,
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
catch (e) {
|
|
755
|
+
trx.rollback();
|
|
756
|
+
throw new Error(`Failed to update post comments - ${e}`);
|
|
757
|
+
}
|
|
758
|
+
await trx.commit();
|
|
759
|
+
}
|
|
760
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
761
|
+
await metaTrx.remove("post", {
|
|
762
|
+
objectId: postId,
|
|
763
|
+
key: "_wp_trash_meta_comments_status",
|
|
764
|
+
});
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
// wp_trash_post
|
|
768
|
+
async trash(postId) {
|
|
769
|
+
const EMPTY_TRASH_DAYS = this.config.config.constants.EMPTY_TRASH_DAYS;
|
|
770
|
+
const post = await this.postUtil.get(postId);
|
|
771
|
+
if (!post.props || "trash" == post.props.post_status) {
|
|
772
|
+
return undefined;
|
|
773
|
+
}
|
|
774
|
+
if (!EMPTY_TRASH_DAYS) {
|
|
775
|
+
await this.remove(postId);
|
|
776
|
+
return post;
|
|
777
|
+
}
|
|
778
|
+
const previousStatus = post.props.post_status;
|
|
779
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
780
|
+
await metaTrx.upsert("post", postId, "_wp_trash_meta_status", previousStatus);
|
|
781
|
+
await metaTrx.upsert("post", postId, "_wp_trash_meta_time", (0, common_1.currentUnixTimestamp)());
|
|
782
|
+
const postUpdated = await this.upsert({
|
|
783
|
+
ID: postId,
|
|
784
|
+
post_status: "trash",
|
|
785
|
+
});
|
|
786
|
+
if (!postUpdated) {
|
|
787
|
+
return undefined;
|
|
788
|
+
}
|
|
789
|
+
await this.trashComments(postId);
|
|
790
|
+
return post;
|
|
791
|
+
}
|
|
792
|
+
// wp_trash_post_comments
|
|
793
|
+
async trashComments(postOrId) {
|
|
794
|
+
const post = typeof postOrId == "number"
|
|
795
|
+
? await this.postUtil.get(postOrId)
|
|
796
|
+
: postOrId;
|
|
797
|
+
if (!post?.props) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
const postId = post.props.ID;
|
|
801
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
802
|
+
const comments = await queryUtil.comments((query) => {
|
|
803
|
+
query.where("post_ID", postId);
|
|
804
|
+
}, zod_1.z.array(val.database.wpComments.pick({
|
|
805
|
+
comment_ID: true,
|
|
806
|
+
comment_approved: true,
|
|
807
|
+
})));
|
|
808
|
+
if (!comments) {
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
const statuses = {};
|
|
812
|
+
comments.forEach((comments) => {
|
|
813
|
+
statuses[comments.comment_ID] = comments.comment_approved;
|
|
814
|
+
});
|
|
815
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
816
|
+
await metaTrx.upsert("post", postId, "_wp_trash_meta_comments_status", statuses, {
|
|
817
|
+
serialize: true,
|
|
818
|
+
});
|
|
819
|
+
// Set status for all comments to post-trashed.
|
|
820
|
+
const trx = await this.database.transaction;
|
|
821
|
+
let result = 0;
|
|
822
|
+
try {
|
|
823
|
+
await trx
|
|
824
|
+
.table(this.tables.get("comments"))
|
|
825
|
+
.where("comment_post_ID", postId)
|
|
826
|
+
.update({
|
|
827
|
+
comment_approved: "post-trashed",
|
|
828
|
+
})
|
|
829
|
+
.then((v) => {
|
|
830
|
+
result = v;
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
catch (e) {
|
|
834
|
+
trx.rollback();
|
|
835
|
+
throw new Error(`Failed to update post comments - ${e}`);
|
|
836
|
+
}
|
|
837
|
+
await trx.commit();
|
|
838
|
+
return result;
|
|
839
|
+
}
|
|
840
|
+
// update_attached_file
|
|
841
|
+
async syncAttachedFile(postId, file) {
|
|
842
|
+
const post = await this.postUtil.get(postId);
|
|
843
|
+
if (!post.props) {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const staticAssetsPath = this.config.config.staticAssetsPath;
|
|
847
|
+
file = file
|
|
848
|
+
.replace(new RegExp(`^${staticAssetsPath}`), "")
|
|
849
|
+
.replace(/^\/+/, "");
|
|
850
|
+
const metaTrx = this.components.get(meta_trx_1.MetaTrx);
|
|
851
|
+
if (file.length > 0) {
|
|
852
|
+
await metaTrx.upsert("post", postId, "_wp_attached_file", file);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
await metaTrx.remove("post", {
|
|
856
|
+
objectId: postId,
|
|
857
|
+
key: "_wp_attached_file",
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
// wp_set_post_categories
|
|
862
|
+
async syncCategories(postId, namesOrTermIds, append = false) {
|
|
863
|
+
const post = await this.postUtil.get(postId);
|
|
864
|
+
if (!post.props) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (0 >= namesOrTermIds.length) {
|
|
868
|
+
const taxonomy = await this.taxonomyUtil.get("category");
|
|
869
|
+
if (!taxonomy.props?.default_term) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if ("auto-draft" !== post.props.post_status) {
|
|
873
|
+
namesOrTermIds = [taxonomy.props?.default_term];
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
const termTrx = this.components.get(term_trx_1.TermTrx);
|
|
877
|
+
return await termTrx.syncObject(postId, namesOrTermIds, "category", append);
|
|
878
|
+
}
|
|
879
|
+
async syncTerms(postId, slugsOrTermIds, taxonomyName = "post_tag", append = false) {
|
|
880
|
+
const post = await this.postUtil.get(postId);
|
|
881
|
+
if (!post.props) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
/*
|
|
885
|
+
* Hierarchical taxonomies must always pass IDs rather than names so that
|
|
886
|
+
* children with the same names but different parents aren't confused.
|
|
887
|
+
*/
|
|
888
|
+
if (await this.taxonomyUtil.isHierarchical(taxonomyName)) {
|
|
889
|
+
slugsOrTermIds = slugsOrTermIds.map((slugOrTermId) => typeof slugOrTermId == "string" ? parseInt(slugOrTermId) : slugOrTermId);
|
|
890
|
+
}
|
|
891
|
+
const termTrx = this.components.get(term_trx_1.TermTrx);
|
|
892
|
+
return await termTrx.syncObject(postId, slugsOrTermIds, taxonomyName, append);
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
exports.PostTrx = PostTrx;
|
|
896
|
+
exports.PostTrx = PostTrx = __decorate([
|
|
897
|
+
(0, component_1.transactions)(),
|
|
898
|
+
__metadata("design:paramtypes", [database_1.default,
|
|
899
|
+
logger_1.Logger,
|
|
900
|
+
components_1.Components,
|
|
901
|
+
config_1.Config,
|
|
902
|
+
post_util_1.PostUtil,
|
|
903
|
+
taxonomy_util_1.TaxonomyUtil,
|
|
904
|
+
comment_util_1.CommentUtil // private validator: Validator
|
|
905
|
+
])
|
|
906
|
+
], PostTrx);
|