@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,589 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.PostCrud = void 0;
|
|
46
|
+
const zod_1 = require("zod");
|
|
47
|
+
const common_1 = require("../common");
|
|
48
|
+
const diff_1 = require("../common/diff");
|
|
49
|
+
const components_1 = require("../core/components");
|
|
50
|
+
const options_1 = require("../core/options");
|
|
51
|
+
const date_time_util_1 = require("../core/utils/date-time.util");
|
|
52
|
+
const post_util_1 = require("../core/utils/post.util");
|
|
53
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
54
|
+
const taxonomy_util_1 = require("../core/utils/taxonomy.util");
|
|
55
|
+
const component_1 = require("../decorators/component");
|
|
56
|
+
const transactions_1 = require("../transactions");
|
|
57
|
+
const val = __importStar(require("../validators"));
|
|
58
|
+
const crud_1 = require("./crud");
|
|
59
|
+
const error_1 = require("./error");
|
|
60
|
+
const meta_crud_1 = require("./meta.crud");
|
|
61
|
+
const vars_1 = require("../core/vars");
|
|
62
|
+
const revision_util_1 = require("../core/utils/revision.util");
|
|
63
|
+
let PostCrud = class PostCrud extends crud_1.Crud {
|
|
64
|
+
constructor(components) {
|
|
65
|
+
super(components);
|
|
66
|
+
}
|
|
67
|
+
// _wp_translate_postdata
|
|
68
|
+
async translate(data) {
|
|
69
|
+
const postId = data.ID ?? undefined;
|
|
70
|
+
let diffData = {};
|
|
71
|
+
let currentPost = {};
|
|
72
|
+
if (postId) {
|
|
73
|
+
currentPost = (await this.getAsUpsert(postId)).data;
|
|
74
|
+
diffData = (0, diff_1.diffObject)(data, currentPost);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
diffData = structuredClone(data);
|
|
78
|
+
}
|
|
79
|
+
const { user, userId } = await this.getUser();
|
|
80
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
81
|
+
const postType = postUtil.getTypeObject(data.post_type);
|
|
82
|
+
if (postId && !(await user.can("edit_post", postId))) {
|
|
83
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit posts as this user");
|
|
84
|
+
}
|
|
85
|
+
if (!postId && !user.can(postType?.capabilities?.create_posts)) {
|
|
86
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit posts as this user");
|
|
87
|
+
}
|
|
88
|
+
if (userId !== data.post_author &&
|
|
89
|
+
!(await user.can(postType?.capabilities?.edit_others_posts))) {
|
|
90
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit posts as this user");
|
|
91
|
+
}
|
|
92
|
+
if (diffData.post_status &&
|
|
93
|
+
"private" == diffData.post_status &&
|
|
94
|
+
postType?.capabilities?.publish_posts &&
|
|
95
|
+
!(await user.can(postType.capabilities.publish_posts))) {
|
|
96
|
+
data.post_status = currentPost?.post_status ?? "pending";
|
|
97
|
+
}
|
|
98
|
+
const publishedStatuses = ["publish", "future"];
|
|
99
|
+
/*
|
|
100
|
+
* Posts 'submitted for approval' are submitted to $_POST the same as if they were being published.
|
|
101
|
+
* Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
|
|
102
|
+
*/
|
|
103
|
+
if (diffData.post_status &&
|
|
104
|
+
(!data.post_status || publishedStatuses.includes(data.post_status)) &&
|
|
105
|
+
!(await user.can(postType?.capabilities?.publish_posts)) &&
|
|
106
|
+
(!publishedStatuses.includes(currentPost?.post_status ?? "") ||
|
|
107
|
+
!postId ||
|
|
108
|
+
!(await user.can("edit_post", postId)))) {
|
|
109
|
+
data.post_status = "pending";
|
|
110
|
+
}
|
|
111
|
+
if (diffData.post_status && "auto-draft" === currentPost.post_status) {
|
|
112
|
+
data.post_status = "draft";
|
|
113
|
+
}
|
|
114
|
+
if (diffData.post_password &&
|
|
115
|
+
diffData.post_password?.length > 0 &&
|
|
116
|
+
!(await user.can(postType?.capabilities?.publish_posts))) {
|
|
117
|
+
data.post_password = currentPost.post_password ?? "";
|
|
118
|
+
}
|
|
119
|
+
if (diffData.post_categeory && diffData.post_categeory.length > 0) {
|
|
120
|
+
const category = await this.components.get(taxonomy_util_1.TaxonomyUtil).get("category");
|
|
121
|
+
if (!(await user.can(category.props?.capabilities?.assign_terms))) {
|
|
122
|
+
data.post_categeory = currentPost.post_categeory ?? undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return data;
|
|
126
|
+
}
|
|
127
|
+
async formReturnData(post, options) {
|
|
128
|
+
const props = post.props;
|
|
129
|
+
if (!props) {
|
|
130
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid Post");
|
|
131
|
+
}
|
|
132
|
+
const { password, editable } = options;
|
|
133
|
+
if (!editable) {
|
|
134
|
+
props.post_content = common_1.formatting.trimMarkupComments(props.post_content);
|
|
135
|
+
props.post_excerpt = common_1.formatting.trimMarkupComments(props.post_excerpt);
|
|
136
|
+
if (!this.checkPasswordProtectedPost(props, password)) {
|
|
137
|
+
post.props.post_content = "";
|
|
138
|
+
post.props.post_excerpt = "";
|
|
139
|
+
post.props.post_password = "";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const author = await post.author();
|
|
143
|
+
const metas = await post.meta.props();
|
|
144
|
+
// public meta is key without _ prefix
|
|
145
|
+
const publicMetas = Object.entries(metas).reduce((acc, [key, value]) => {
|
|
146
|
+
if (key[0] !== "_") {
|
|
147
|
+
acc[key] = value;
|
|
148
|
+
}
|
|
149
|
+
return acc;
|
|
150
|
+
}, {});
|
|
151
|
+
return {
|
|
152
|
+
...props,
|
|
153
|
+
metas: editable ? metas : publicMetas,
|
|
154
|
+
author: {
|
|
155
|
+
ID: author?.ID,
|
|
156
|
+
display_name: author?.display_name,
|
|
157
|
+
user_nicename: author?.user_nicename,
|
|
158
|
+
},
|
|
159
|
+
tags: ((await post.terms("post_tag")) ?? []).map((term) => ({
|
|
160
|
+
term_id: term.term_id,
|
|
161
|
+
name: term.name,
|
|
162
|
+
slug: term.slug,
|
|
163
|
+
})),
|
|
164
|
+
categories: ((await post.terms("category")) ?? []).map((term) => ({
|
|
165
|
+
term_id: term.term_id,
|
|
166
|
+
name: term.name,
|
|
167
|
+
slug: term.slug,
|
|
168
|
+
})),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async getAsUpsert(postId, defaultValue = {}) {
|
|
172
|
+
const getData = (await this.get(postId, { context: "edit" })).data;
|
|
173
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
174
|
+
const post = await postUtil.get(postId);
|
|
175
|
+
const data = {
|
|
176
|
+
...getData,
|
|
177
|
+
meta_input: await post.meta.props(),
|
|
178
|
+
tags_input: (await post.terms("post_tag"))?.map((tag) => tag.term_id),
|
|
179
|
+
post_categeory: (await post.terms("category"))?.map((category) => category.term_id),
|
|
180
|
+
};
|
|
181
|
+
return this.returnValue(val.trx.postUpsert.parse({ ...data, ...defaultValue }));
|
|
182
|
+
}
|
|
183
|
+
async checkPermission(action, postType, postId) {
|
|
184
|
+
const { user } = await this.getUser();
|
|
185
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
186
|
+
const postTypeObject = postUtil.getTypeObject(postType);
|
|
187
|
+
return (postTypeObject?.capabilities &&
|
|
188
|
+
postTypeObject.capabilities[action] &&
|
|
189
|
+
(await user.can(postTypeObject.capabilities[action], postId)));
|
|
190
|
+
}
|
|
191
|
+
async get(postIdOrSlug, options) {
|
|
192
|
+
const { password = "", context = "view" } = options ?? {};
|
|
193
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
194
|
+
const post = typeof postIdOrSlug == "string"
|
|
195
|
+
? await postUtil.getBySlug(postIdOrSlug)
|
|
196
|
+
: await postUtil.get(postIdOrSlug);
|
|
197
|
+
if (!post?.props?.ID ||
|
|
198
|
+
(options?.postType && post.props.post_type !== options.postType)) {
|
|
199
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `Post not found - ${postIdOrSlug}`);
|
|
200
|
+
}
|
|
201
|
+
const postId = post.props.ID;
|
|
202
|
+
const { user } = await this.getUser();
|
|
203
|
+
const postType = post.props.post_type;
|
|
204
|
+
if (context == "edit" &&
|
|
205
|
+
!(await this.checkPermission("edit_post", postType, postId))) {
|
|
206
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this post");
|
|
207
|
+
}
|
|
208
|
+
// Private post
|
|
209
|
+
if (post.props.post_status == "private" &&
|
|
210
|
+
!(await this.canReadPrivatePosts(postType))) {
|
|
211
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to view this post");
|
|
212
|
+
}
|
|
213
|
+
const role = await user.role();
|
|
214
|
+
if (role.is("anonymous") && post.props.post_status !== "publish") {
|
|
215
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to view this post");
|
|
216
|
+
}
|
|
217
|
+
return this.returnValue(await this.formReturnData(post, {
|
|
218
|
+
password,
|
|
219
|
+
editable: context == "edit",
|
|
220
|
+
}), { protected: post.props.post_password != "" });
|
|
221
|
+
}
|
|
222
|
+
// edit_post
|
|
223
|
+
async update(postId, data) {
|
|
224
|
+
data.ID = postId;
|
|
225
|
+
const currentPost = (await this.getAsUpsert(postId, { context: "edit" }))
|
|
226
|
+
.data;
|
|
227
|
+
data.ID = currentPost.ID;
|
|
228
|
+
data.post_type = currentPost.post_type;
|
|
229
|
+
data.post_mime_type = currentPost.post_mime_type;
|
|
230
|
+
data = await this.translate(data);
|
|
231
|
+
if (data.meta_input) {
|
|
232
|
+
const metaCrud = this.components.get(meta_crud_1.MetaCrud);
|
|
233
|
+
await metaCrud.update("post", postId, data.meta_input, "sync");
|
|
234
|
+
data.meta_input = undefined;
|
|
235
|
+
}
|
|
236
|
+
const postTrx = this.components.get(transactions_1.PostTrx);
|
|
237
|
+
const result = await postTrx.upsert(data);
|
|
238
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
239
|
+
const postType = postUtil.getTypeObject(data.post_type);
|
|
240
|
+
if (postType?.supports.includes("revisions") &&
|
|
241
|
+
data.post_content !== currentPost.post_content) {
|
|
242
|
+
const revisionTrx = this.components.get(transactions_1.RevisionTrx);
|
|
243
|
+
await revisionTrx.save(postId);
|
|
244
|
+
}
|
|
245
|
+
return this.returnValue(result);
|
|
246
|
+
}
|
|
247
|
+
// wp_write_post
|
|
248
|
+
async create(data) {
|
|
249
|
+
if (!data.post_type || !(await this.canEditPosts(data.post_type))) {
|
|
250
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "post_type is not defined or you are not allowed to edit posts in this post type");
|
|
251
|
+
}
|
|
252
|
+
if (data.post_type !== "attachment") {
|
|
253
|
+
data.post_mime_type = "";
|
|
254
|
+
}
|
|
255
|
+
if (data.ID && data.ID > 0) {
|
|
256
|
+
return await this.update(data.ID, val.trx.postUpsert.parse(data));
|
|
257
|
+
}
|
|
258
|
+
data.ID = undefined;
|
|
259
|
+
data = await this.translate(data);
|
|
260
|
+
const postTrx = this.components.get(transactions_1.PostTrx);
|
|
261
|
+
return this.returnValue(await postTrx.upsert(data));
|
|
262
|
+
}
|
|
263
|
+
async delete(postId) {
|
|
264
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
265
|
+
const post = await postUtil.get(postId);
|
|
266
|
+
if (!post.props?.ID) {
|
|
267
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `Post not found - ${postId}`);
|
|
268
|
+
}
|
|
269
|
+
const postType = post.props.post_type;
|
|
270
|
+
if (!(await this.checkPermission("delete_post", postType, postId))) {
|
|
271
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to delete this post");
|
|
272
|
+
}
|
|
273
|
+
const postTrx = this.components.get(transactions_1.PostTrx);
|
|
274
|
+
return this.returnValue(await postTrx.remove(postId, true).then((v) => typeof v !== "undefined"));
|
|
275
|
+
}
|
|
276
|
+
async trashOrUntrash(postId, trash) {
|
|
277
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
278
|
+
const post = await postUtil.get(postId);
|
|
279
|
+
if (!post.props?.ID) {
|
|
280
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `Post not found - ${postId}`);
|
|
281
|
+
}
|
|
282
|
+
const postType = post.props.post_type;
|
|
283
|
+
if (!(await this.checkPermission("edit_post", postType, postId))) {
|
|
284
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this post");
|
|
285
|
+
}
|
|
286
|
+
const postTrx = this.components.get(transactions_1.PostTrx);
|
|
287
|
+
return trash
|
|
288
|
+
? await postTrx.trash(postId).then((v) => typeof v !== "undefined")
|
|
289
|
+
: await postTrx.untrash(postId).then((v) => typeof v !== "undefined");
|
|
290
|
+
}
|
|
291
|
+
async trash(postId) {
|
|
292
|
+
return this.returnValue(await this.trashOrUntrash(postId, true));
|
|
293
|
+
}
|
|
294
|
+
async untrash(postId) {
|
|
295
|
+
return this.returnValue(await this.trashOrUntrash(postId, false));
|
|
296
|
+
}
|
|
297
|
+
async checkAutosavePermission(parent) {
|
|
298
|
+
const { user } = await this.getUser();
|
|
299
|
+
if (!parent.props) {
|
|
300
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid parameters.");
|
|
301
|
+
}
|
|
302
|
+
if (!(await user.can("edit_post", parent.props.ID))) {
|
|
303
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to autosave of this post");
|
|
304
|
+
}
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
// class-wp-rest-autosaves-controller.php create_item
|
|
308
|
+
async autosave(parentId, data) {
|
|
309
|
+
const { user } = await this.getUser();
|
|
310
|
+
const vars = this.components.get(vars_1.Vars);
|
|
311
|
+
vars.DOING_AUTOSAVE = true;
|
|
312
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
313
|
+
const parent = await postUtil.get(parentId);
|
|
314
|
+
await this.checkAutosavePermission(parent);
|
|
315
|
+
data = await this.translate(data);
|
|
316
|
+
data.post_parent = parentId;
|
|
317
|
+
const isDraft = data.post_status == "draft" || data.post_status == "auto-draft";
|
|
318
|
+
let autosaveId;
|
|
319
|
+
if (isDraft && user.props?.ID === data.post_author) {
|
|
320
|
+
/*
|
|
321
|
+
* Draft posts for the same author: autosaving updates the post and does not create a revision.
|
|
322
|
+
* Convert the post object to an array and add slashes, wp_update_post() expects escaped array.
|
|
323
|
+
*/
|
|
324
|
+
const postTrx = this.components.get(transactions_1.PostTrx);
|
|
325
|
+
autosaveId = await postTrx.upsert(common_1.formatting.slash(data));
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
const revisionTrx = this.components.get(transactions_1.RevisionTrx);
|
|
329
|
+
autosaveId = await revisionTrx.autosave(data);
|
|
330
|
+
}
|
|
331
|
+
if (!autosaveId) {
|
|
332
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Failed to autosave post");
|
|
333
|
+
}
|
|
334
|
+
const post = await postUtil.get(autosaveId);
|
|
335
|
+
if (!post.props) {
|
|
336
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Failed to get autosave post after saving");
|
|
337
|
+
}
|
|
338
|
+
return this.returnValue(post.props);
|
|
339
|
+
}
|
|
340
|
+
async getAutosave(parentId) {
|
|
341
|
+
const { user } = await this.getUser();
|
|
342
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
343
|
+
const parent = await postUtil.get(parentId);
|
|
344
|
+
await this.checkAutosavePermission(parent);
|
|
345
|
+
const revisionUtil = this.components.get(revision_util_1.RevisionUtil);
|
|
346
|
+
const autosave = await revisionUtil.getAutosave(parentId, user.props?.ID);
|
|
347
|
+
if (!autosave?.props) {
|
|
348
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, "Autosave not found");
|
|
349
|
+
}
|
|
350
|
+
return await this.getAsUpsert(autosave.props.ID);
|
|
351
|
+
}
|
|
352
|
+
async copy(postId) {
|
|
353
|
+
const { user } = await this.getUser();
|
|
354
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
355
|
+
const post = await postUtil.get(postId);
|
|
356
|
+
if (!post.props || !user.props?.ID) {
|
|
357
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, "Post not found");
|
|
358
|
+
}
|
|
359
|
+
const userId = user.props.ID;
|
|
360
|
+
if (post.props.post_type == "attachment") {
|
|
361
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Sorry, you are not allowed to copy attachments");
|
|
362
|
+
}
|
|
363
|
+
await this.checkPermission("edit_post", post.props.post_type, postId);
|
|
364
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
365
|
+
const postTitle = await (async () => {
|
|
366
|
+
const targetPostTitle = post?.props?.post_type;
|
|
367
|
+
let postTitle = `Copy of ${post?.props?.post_title}`;
|
|
368
|
+
for (let i = 0; i < 10; i++) {
|
|
369
|
+
const copyPosts = await queryUtil.posts((query) => {
|
|
370
|
+
query
|
|
371
|
+
.where("post_title", postTitle)
|
|
372
|
+
.where("post_type", targetPostTitle)
|
|
373
|
+
.builder.limit(1);
|
|
374
|
+
});
|
|
375
|
+
if (!copyPosts) {
|
|
376
|
+
return postTitle;
|
|
377
|
+
}
|
|
378
|
+
postTitle = `Copy of ${post?.props?.post_title} ${i + 2}`;
|
|
379
|
+
}
|
|
380
|
+
const maxSuffix = 10;
|
|
381
|
+
return `Copy of ${post?.props?.post_title} ${Math.floor(Math.random() * (maxSuffix + 999990010 - maxSuffix + 1) + maxSuffix + 1)}`;
|
|
382
|
+
})();
|
|
383
|
+
const postUpsert = (await this.getAsUpsert(postId)).data;
|
|
384
|
+
postUpsert.ID = undefined;
|
|
385
|
+
postUpsert.post_status = "draft";
|
|
386
|
+
postUpsert.post_title = postTitle;
|
|
387
|
+
postUpsert.post_author = userId;
|
|
388
|
+
const copiedPostId = (await this.create(postUpsert)).data;
|
|
389
|
+
return this.returnValue(copiedPostId);
|
|
390
|
+
}
|
|
391
|
+
async list(args, options) {
|
|
392
|
+
const { password = "", postTypes = ["post"], context = "view", countGroupBy: includeCountGroupBy, } = options ?? {};
|
|
393
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
394
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
395
|
+
const parsedArgs = val.crud.postListParams.parse(args ?? {});
|
|
396
|
+
const { user } = await this.getUser();
|
|
397
|
+
const role = await user.role();
|
|
398
|
+
let canReadPrivatePosts = true;
|
|
399
|
+
for (const postType of postTypes) {
|
|
400
|
+
const postTypeObject = postUtil.getTypeObject(postType);
|
|
401
|
+
if (!postTypeObject) {
|
|
402
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, `Invalid post type`);
|
|
403
|
+
}
|
|
404
|
+
if (context == "edit" && !(await this.canEditPosts(postType))) {
|
|
405
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit posts in this post type");
|
|
406
|
+
}
|
|
407
|
+
canReadPrivatePosts =
|
|
408
|
+
canReadPrivatePosts && (await this.canReadPrivatePosts(postType));
|
|
409
|
+
}
|
|
410
|
+
let stickyPostIds = [];
|
|
411
|
+
if (parsedArgs.sticky) {
|
|
412
|
+
try {
|
|
413
|
+
stickyPostIds = zod_1.z
|
|
414
|
+
.array(zod_1.z.number())
|
|
415
|
+
.parse(await this.components
|
|
416
|
+
.get(options_1.Options)
|
|
417
|
+
.get("sticky_posts", { default: (0, common_1.phpSerialize)([]) }));
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
stickyPostIds = [0];
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const protectedPostIds = [];
|
|
424
|
+
const dateTimeUtil = this.components.get(date_time_util_1.DateTimeUtil);
|
|
425
|
+
const buildQuery = (query) => {
|
|
426
|
+
const { column } = query.alias;
|
|
427
|
+
const offset = parsedArgs.offset ?? (parsedArgs.page - 1) * parsedArgs.per_page;
|
|
428
|
+
const limit = parsedArgs.per_page;
|
|
429
|
+
query.builder.offset(offset).limit(limit).groupBy(column("posts", "ID"));
|
|
430
|
+
query.whereIn("post_type", postTypes);
|
|
431
|
+
// Check for mime types
|
|
432
|
+
if (postTypes.includes("attachment") &&
|
|
433
|
+
Array.isArray(options?.mimeTypes)) {
|
|
434
|
+
query.andWhere((query) => {
|
|
435
|
+
for (const mimeType of options.mimeTypes) {
|
|
436
|
+
// Use whereLike if mimeType does not have a slash
|
|
437
|
+
if (!mimeType.includes("/")) {
|
|
438
|
+
query.or.whereLike("post_mime_type", mimeType);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
query.or.where("post_mime_type", mimeType);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
if (parsedArgs.orderby) {
|
|
447
|
+
query.builder.orderBy(column("posts", parsedArgs.orderby), parsedArgs.order);
|
|
448
|
+
}
|
|
449
|
+
if (role.is("anonymous")) {
|
|
450
|
+
query.where("post_status", "publish").andWhere((query) => {
|
|
451
|
+
query.where("post_password", password).or.where("post_password", "");
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
if (!canReadPrivatePosts) {
|
|
455
|
+
query.andWhereNot((query) => query.where("post_status", "private"));
|
|
456
|
+
}
|
|
457
|
+
if (stickyPostIds.length > 0 || Array.isArray(parsedArgs.include)) {
|
|
458
|
+
query.whereIn("ID", [...stickyPostIds, ...(parsedArgs.include ?? [])]);
|
|
459
|
+
}
|
|
460
|
+
if (Array.isArray(parsedArgs.exclude)) {
|
|
461
|
+
query.not.andWhere((query) => query.whereIn("ID", parsedArgs.exclude));
|
|
462
|
+
}
|
|
463
|
+
if (parsedArgs.search) {
|
|
464
|
+
query.andWhere((query) => {
|
|
465
|
+
const searchColumns = [
|
|
466
|
+
"post_title",
|
|
467
|
+
"post_excerpt",
|
|
468
|
+
"post_content",
|
|
469
|
+
];
|
|
470
|
+
for (const searchColumn of searchColumns) {
|
|
471
|
+
parsedArgs.search &&
|
|
472
|
+
query.or.whereLike(searchColumn, parsedArgs.search);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
if (parsedArgs.meta && context == "edit") {
|
|
477
|
+
query
|
|
478
|
+
.withMeta()
|
|
479
|
+
.where("meta_key", parsedArgs.meta.key)
|
|
480
|
+
.where("meta_value", parsedArgs.meta.value);
|
|
481
|
+
}
|
|
482
|
+
if (parsedArgs.exclude_meta && context == "edit") {
|
|
483
|
+
query.withoutMeta(parsedArgs.exclude_meta.key, parsedArgs.exclude_meta.value);
|
|
484
|
+
}
|
|
485
|
+
const taxonomyNames = [];
|
|
486
|
+
for (const key of Object.keys(parsedArgs)) {
|
|
487
|
+
if (!parsedArgs[key] || key == "meta")
|
|
488
|
+
continue;
|
|
489
|
+
const value = parsedArgs[key];
|
|
490
|
+
switch (key) {
|
|
491
|
+
case "after":
|
|
492
|
+
case "before":
|
|
493
|
+
query.where("post_date", dateTimeUtil.get(new Date(value)).mySQLDatetime, key == "after" ? ">=" : "<=");
|
|
494
|
+
break;
|
|
495
|
+
case "modified_after":
|
|
496
|
+
case "modified_before":
|
|
497
|
+
query.where("post_date", dateTimeUtil.get(new Date(value)).mySQLDatetime, key == "modified_after" ? ">=" : "<=");
|
|
498
|
+
break;
|
|
499
|
+
case "author":
|
|
500
|
+
Array.isArray(value) && query.whereIn("post_author", value);
|
|
501
|
+
break;
|
|
502
|
+
case "author_exclude":
|
|
503
|
+
Array.isArray(value) &&
|
|
504
|
+
query.andWhereNot((query) => query.whereIn("post_author", value));
|
|
505
|
+
break;
|
|
506
|
+
case "slug":
|
|
507
|
+
query.where("post_name", value);
|
|
508
|
+
break;
|
|
509
|
+
case "status":
|
|
510
|
+
Array.isArray(value) && query.whereIn("post_status", value);
|
|
511
|
+
break;
|
|
512
|
+
case "status_exclude":
|
|
513
|
+
Array.isArray(value) &&
|
|
514
|
+
query.andWhereNot((query) => query.whereIn("post_status", value));
|
|
515
|
+
break;
|
|
516
|
+
case "categories":
|
|
517
|
+
case "categories_exclude":
|
|
518
|
+
taxonomyNames.push("category");
|
|
519
|
+
break;
|
|
520
|
+
case "tags":
|
|
521
|
+
case "tags_exclude":
|
|
522
|
+
taxonomyNames.push("post_tag");
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (taxonomyNames.length > 0) {
|
|
526
|
+
query.withTerms(taxonomyNames, (query) => {
|
|
527
|
+
query[parsedArgs.tax_relation === "OR" ? "orWhere" : "andWhere"]((query) => {
|
|
528
|
+
if (parsedArgs.categories || parsedArgs.tags) {
|
|
529
|
+
query.whereIn("term_id", [
|
|
530
|
+
...(parsedArgs.categories ?? []),
|
|
531
|
+
...(parsedArgs.tags ?? []),
|
|
532
|
+
]);
|
|
533
|
+
}
|
|
534
|
+
if (parsedArgs.categories_exclude || parsedArgs.tags_exclude) {
|
|
535
|
+
query.andWhereNot((query) => query.whereIn("term_id", [
|
|
536
|
+
...(parsedArgs.categories_exclude ?? []),
|
|
537
|
+
...(parsedArgs.tags_exclude ?? []),
|
|
538
|
+
]));
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
const posts = (await queryUtil.posts((query) => {
|
|
545
|
+
buildQuery(query);
|
|
546
|
+
if (postTypes.includes("attachment")) {
|
|
547
|
+
console.log(query.builder.toString());
|
|
548
|
+
}
|
|
549
|
+
})) ?? [];
|
|
550
|
+
const counts = await queryUtil.posts((query) => {
|
|
551
|
+
buildQuery(query);
|
|
552
|
+
query.count("posts", "ID");
|
|
553
|
+
}, val.query.resultCount);
|
|
554
|
+
const countGroupBy = (includeCountGroupBy
|
|
555
|
+
? await queryUtil.posts((query) => {
|
|
556
|
+
buildQuery(query);
|
|
557
|
+
query
|
|
558
|
+
.where("post_type", postTypes)
|
|
559
|
+
.countGroupby("posts", includeCountGroupBy);
|
|
560
|
+
}, val.query.resultCountGroupBy(includeCountGroupBy))
|
|
561
|
+
: []);
|
|
562
|
+
const data = [];
|
|
563
|
+
for (const post of postUtil.toPosts(posts)) {
|
|
564
|
+
const props = post.props;
|
|
565
|
+
if (props.post_password != "") {
|
|
566
|
+
protectedPostIds.push(props.ID);
|
|
567
|
+
}
|
|
568
|
+
data.push(await this.formReturnData(post, {
|
|
569
|
+
password,
|
|
570
|
+
editable: context == "edit",
|
|
571
|
+
}));
|
|
572
|
+
}
|
|
573
|
+
const pagination = this.pagination({
|
|
574
|
+
page: parsedArgs.page,
|
|
575
|
+
limit: parsedArgs.per_page,
|
|
576
|
+
count: counts?.count ?? 0,
|
|
577
|
+
});
|
|
578
|
+
return this.returnValue(data, {
|
|
579
|
+
pagination,
|
|
580
|
+
protected: protectedPostIds,
|
|
581
|
+
countGroupBy,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
exports.PostCrud = PostCrud;
|
|
586
|
+
exports.PostCrud = PostCrud = __decorate([
|
|
587
|
+
(0, component_1.component)(),
|
|
588
|
+
__metadata("design:paramtypes", [components_1.Components])
|
|
589
|
+
], PostCrud);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Components } from "../core/components";
|
|
3
|
+
import * as val from "../validators";
|
|
4
|
+
import { Crud } from "./crud";
|
|
5
|
+
export declare class RevisionCrud extends Crud {
|
|
6
|
+
constructor(components: Components);
|
|
7
|
+
private checkPermission;
|
|
8
|
+
get(parentId: number, id: number): Promise<{
|
|
9
|
+
data: import("../types").WpPosts;
|
|
10
|
+
info: undefined;
|
|
11
|
+
}>;
|
|
12
|
+
restore(parentId: number, id: number): Promise<{
|
|
13
|
+
data: boolean;
|
|
14
|
+
info: undefined;
|
|
15
|
+
}>;
|
|
16
|
+
list(parentId: number, args: Partial<z.infer<typeof val.crud.revisionListParams>>): Promise<{
|
|
17
|
+
data: [] | [{
|
|
18
|
+
ID: number;
|
|
19
|
+
post_author: number;
|
|
20
|
+
post_content: string;
|
|
21
|
+
post_title: string;
|
|
22
|
+
post_excerpt: string;
|
|
23
|
+
post_status: string;
|
|
24
|
+
comment_status: string;
|
|
25
|
+
ping_status: string;
|
|
26
|
+
post_password: string;
|
|
27
|
+
post_name: string;
|
|
28
|
+
to_ping: string;
|
|
29
|
+
pinged: string;
|
|
30
|
+
post_content_filtered: string;
|
|
31
|
+
post_parent: number;
|
|
32
|
+
guid: string;
|
|
33
|
+
menu_order: number;
|
|
34
|
+
post_type: string;
|
|
35
|
+
post_mime_type: string;
|
|
36
|
+
comment_count: number;
|
|
37
|
+
post_date?: string | undefined;
|
|
38
|
+
post_date_gmt?: string | undefined;
|
|
39
|
+
post_modified?: string | undefined;
|
|
40
|
+
post_modified_gmt?: string | undefined;
|
|
41
|
+
}, ...{
|
|
42
|
+
ID: number;
|
|
43
|
+
post_author: number;
|
|
44
|
+
post_content: string;
|
|
45
|
+
post_title: string;
|
|
46
|
+
post_excerpt: string;
|
|
47
|
+
post_status: string;
|
|
48
|
+
comment_status: string;
|
|
49
|
+
ping_status: string;
|
|
50
|
+
post_password: string;
|
|
51
|
+
post_name: string;
|
|
52
|
+
to_ping: string;
|
|
53
|
+
pinged: string;
|
|
54
|
+
post_content_filtered: string;
|
|
55
|
+
post_parent: number;
|
|
56
|
+
guid: string;
|
|
57
|
+
menu_order: number;
|
|
58
|
+
post_type: string;
|
|
59
|
+
post_mime_type: string;
|
|
60
|
+
comment_count: number;
|
|
61
|
+
post_date?: string | undefined;
|
|
62
|
+
post_date_gmt?: string | undefined;
|
|
63
|
+
post_modified?: string | undefined;
|
|
64
|
+
post_modified_gmt?: string | undefined;
|
|
65
|
+
}[]];
|
|
66
|
+
info: {
|
|
67
|
+
pagination: {
|
|
68
|
+
page: number;
|
|
69
|
+
limit: number;
|
|
70
|
+
totalPage: number;
|
|
71
|
+
count: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=revision.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revision.crud.d.ts","sourceRoot":"","sources":["../../src/crud/revision.crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhD,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,qBACa,YAAa,SAAQ,IAAI;gBACxB,UAAU,EAAE,UAAU;YAIpB,eAAe;IAoBvB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;IAgBhC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;IAqCpC,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqE7D"}
|