@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,431 @@
|
|
|
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.CommentCrud = void 0;
|
|
46
|
+
const common_1 = require("../common");
|
|
47
|
+
const diff_1 = require("../common/diff");
|
|
48
|
+
const components_1 = require("../core/components");
|
|
49
|
+
const options_1 = require("../core/options");
|
|
50
|
+
const comment_util_1 = require("../core/utils/comment.util");
|
|
51
|
+
const post_util_1 = require("../core/utils/post.util");
|
|
52
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
53
|
+
const component_1 = require("../decorators/component");
|
|
54
|
+
const transactions_1 = require("../transactions");
|
|
55
|
+
const val = __importStar(require("../validators"));
|
|
56
|
+
const crud_1 = require("./crud");
|
|
57
|
+
const error_1 = require("./error");
|
|
58
|
+
let CommentCrud = class CommentCrud extends crud_1.Crud {
|
|
59
|
+
commentUtil;
|
|
60
|
+
postUtil;
|
|
61
|
+
constructor(components, commentUtil, postUtil) {
|
|
62
|
+
super(components);
|
|
63
|
+
this.commentUtil = commentUtil;
|
|
64
|
+
this.postUtil = postUtil;
|
|
65
|
+
}
|
|
66
|
+
async canReadPostComment(post, password) {
|
|
67
|
+
if (!post.props) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const { user } = await this.getUser();
|
|
71
|
+
const postType = this.postUtil.getTypeObject(post.props?.post_type);
|
|
72
|
+
if (!postType) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return (this.checkPasswordProtectedPost(post.props, password ?? "") ||
|
|
76
|
+
(await this.canReadPost(post.props)) ||
|
|
77
|
+
(await user.can("edit_post", post.props?.ID)));
|
|
78
|
+
}
|
|
79
|
+
async canRead(comment) {
|
|
80
|
+
const { user } = await this.getUser();
|
|
81
|
+
if (!user.props) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (comment.props?.comment_post_ID) {
|
|
85
|
+
const post = await this.postUtil.get(comment.props.comment_post_ID);
|
|
86
|
+
if (post.props &&
|
|
87
|
+
(await this.canReadPost(post.props)) &&
|
|
88
|
+
`${comment.props.comment_approved}` == "1") {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!comment.props?.comment_post_ID &&
|
|
93
|
+
!(await user.can("moderate_comments"))) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (comment.props?.user_id && user.props.ID === comment.props.user_id) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return (comment.props?.comment_ID &&
|
|
100
|
+
(await user.can("edit_comment", comment.props.comment_ID)));
|
|
101
|
+
}
|
|
102
|
+
async canEdit(commentId) {
|
|
103
|
+
if (!(await this.commentUtil.get(commentId)).props) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const { user } = await this.getUser();
|
|
107
|
+
const role = await user.role();
|
|
108
|
+
if (role.is("anonymous")) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return ((await user.can("moderate_comments")) ||
|
|
112
|
+
(await user.can("edit_comment", commentId)));
|
|
113
|
+
}
|
|
114
|
+
async formReturnData(comment, context, options) {
|
|
115
|
+
const { limitChildren = 99 } = options ?? {};
|
|
116
|
+
const props = comment.props;
|
|
117
|
+
const parentComment = await comment.parent();
|
|
118
|
+
const user = await comment.user();
|
|
119
|
+
const post = await comment.post();
|
|
120
|
+
const children = await comment.children(limitChildren);
|
|
121
|
+
const countChildren = await comment.countChildren();
|
|
122
|
+
if ("edit" === context) {
|
|
123
|
+
return {
|
|
124
|
+
...props,
|
|
125
|
+
post_comment_count: post?.comment_count,
|
|
126
|
+
post_title: post?.post_title,
|
|
127
|
+
post_type: post?.post_type,
|
|
128
|
+
post_guid: post?.guid,
|
|
129
|
+
user_display_name: user?.display_name,
|
|
130
|
+
parent_comment_author: parentComment?.comment_author,
|
|
131
|
+
parent_user_display_name: parentComment?.display_name,
|
|
132
|
+
parent_user_id: parentComment?.user_id,
|
|
133
|
+
children,
|
|
134
|
+
count_children: countChildren,
|
|
135
|
+
metas: await comment.meta.props(),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return {
|
|
140
|
+
comment_ID: props.comment_ID,
|
|
141
|
+
comment_post_ID: props.comment_post_ID,
|
|
142
|
+
comment_author: props.comment_author,
|
|
143
|
+
comment_author_email: props.comment_author_email,
|
|
144
|
+
comment_date: props.comment_date,
|
|
145
|
+
comment_date_gmt: props.comment_date_gmt,
|
|
146
|
+
comment_content: props.comment_content,
|
|
147
|
+
comment_parent: props.comment_parent,
|
|
148
|
+
comment_approved: props.comment_approved,
|
|
149
|
+
comment_type: props.comment_type,
|
|
150
|
+
post_comment_count: post?.comment_count,
|
|
151
|
+
post_title: post?.post_title,
|
|
152
|
+
post_type: post?.post_type,
|
|
153
|
+
post_guid: post?.guid,
|
|
154
|
+
post_author: post?.post_author,
|
|
155
|
+
post_status: post?.post_status,
|
|
156
|
+
parent_comment_author: parentComment?.comment_author,
|
|
157
|
+
parent_user_id: parentComment?.user_id,
|
|
158
|
+
parent_user_display_name: parentComment?.display_name,
|
|
159
|
+
user_id: props.user_id,
|
|
160
|
+
user_display_name: user?.display_name,
|
|
161
|
+
children,
|
|
162
|
+
count_children: countChildren,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async getAsUpsert(commentId) {
|
|
167
|
+
const comment = (await this.get(commentId, { context: "edit" })).data;
|
|
168
|
+
return this.returnValue(val.trx.commentUpsert.parse(comment));
|
|
169
|
+
}
|
|
170
|
+
async get(commentId, options) {
|
|
171
|
+
const { password = "", context = "view" } = options ?? {};
|
|
172
|
+
const comment = await this.commentUtil.get(commentId);
|
|
173
|
+
if (!comment.props) {
|
|
174
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, "Comment not found");
|
|
175
|
+
}
|
|
176
|
+
const { user } = await this.getUser();
|
|
177
|
+
if (context == "edit" && !(await user.can("moderate_comments"))) {
|
|
178
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit comments");
|
|
179
|
+
}
|
|
180
|
+
if (!(await this.canRead(comment))) {
|
|
181
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to read comments");
|
|
182
|
+
}
|
|
183
|
+
const post = await this.postUtil.get(comment.props.comment_post_ID);
|
|
184
|
+
if (post.props && !(await this.canReadPostComment(post, password))) {
|
|
185
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to read the post for this comment");
|
|
186
|
+
}
|
|
187
|
+
return this.returnValue((await this.formReturnData(comment, context)));
|
|
188
|
+
}
|
|
189
|
+
async create(data, options) {
|
|
190
|
+
const { remoteIp } = options ?? {};
|
|
191
|
+
const { user, userId } = await this.getUser();
|
|
192
|
+
const role = await user.role();
|
|
193
|
+
if (!role.is("anonymous") || !user.props) {
|
|
194
|
+
const options = this.components.get(options_1.Options);
|
|
195
|
+
if (await options.get("comment_registration")) {
|
|
196
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you must be logged in to comment");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Limit who can set comment `author`, `author_ip` or `status` to anything other than the default.
|
|
200
|
+
if (data.user_id &&
|
|
201
|
+
userId !== data.user_id &&
|
|
202
|
+
(await user.can("moderate_comments"))) {
|
|
203
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this comment");
|
|
204
|
+
}
|
|
205
|
+
if (data.comment_author_IP &&
|
|
206
|
+
!(await user.can("moderate_comments")) &&
|
|
207
|
+
(!remoteIp || data.comment_author_IP !== remoteIp)) {
|
|
208
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this comment");
|
|
209
|
+
}
|
|
210
|
+
if (data.comment_approved && !(await user.can("moderate_comments"))) {
|
|
211
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this comment");
|
|
212
|
+
}
|
|
213
|
+
if (!data.comment_post_ID) {
|
|
214
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to create this comment without a post");
|
|
215
|
+
}
|
|
216
|
+
const post = await this.postUtil.get(data.comment_post_ID);
|
|
217
|
+
if (!post.props ||
|
|
218
|
+
"draft" === post.props.post_status ||
|
|
219
|
+
"trash" === post.props.post_status ||
|
|
220
|
+
!this.canReadPostComment(post) ||
|
|
221
|
+
!this.commentUtil.isOpen(post)) {
|
|
222
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to create a comment on this post");
|
|
223
|
+
}
|
|
224
|
+
if (data.comment_ID) {
|
|
225
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Cannot create existing comment");
|
|
226
|
+
}
|
|
227
|
+
// Do not allow comments to be created with a non-default type.
|
|
228
|
+
if (data.comment_type &&
|
|
229
|
+
data.comment_type?.length > 0 &&
|
|
230
|
+
"comment" !== data.comment_type) {
|
|
231
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Cannot create a comment with that type");
|
|
232
|
+
}
|
|
233
|
+
if (!data.comment_content || data.comment_content == "") {
|
|
234
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid comment content");
|
|
235
|
+
}
|
|
236
|
+
// Set author data if the user's logged in.
|
|
237
|
+
if (user.props &&
|
|
238
|
+
0 >=
|
|
239
|
+
[
|
|
240
|
+
"user_id",
|
|
241
|
+
"comment_author",
|
|
242
|
+
"comment_author_email",
|
|
243
|
+
"comment_author_url",
|
|
244
|
+
].filter((k) => data[k] && (data[k]?.toString() ?? "").length > 0)
|
|
245
|
+
.length) {
|
|
246
|
+
data = {
|
|
247
|
+
...data,
|
|
248
|
+
user_id: user.props.ID,
|
|
249
|
+
comment_author: user.props.display_name,
|
|
250
|
+
comment_author_email: user.props.user_email,
|
|
251
|
+
comment_author_url: user.props.user_url,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
// Honor the discussion setting that requires a name and email address of the comment author.
|
|
255
|
+
const optionsCore = this.components.get(options_1.Options);
|
|
256
|
+
if ((!data.comment_author_email || 0 >= data.comment_author_email.length) &&
|
|
257
|
+
(!data.comment_author || 0 >= data.comment_author.length) &&
|
|
258
|
+
(await optionsCore.get("require_name_email"))) {
|
|
259
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Creating a comment requires valid author name and email values.");
|
|
260
|
+
}
|
|
261
|
+
data.comment_approved = await this.commentUtil.getStatus(data);
|
|
262
|
+
const commentTrx = this.components.get(transactions_1.CommentTrx);
|
|
263
|
+
return this.returnValue(await commentTrx.upsert(data));
|
|
264
|
+
}
|
|
265
|
+
async update(commentId, data) {
|
|
266
|
+
if (!(await this.canEdit(commentId))) {
|
|
267
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this comment");
|
|
268
|
+
}
|
|
269
|
+
data.comment_ID = commentId;
|
|
270
|
+
const currentComment = (await this.getAsUpsert(commentId)).data;
|
|
271
|
+
if (currentComment.comment_type !== data.comment_type) {
|
|
272
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to change the comment type");
|
|
273
|
+
}
|
|
274
|
+
const diffData = (0, diff_1.diffObject)(data, currentComment);
|
|
275
|
+
const postId = diffData.comment_post_ID ?? currentComment.comment_post_ID;
|
|
276
|
+
if (postId && postId > 0) {
|
|
277
|
+
const post = await this.postUtil.get(postId);
|
|
278
|
+
if (!post.props) {
|
|
279
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid post ID");
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const commentTrx = this.components.get(transactions_1.CommentTrx);
|
|
283
|
+
return this.returnValue(await commentTrx.upsert(data));
|
|
284
|
+
}
|
|
285
|
+
async delete(commentId, force = false) {
|
|
286
|
+
if (!(await this.canEdit(commentId))) {
|
|
287
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to delete this comment");
|
|
288
|
+
}
|
|
289
|
+
const commentTrx = this.components.get(transactions_1.CommentTrx);
|
|
290
|
+
return this.returnValue(await commentTrx.remove(commentId, force));
|
|
291
|
+
}
|
|
292
|
+
async list(args, options) {
|
|
293
|
+
const { context = "view", password, limitChildren } = options ?? {};
|
|
294
|
+
const { user } = await this.getUser();
|
|
295
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
296
|
+
const parsedArgs = val.crud.commentListParams.parse(args ?? {});
|
|
297
|
+
if (parsedArgs.post) {
|
|
298
|
+
for (const postId of parsedArgs.post) {
|
|
299
|
+
const post = await this.postUtil.get(postId);
|
|
300
|
+
if (!post.props ||
|
|
301
|
+
!(await this.canReadPost(post.props)) ||
|
|
302
|
+
!(await this.canReadPostComment(post, password))) {
|
|
303
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to read the post for this comment");
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (context == "edit" && !(await user.can("moderate_comments"))) {
|
|
308
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit comments");
|
|
309
|
+
}
|
|
310
|
+
if (!(await user.can("edit_posts"))) {
|
|
311
|
+
const protectedParams = [
|
|
312
|
+
"author",
|
|
313
|
+
"author_exclude",
|
|
314
|
+
"author_email",
|
|
315
|
+
"type",
|
|
316
|
+
"status",
|
|
317
|
+
];
|
|
318
|
+
for (const param of protectedParams) {
|
|
319
|
+
switch (param) {
|
|
320
|
+
case "status":
|
|
321
|
+
if ("approve" !== parsedArgs[param]) {
|
|
322
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Query parameter not permitted");
|
|
323
|
+
}
|
|
324
|
+
break;
|
|
325
|
+
case "type":
|
|
326
|
+
if ("comment" !== parsedArgs[param]) {
|
|
327
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Query parameter not permitted");
|
|
328
|
+
}
|
|
329
|
+
break;
|
|
330
|
+
default:
|
|
331
|
+
if (parsedArgs[param]) {
|
|
332
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, `Query parameter not permitted - ${param} ${parsedArgs[param]}`);
|
|
333
|
+
}
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const buildQuery = (query) => {
|
|
339
|
+
const { column } = query.alias;
|
|
340
|
+
const offset = (parsedArgs.page - 1) * parsedArgs.per_page;
|
|
341
|
+
const limit = parsedArgs.per_page;
|
|
342
|
+
query.builder
|
|
343
|
+
.offset(offset)
|
|
344
|
+
.limit(limit)
|
|
345
|
+
.groupBy(column("comments", "comment_ID"));
|
|
346
|
+
if (parsedArgs.orderby) {
|
|
347
|
+
query.builder.orderBy(column("comments", parsedArgs.orderby), parsedArgs.order);
|
|
348
|
+
}
|
|
349
|
+
if (parsedArgs.search) {
|
|
350
|
+
query.andWhere((query) => {
|
|
351
|
+
const searchColumns = [
|
|
352
|
+
"author",
|
|
353
|
+
"author_email",
|
|
354
|
+
"author_url",
|
|
355
|
+
"author_IP",
|
|
356
|
+
"content",
|
|
357
|
+
];
|
|
358
|
+
for (const searchColumn of searchColumns) {
|
|
359
|
+
parsedArgs.search &&
|
|
360
|
+
query.or.whereLike(searchColumn, parsedArgs.search);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
for (const key of Object.keys(parsedArgs)) {
|
|
365
|
+
const value = parsedArgs[key];
|
|
366
|
+
if (!value)
|
|
367
|
+
continue;
|
|
368
|
+
switch (key) {
|
|
369
|
+
case "after":
|
|
370
|
+
case "before":
|
|
371
|
+
query.where("date", common_1.formatting.dateMySQL(value), key == "after" ? ">=" : "<=");
|
|
372
|
+
break;
|
|
373
|
+
case "author":
|
|
374
|
+
query.whereIn("user_id", value);
|
|
375
|
+
break;
|
|
376
|
+
case "author_exclude":
|
|
377
|
+
query.andWhereNot((query) => query.whereIn("user_id", value));
|
|
378
|
+
break;
|
|
379
|
+
case "author_email":
|
|
380
|
+
query.where("author_email", value);
|
|
381
|
+
break;
|
|
382
|
+
case "include":
|
|
383
|
+
query.whereIn("ID", value);
|
|
384
|
+
break;
|
|
385
|
+
case "exclude":
|
|
386
|
+
query.andWhereNot((query) => query.whereIn("ID", value));
|
|
387
|
+
break;
|
|
388
|
+
case "parent":
|
|
389
|
+
query.whereIn("parent", value);
|
|
390
|
+
break;
|
|
391
|
+
case "parent_exclude":
|
|
392
|
+
query.andWhereNot((query) => query.whereIn("parent", value));
|
|
393
|
+
break;
|
|
394
|
+
case "post":
|
|
395
|
+
query.whereIn("post_ID", value);
|
|
396
|
+
break;
|
|
397
|
+
case "type":
|
|
398
|
+
query.where("type", value);
|
|
399
|
+
break;
|
|
400
|
+
case "status":
|
|
401
|
+
query.whereIn("approved", value == "approve" ? ["1", "approve"] : [`${value}`]);
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
const comments = (await queryUtil.comments((query) => {
|
|
407
|
+
buildQuery(query);
|
|
408
|
+
})) ?? [];
|
|
409
|
+
const counts = await queryUtil.comments((query) => {
|
|
410
|
+
buildQuery(query);
|
|
411
|
+
query.count("comments", "comment_ID");
|
|
412
|
+
}, val.query.resultCount);
|
|
413
|
+
const data = [];
|
|
414
|
+
for (const comment of this.commentUtil.toComments(comments)) {
|
|
415
|
+
data.push(await this.formReturnData(comment, context, { limitChildren }));
|
|
416
|
+
}
|
|
417
|
+
const pagination = this.pagination({
|
|
418
|
+
page: parsedArgs.page,
|
|
419
|
+
limit: parsedArgs.per_page,
|
|
420
|
+
count: counts?.count ?? 0,
|
|
421
|
+
});
|
|
422
|
+
return this.returnValue(data, { pagination });
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
exports.CommentCrud = CommentCrud;
|
|
426
|
+
exports.CommentCrud = CommentCrud = __decorate([
|
|
427
|
+
(0, component_1.component)(),
|
|
428
|
+
__metadata("design:paramtypes", [components_1.Components,
|
|
429
|
+
comment_util_1.CommentUtil,
|
|
430
|
+
post_util_1.PostUtil])
|
|
431
|
+
], CommentCrud);
|
package/crud/crud.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Components } from "../core/components";
|
|
2
|
+
import { User } from "../core/user";
|
|
3
|
+
import * as types from "../types";
|
|
4
|
+
import { CrudError } from "./error";
|
|
5
|
+
export declare abstract class Crud {
|
|
6
|
+
protected components: Components;
|
|
7
|
+
constructor(components: Components);
|
|
8
|
+
protected getUser(): Promise<{
|
|
9
|
+
user: User;
|
|
10
|
+
userId: number | undefined;
|
|
11
|
+
userProps: types.WpUsers | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
private checkPostsPermission;
|
|
14
|
+
private originalBlogId;
|
|
15
|
+
private originalSiteId;
|
|
16
|
+
protected switchBlog(args: {
|
|
17
|
+
siteId?: number;
|
|
18
|
+
blogId?: number;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
protected restoreBlog(): Promise<void>;
|
|
21
|
+
protected getAvailableBlogs(args: {
|
|
22
|
+
blogIds?: number[];
|
|
23
|
+
siteIds?: number[];
|
|
24
|
+
canArgs: Parameters<InstanceType<typeof User>["can"]>[];
|
|
25
|
+
}): Promise<[{
|
|
26
|
+
blog_id: number;
|
|
27
|
+
site_id: number;
|
|
28
|
+
}[], CrudError[]]>;
|
|
29
|
+
protected checkBlogsPermission(args: {
|
|
30
|
+
blogIds?: number[];
|
|
31
|
+
siteIds?: number[];
|
|
32
|
+
canArgs: Parameters<InstanceType<typeof User>["can"]>[];
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
protected canEditPosts(postType: string, defaultUser?: User): Promise<boolean>;
|
|
35
|
+
protected canDeletePosts(postType: string, defaultUser?: User): Promise<boolean>;
|
|
36
|
+
protected canReadPrivatePosts(postType: string, defaultUser?: User): Promise<boolean>;
|
|
37
|
+
protected canReadPost(post: types.WpPosts): Promise<boolean>;
|
|
38
|
+
protected checkPasswordProtectedPost(post: types.WpPosts, password: string): boolean;
|
|
39
|
+
protected pagination(params: {
|
|
40
|
+
page: number;
|
|
41
|
+
limit: number;
|
|
42
|
+
count: number;
|
|
43
|
+
}): {
|
|
44
|
+
page: number;
|
|
45
|
+
limit: number;
|
|
46
|
+
totalPage: number;
|
|
47
|
+
count: number;
|
|
48
|
+
};
|
|
49
|
+
protected returnValue<T>(data: T, info?: undefined): {
|
|
50
|
+
data: T;
|
|
51
|
+
info: undefined;
|
|
52
|
+
};
|
|
53
|
+
protected returnValue<T, I>(data: T, info: I): {
|
|
54
|
+
data: T;
|
|
55
|
+
info: I;
|
|
56
|
+
};
|
|
57
|
+
get(...arg2: any): Promise<ReturnType<Crud["returnValue"]>>;
|
|
58
|
+
create(...arg2: any): Promise<ReturnType<Crud["returnValue"]>>;
|
|
59
|
+
update(...arg2: any): Promise<ReturnType<Crud["returnValue"]>>;
|
|
60
|
+
delete(...arg2: any): Promise<ReturnType<Crud["returnValue"]>>;
|
|
61
|
+
list(...arg2: any): Promise<ReturnType<Crud["returnValue"]>>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../src/crud/crud.ts"],"names":[],"mappings":"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"}
|