@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,155 @@
|
|
|
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.RevisionCrud = void 0;
|
|
46
|
+
const components_1 = require("../core/components");
|
|
47
|
+
const post_util_1 = require("../core/utils/post.util");
|
|
48
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
49
|
+
const component_1 = require("../decorators/component");
|
|
50
|
+
const transactions_1 = require("../transactions");
|
|
51
|
+
const val = __importStar(require("../validators"));
|
|
52
|
+
const crud_1 = require("./crud");
|
|
53
|
+
const error_1 = require("./error");
|
|
54
|
+
let RevisionCrud = class RevisionCrud extends crud_1.Crud {
|
|
55
|
+
constructor(components) {
|
|
56
|
+
super(components);
|
|
57
|
+
}
|
|
58
|
+
async checkPermission(parentId) {
|
|
59
|
+
const { user } = await this.getUser();
|
|
60
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
61
|
+
const parent = await postUtil.get(parentId);
|
|
62
|
+
if (!parent.props) {
|
|
63
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid parameters.");
|
|
64
|
+
}
|
|
65
|
+
if (!(await user.can("edit_post", parent.props.ID))) {
|
|
66
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to view revisions of this post");
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
async get(parentId, id) {
|
|
71
|
+
await this.checkPermission(parentId);
|
|
72
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
73
|
+
const revision = await postUtil.get(id);
|
|
74
|
+
if (!revision.props || revision.props.post_parent !== parentId) {
|
|
75
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `The revision does not belong to the specified parent with id of ${parentId}`);
|
|
76
|
+
}
|
|
77
|
+
return this.returnValue(revision.props);
|
|
78
|
+
}
|
|
79
|
+
async restore(parentId, id) {
|
|
80
|
+
await this.checkPermission(parentId);
|
|
81
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
82
|
+
const revision = await postUtil.get(id);
|
|
83
|
+
const parent = await postUtil.get(parentId);
|
|
84
|
+
if (!revision.props ||
|
|
85
|
+
revision.props.post_parent !== parentId ||
|
|
86
|
+
!parent.props) {
|
|
87
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `The revision does not belong to the specified parent with id of ${parentId}`);
|
|
88
|
+
}
|
|
89
|
+
const postType = postUtil.getTypeObject(parent.props.post_type);
|
|
90
|
+
if (!postType?.supports.includes("revisions")) {
|
|
91
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `The item doesn't support revision ${parentId}`);
|
|
92
|
+
}
|
|
93
|
+
const revisionTrx = this.components.get(transactions_1.RevisionTrx);
|
|
94
|
+
const result = await revisionTrx.restore(id);
|
|
95
|
+
if (result === parentId) {
|
|
96
|
+
await revisionTrx.save(parentId);
|
|
97
|
+
return this.returnValue(true);
|
|
98
|
+
}
|
|
99
|
+
return this.returnValue(false);
|
|
100
|
+
}
|
|
101
|
+
async list(parentId, args) {
|
|
102
|
+
await this.checkPermission(parentId);
|
|
103
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
104
|
+
const parsedArgs = val.crud.revisionListParams.parse(args ?? {});
|
|
105
|
+
const buildQuery = (query) => {
|
|
106
|
+
const { column } = query.alias;
|
|
107
|
+
const offset = parsedArgs.offset ?? (parsedArgs.page - 1) * parsedArgs.per_page;
|
|
108
|
+
const limit = parsedArgs.per_page;
|
|
109
|
+
query.builder.offset(offset).limit(limit).groupBy(column("posts", "ID"));
|
|
110
|
+
query.where("post_parent", parentId).where("post_type", "revision");
|
|
111
|
+
if (parsedArgs.orderby) {
|
|
112
|
+
query.builder.orderBy(column("posts", parsedArgs.orderby), parsedArgs.order);
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(parsedArgs.include)) {
|
|
115
|
+
query.whereIn("ID", parsedArgs.include);
|
|
116
|
+
}
|
|
117
|
+
if (Array.isArray(parsedArgs.exclude)) {
|
|
118
|
+
query.not.andWhere((query) => query.whereIn("ID", parsedArgs.exclude));
|
|
119
|
+
}
|
|
120
|
+
if (parsedArgs.search) {
|
|
121
|
+
query.andWhere((query) => {
|
|
122
|
+
const searchColumns = [
|
|
123
|
+
"post_title",
|
|
124
|
+
"post_excerpt",
|
|
125
|
+
"post_content",
|
|
126
|
+
];
|
|
127
|
+
for (const searchColumn of searchColumns) {
|
|
128
|
+
parsedArgs.search &&
|
|
129
|
+
query.or.whereLike(searchColumn, parsedArgs.search);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const revisions = (await queryUtil.posts((query) => {
|
|
135
|
+
buildQuery(query);
|
|
136
|
+
})) ?? [];
|
|
137
|
+
const counts = await queryUtil.posts((query) => {
|
|
138
|
+
buildQuery(query);
|
|
139
|
+
query.count("posts", "ID");
|
|
140
|
+
}, val.query.resultCount);
|
|
141
|
+
const pagination = this.pagination({
|
|
142
|
+
page: parsedArgs.page,
|
|
143
|
+
limit: parsedArgs.per_page,
|
|
144
|
+
count: counts?.count ?? 0,
|
|
145
|
+
});
|
|
146
|
+
return this.returnValue(revisions, {
|
|
147
|
+
pagination,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
exports.RevisionCrud = RevisionCrud;
|
|
152
|
+
exports.RevisionCrud = RevisionCrud = __decorate([
|
|
153
|
+
(0, component_1.component)(),
|
|
154
|
+
__metadata("design:paramtypes", [components_1.Components])
|
|
155
|
+
], RevisionCrud);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Config } from "../config";
|
|
3
|
+
import { Components } from "../core/components";
|
|
4
|
+
import { RolesUtil } from "../core/utils/roles.util";
|
|
5
|
+
import * as val from "../validators";
|
|
6
|
+
import { Crud } from "./crud";
|
|
7
|
+
type RoleUpsert = z.infer<typeof val.trx.rolesUpsert>;
|
|
8
|
+
export declare class RolesCrud extends Crud {
|
|
9
|
+
private config;
|
|
10
|
+
constructor(components: Components, config: Config);
|
|
11
|
+
private checkPermission;
|
|
12
|
+
create(data: RoleUpsert, options?: Partial<{
|
|
13
|
+
siteId: number;
|
|
14
|
+
blogId: number;
|
|
15
|
+
remove: boolean;
|
|
16
|
+
}>): Promise<{
|
|
17
|
+
data: boolean;
|
|
18
|
+
info: undefined;
|
|
19
|
+
}>;
|
|
20
|
+
delete(roleName: string, options?: Partial<{
|
|
21
|
+
siteId: number;
|
|
22
|
+
blogId: number;
|
|
23
|
+
}>): Promise<{
|
|
24
|
+
data: boolean;
|
|
25
|
+
info: undefined;
|
|
26
|
+
}>;
|
|
27
|
+
update(roleName: string, data: Omit<RoleUpsert, "role">, options?: Partial<{
|
|
28
|
+
siteId: number;
|
|
29
|
+
blogId: number;
|
|
30
|
+
}>): Promise<{
|
|
31
|
+
data: boolean;
|
|
32
|
+
info: undefined;
|
|
33
|
+
}>;
|
|
34
|
+
list(args: z.infer<typeof val.crud.rolesListParams>): Promise<{
|
|
35
|
+
data: {
|
|
36
|
+
blog: {
|
|
37
|
+
blog_id: number;
|
|
38
|
+
site_id: number;
|
|
39
|
+
};
|
|
40
|
+
roles: Awaited<ReturnType<InstanceType<typeof RolesUtil>["get"]>>;
|
|
41
|
+
}[];
|
|
42
|
+
info: undefined;
|
|
43
|
+
}>;
|
|
44
|
+
count(args: z.infer<typeof val.crud.rolesCountListParams>): Promise<{
|
|
45
|
+
data: Record<string, number | undefined>;
|
|
46
|
+
info: undefined;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=roles.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.crud.d.ts","sourceRoot":"","sources":["../../src/crud/roles.crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAKrD,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAEtD,qBACa,SAAU,SAAQ,IAAI;IACG,OAAO,CAAC,MAAM;gBAAtC,UAAU,EAAE,UAAU,EAAU,MAAM,EAAE,MAAM;YAI5C,eAAe;IAmBvB,MAAM,CACV,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;;;;IA6BE,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;;;;IAoBE,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;;;;IA2BE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;;;;;;mBAqB9C,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;;;;IAe/D,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC;;;;CAmChE"}
|
|
@@ -0,0 +1,198 @@
|
|
|
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.RolesCrud = void 0;
|
|
46
|
+
const config_1 = require("../config");
|
|
47
|
+
const components_1 = require("../core/components");
|
|
48
|
+
const roles_util_1 = require("../core/utils/roles.util");
|
|
49
|
+
const vars_1 = require("../core/vars");
|
|
50
|
+
const component_1 = require("../decorators/component");
|
|
51
|
+
const defaults = __importStar(require("../defaults"));
|
|
52
|
+
const transactions_1 = require("../transactions");
|
|
53
|
+
const val = __importStar(require("../validators"));
|
|
54
|
+
const crud_1 = require("./crud");
|
|
55
|
+
const error_1 = require("./error");
|
|
56
|
+
let RolesCrud = class RolesCrud extends crud_1.Crud {
|
|
57
|
+
config;
|
|
58
|
+
constructor(components, config) {
|
|
59
|
+
super(components);
|
|
60
|
+
this.config = config;
|
|
61
|
+
}
|
|
62
|
+
async checkPermission(roleNames) {
|
|
63
|
+
const defaultRoles = defaults.roles;
|
|
64
|
+
const { user: currentUser } = await this.getUser();
|
|
65
|
+
if (!(await currentUser.can("manage_roles"))) {
|
|
66
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
67
|
+
}
|
|
68
|
+
for (const roleName of roleNames) {
|
|
69
|
+
// Default roles are not allowed to edit
|
|
70
|
+
if (Object.keys(defaultRoles).includes(roleName)) {
|
|
71
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted to edit default roles");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async create(data, options) {
|
|
76
|
+
try {
|
|
77
|
+
const { blogId, siteId } = options ?? {};
|
|
78
|
+
await this.switchBlog({
|
|
79
|
+
siteId,
|
|
80
|
+
blogId,
|
|
81
|
+
});
|
|
82
|
+
await this.checkPermission([data.role]);
|
|
83
|
+
const vars = this.components.get(vars_1.Vars);
|
|
84
|
+
const currentUserRoles = vars.USER_ROLES;
|
|
85
|
+
if (currentUserRoles[data.role]) {
|
|
86
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Role already exists");
|
|
87
|
+
}
|
|
88
|
+
data.new_role = undefined;
|
|
89
|
+
const roleTrx = this.components.get(transactions_1.RolesTrx);
|
|
90
|
+
const result = await roleTrx.upsert(data);
|
|
91
|
+
return this.returnValue(result);
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
await this.restoreBlog();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async delete(roleName, options) {
|
|
98
|
+
try {
|
|
99
|
+
const { blogId, siteId } = options ?? {};
|
|
100
|
+
await this.switchBlog({
|
|
101
|
+
siteId,
|
|
102
|
+
blogId,
|
|
103
|
+
});
|
|
104
|
+
await this.checkPermission([roleName]);
|
|
105
|
+
const roleTrx = this.components.get(transactions_1.RolesTrx);
|
|
106
|
+
const result = await roleTrx.remove(roleName);
|
|
107
|
+
return this.returnValue(result);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await this.restoreBlog();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async update(roleName, data, options) {
|
|
114
|
+
try {
|
|
115
|
+
const { blogId, siteId } = options ?? {};
|
|
116
|
+
await this.switchBlog({
|
|
117
|
+
siteId,
|
|
118
|
+
blogId,
|
|
119
|
+
});
|
|
120
|
+
const updateData = {
|
|
121
|
+
...data,
|
|
122
|
+
role: roleName,
|
|
123
|
+
};
|
|
124
|
+
const roleNames = data.new_role ? [roleName, data.new_role] : [roleName];
|
|
125
|
+
await this.checkPermission(roleNames);
|
|
126
|
+
data.new_role = undefined;
|
|
127
|
+
const roleTrx = this.components.get(transactions_1.RolesTrx);
|
|
128
|
+
const result = await roleTrx.upsert(updateData);
|
|
129
|
+
return this.returnValue(result);
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
await this.restoreBlog();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async list(args) {
|
|
136
|
+
let blogIds;
|
|
137
|
+
if (!this.config.isMultiSite()) {
|
|
138
|
+
blogIds = [1];
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const parsedArgs = val.crud.rolesListParams.parse(args);
|
|
142
|
+
blogIds = parsedArgs.blog_ids;
|
|
143
|
+
}
|
|
144
|
+
const [blogs, errors] = await this.getAvailableBlogs({
|
|
145
|
+
blogIds,
|
|
146
|
+
canArgs: [["list_users"]],
|
|
147
|
+
});
|
|
148
|
+
if (errors.length > 0) {
|
|
149
|
+
throw errors[0];
|
|
150
|
+
}
|
|
151
|
+
const roles = [];
|
|
152
|
+
const roleUtil = this.components.get(roles_util_1.RolesUtil);
|
|
153
|
+
for (const blog of blogs) {
|
|
154
|
+
const blogId = blog.blog_id;
|
|
155
|
+
roles.push({
|
|
156
|
+
blog,
|
|
157
|
+
roles: await roleUtil.get(blogId),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return this.returnValue(roles);
|
|
161
|
+
}
|
|
162
|
+
async count(args) {
|
|
163
|
+
let siteId;
|
|
164
|
+
let blogId;
|
|
165
|
+
if (!this.config.isMultiSite()) {
|
|
166
|
+
blogId = 1;
|
|
167
|
+
siteId = undefined;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const parsedArgs = val.crud.rolesCountListParams.parse(args);
|
|
171
|
+
blogId = parsedArgs.blog_id;
|
|
172
|
+
siteId = parsedArgs.site_id;
|
|
173
|
+
}
|
|
174
|
+
if (!blogId && !siteId) {
|
|
175
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Missing parameter");
|
|
176
|
+
}
|
|
177
|
+
await this.checkBlogsPermission({
|
|
178
|
+
blogIds: blogId ? [blogId] : undefined,
|
|
179
|
+
siteIds: siteId ? [siteId] : undefined,
|
|
180
|
+
canArgs: [["list_users"]],
|
|
181
|
+
});
|
|
182
|
+
const rolesUtil = this.components.get(roles_util_1.RolesUtil);
|
|
183
|
+
let counts = {};
|
|
184
|
+
if (siteId) {
|
|
185
|
+
const superAdmins = await rolesUtil.getSuperAdmins({ siteId });
|
|
186
|
+
counts = { superadmins: superAdmins.length };
|
|
187
|
+
}
|
|
188
|
+
else if (blogId) {
|
|
189
|
+
counts = await rolesUtil.count(blogId);
|
|
190
|
+
}
|
|
191
|
+
return this.returnValue(counts);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
exports.RolesCrud = RolesCrud;
|
|
195
|
+
exports.RolesCrud = RolesCrud = __decorate([
|
|
196
|
+
(0, component_1.component)(),
|
|
197
|
+
__metadata("design:paramtypes", [components_1.Components, config_1.Config])
|
|
198
|
+
], RolesCrud);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Config } from "../config";
|
|
3
|
+
import { Components } from "../core/components";
|
|
4
|
+
import * as val from "../validators";
|
|
5
|
+
import { Crud } from "./crud";
|
|
6
|
+
type Settings = z.infer<typeof val.crud.settings>;
|
|
7
|
+
export declare class SettingsCrud extends Crud {
|
|
8
|
+
#private;
|
|
9
|
+
private config;
|
|
10
|
+
constructor(components: Components, config: Config);
|
|
11
|
+
private optionNames;
|
|
12
|
+
private get reversedMapping();
|
|
13
|
+
private checkPermission;
|
|
14
|
+
get(options?: {
|
|
15
|
+
blogId: number;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
data: {
|
|
18
|
+
url?: string | undefined;
|
|
19
|
+
title?: string | undefined;
|
|
20
|
+
home?: string | undefined;
|
|
21
|
+
email?: string | undefined;
|
|
22
|
+
description?: string | undefined;
|
|
23
|
+
start_of_week?: number | undefined;
|
|
24
|
+
use_smilies?: number | undefined;
|
|
25
|
+
default_category?: number | undefined;
|
|
26
|
+
default_comment_status?: "closed" | "open" | undefined;
|
|
27
|
+
default_ping_status?: "closed" | "open" | undefined;
|
|
28
|
+
posts_per_page?: number | undefined;
|
|
29
|
+
date_format?: string | undefined;
|
|
30
|
+
time_format?: string | undefined;
|
|
31
|
+
show_on_front?: string | undefined;
|
|
32
|
+
page_for_posts?: number | undefined;
|
|
33
|
+
page_on_front?: number | undefined;
|
|
34
|
+
default_post_format?: number | undefined;
|
|
35
|
+
site_icon?: number | undefined;
|
|
36
|
+
timezone?: string | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
time_offset_minutes: number;
|
|
39
|
+
};
|
|
40
|
+
info: undefined;
|
|
41
|
+
}>;
|
|
42
|
+
update(input: Settings, options?: {
|
|
43
|
+
blogId: number;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
data: boolean;
|
|
46
|
+
info: undefined;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=settings.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.crud.d.ts","sourceRoot":"","sources":["../../src/crud/settings.crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAI9B,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAElD,qBACa,YAAa,SAAQ,IAAI;;IACA,OAAO,CAAC,MAAM;gBAAtC,UAAU,EAAE,UAAU,EAAU,MAAM,EAAE,MAAM;IA+B1D,OAAO,CAAC,WAAW;IAInB,OAAO,KAAK,eAAe,GAI1B;YAEa,eAAe;IAOvB,GAAG,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;iCA8BU,MAAM;;;;IAOhD,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;;;;CA2B3D"}
|
|
@@ -0,0 +1,153 @@
|
|
|
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.SettingsCrud = void 0;
|
|
46
|
+
const zod_1 = require("zod");
|
|
47
|
+
const config_1 = require("../config");
|
|
48
|
+
const components_1 = require("../core/components");
|
|
49
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
50
|
+
const component_1 = require("../decorators/component");
|
|
51
|
+
const transactions_1 = require("../transactions");
|
|
52
|
+
const val = __importStar(require("../validators"));
|
|
53
|
+
const crud_1 = require("./crud");
|
|
54
|
+
const error_1 = require("./error");
|
|
55
|
+
const vars_1 = require("../core/vars");
|
|
56
|
+
let SettingsCrud = class SettingsCrud extends crud_1.Crud {
|
|
57
|
+
config;
|
|
58
|
+
constructor(components, config) {
|
|
59
|
+
super(components);
|
|
60
|
+
this.config = config;
|
|
61
|
+
}
|
|
62
|
+
// These records are visible to public.
|
|
63
|
+
// Use options.crud for private settings.
|
|
64
|
+
#mapping = {
|
|
65
|
+
title: "blogname",
|
|
66
|
+
description: "blogdescription",
|
|
67
|
+
url: "siteurl",
|
|
68
|
+
home: "home",
|
|
69
|
+
email: "admin_email",
|
|
70
|
+
timezone: "timezone_string",
|
|
71
|
+
date_format: "date_format",
|
|
72
|
+
time_format: "time_format",
|
|
73
|
+
start_of_week: "start_of_week",
|
|
74
|
+
use_smilies: "use_smilies",
|
|
75
|
+
default_category: "default_category",
|
|
76
|
+
default_post_format: "default_post_format",
|
|
77
|
+
posts_per_page: "posts_per_page",
|
|
78
|
+
show_on_front: "show_on_front",
|
|
79
|
+
page_on_front: "page_on_front",
|
|
80
|
+
page_for_posts: "page_on_front",
|
|
81
|
+
default_ping_status: "default_ping_status",
|
|
82
|
+
default_comment_status: "default_comment_status",
|
|
83
|
+
site_icon: "site_icon",
|
|
84
|
+
};
|
|
85
|
+
optionNames() {
|
|
86
|
+
return Object.entries(this.#mapping).map((v) => v[1]);
|
|
87
|
+
}
|
|
88
|
+
get reversedMapping() {
|
|
89
|
+
return Object.entries(this.#mapping)
|
|
90
|
+
.map((v) => ({ [v[1]]: v[0] }))
|
|
91
|
+
.reduce((obj, item) => ({ ...obj, ...item }), {});
|
|
92
|
+
}
|
|
93
|
+
async checkPermission() {
|
|
94
|
+
const { user } = await this.getUser();
|
|
95
|
+
if (!(await user.can("manage_options"))) {
|
|
96
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async get(options) {
|
|
100
|
+
const { blogId } = options ?? {};
|
|
101
|
+
const { user } = await this.getUser();
|
|
102
|
+
const vars = this.components.get(vars_1.Vars);
|
|
103
|
+
try {
|
|
104
|
+
if (blogId) {
|
|
105
|
+
await this.switchBlog({ blogId });
|
|
106
|
+
}
|
|
107
|
+
const role = await user.role();
|
|
108
|
+
if (role.is("anonymous")) {
|
|
109
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
110
|
+
}
|
|
111
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
112
|
+
const optionsCore = (await queryUtil.options((query) => {
|
|
113
|
+
query.whereIn(this.optionNames());
|
|
114
|
+
}, zod_1.z.array(val.query.optionsResult))) ?? [];
|
|
115
|
+
const data = optionsCore
|
|
116
|
+
.map((option) => ({
|
|
117
|
+
[this.reversedMapping[option.option_name]]: option.option_value,
|
|
118
|
+
}))
|
|
119
|
+
.reduce((obj, item) => ({ ...obj, ...item }), {});
|
|
120
|
+
data.timezone = vars.TZ_IDENTIFIER;
|
|
121
|
+
data.time_offset_minutes = vars.TIME_OFFSET_MINUTES;
|
|
122
|
+
return this.returnValue(data);
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await this.restoreBlog();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async update(input, options) {
|
|
129
|
+
const { blogId } = options ?? {};
|
|
130
|
+
try {
|
|
131
|
+
if (blogId) {
|
|
132
|
+
await this.switchBlog({ blogId });
|
|
133
|
+
}
|
|
134
|
+
await this.checkPermission();
|
|
135
|
+
const data = val.crud.settings.parse(input);
|
|
136
|
+
const optionsTrx = this.components.get(transactions_1.OptionsTrx);
|
|
137
|
+
for (const [key, value] of Object.entries(data)) {
|
|
138
|
+
await optionsTrx.insert(this.#mapping[key], value, {
|
|
139
|
+
upsert: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return this.returnValue(true);
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
await this.restoreBlog();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
exports.SettingsCrud = SettingsCrud;
|
|
150
|
+
exports.SettingsCrud = SettingsCrud = __decorate([
|
|
151
|
+
(0, component_1.component)(),
|
|
152
|
+
__metadata("design:paramtypes", [components_1.Components, config_1.Config])
|
|
153
|
+
], SettingsCrud);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Config } from "../config";
|
|
3
|
+
import { Components } from "../core/components";
|
|
4
|
+
import * as val from "../validators";
|
|
5
|
+
import { Crud } from "./crud";
|
|
6
|
+
import type * as types from "../types";
|
|
7
|
+
import { SiteUtil } from "../core/utils/site.util";
|
|
8
|
+
type DataListType = (types.WpSite & {
|
|
9
|
+
site_name: string;
|
|
10
|
+
})[];
|
|
11
|
+
type SiteUpsert = z.infer<typeof val.trx.siteUpsert>;
|
|
12
|
+
export declare class SiteCrud extends Crud {
|
|
13
|
+
private config;
|
|
14
|
+
private siteUtil;
|
|
15
|
+
constructor(components: Components, config: Config, siteUtil: SiteUtil);
|
|
16
|
+
private checkPermission;
|
|
17
|
+
get(siteId: number): Promise<{
|
|
18
|
+
data: {
|
|
19
|
+
site_meta: Record<string, any>;
|
|
20
|
+
id: number;
|
|
21
|
+
path: string;
|
|
22
|
+
domain: string;
|
|
23
|
+
};
|
|
24
|
+
info: undefined;
|
|
25
|
+
}>;
|
|
26
|
+
create(args: {
|
|
27
|
+
domain: string;
|
|
28
|
+
siteName: string;
|
|
29
|
+
path: string;
|
|
30
|
+
}, options?: {
|
|
31
|
+
subdomainInstall?: boolean;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
data: {
|
|
34
|
+
siteId: number;
|
|
35
|
+
blogId: number;
|
|
36
|
+
};
|
|
37
|
+
info: undefined;
|
|
38
|
+
}>;
|
|
39
|
+
update(siteId: number, data: Partial<SiteUpsert>): Promise<{
|
|
40
|
+
data: number;
|
|
41
|
+
info: undefined;
|
|
42
|
+
}>;
|
|
43
|
+
delete(siteId: number, options?: {
|
|
44
|
+
newSiteId?: number;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
data: boolean;
|
|
47
|
+
info: undefined;
|
|
48
|
+
}>;
|
|
49
|
+
list(args: Partial<z.infer<typeof val.crud.siteListParams>>): Promise<{
|
|
50
|
+
data: DataListType;
|
|
51
|
+
info: {
|
|
52
|
+
pagination: {
|
|
53
|
+
page: number;
|
|
54
|
+
limit: number;
|
|
55
|
+
totalPage: number;
|
|
56
|
+
count: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=site.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.crud.d.ts","sourceRoot":"","sources":["../../src/crud/site.crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOhD,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,KAAK,YAAY,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CAAC;AAC7D,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAErD,qBACa,QAAS,SAAQ,IAAI;IAG9B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;gBAFhB,UAAU,EAAE,UAAU,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ;YAKd,eAAe;IAevB,GAAG,CAAC,MAAM,EAAE,MAAM;;;;;;;;;IAqBlB,MAAM,CACV,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,EACD,OAAO,CAAC,EAAE;QACR,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B;;;;;;;IAyEG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC;;;;IAkBhD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;IAiBvD,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;;;;;;;;;;;CA+FlE"}
|