@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,67 @@
|
|
|
1
|
+
import { Components } from "../components";
|
|
2
|
+
import { Post } from "../post";
|
|
3
|
+
import { PostUtil } from "./post.util";
|
|
4
|
+
import { Config } from "../../config";
|
|
5
|
+
import type * as types from "../../types";
|
|
6
|
+
import { PostsQuery } from "../../query-builder";
|
|
7
|
+
type RevisionColumns = Extract<types.Columns<"posts"> & keyof types.trx.PostUpsert, "post_title" | "post_content" | "post_excerpt">;
|
|
8
|
+
export declare class RevisionUtil {
|
|
9
|
+
private components;
|
|
10
|
+
private config;
|
|
11
|
+
private postUtil;
|
|
12
|
+
static revisionFields: Record<RevisionColumns, string>;
|
|
13
|
+
constructor(components: Components, config: Config, postUtil: PostUtil);
|
|
14
|
+
getAutosave(postId: number, userId?: number): Promise<Post | undefined>;
|
|
15
|
+
getList(postOrId: Post | number, fn?: (query: PostsQuery) => void): Promise<never[] | [{
|
|
16
|
+
ID: number;
|
|
17
|
+
post_author: number;
|
|
18
|
+
post_content: string;
|
|
19
|
+
post_title: string;
|
|
20
|
+
post_excerpt: string;
|
|
21
|
+
post_status: string;
|
|
22
|
+
comment_status: string;
|
|
23
|
+
ping_status: string;
|
|
24
|
+
post_password: string;
|
|
25
|
+
post_name: string;
|
|
26
|
+
to_ping: string;
|
|
27
|
+
pinged: string;
|
|
28
|
+
post_content_filtered: string;
|
|
29
|
+
post_parent: number;
|
|
30
|
+
guid: string;
|
|
31
|
+
menu_order: number;
|
|
32
|
+
post_type: string;
|
|
33
|
+
post_mime_type: string;
|
|
34
|
+
comment_count: number;
|
|
35
|
+
post_date?: string | undefined;
|
|
36
|
+
post_date_gmt?: string | undefined;
|
|
37
|
+
post_modified?: string | undefined;
|
|
38
|
+
post_modified_gmt?: string | undefined;
|
|
39
|
+
}, ...{
|
|
40
|
+
ID: number;
|
|
41
|
+
post_author: number;
|
|
42
|
+
post_content: string;
|
|
43
|
+
post_title: string;
|
|
44
|
+
post_excerpt: string;
|
|
45
|
+
post_status: string;
|
|
46
|
+
comment_status: string;
|
|
47
|
+
ping_status: string;
|
|
48
|
+
post_password: string;
|
|
49
|
+
post_name: string;
|
|
50
|
+
to_ping: string;
|
|
51
|
+
pinged: string;
|
|
52
|
+
post_content_filtered: string;
|
|
53
|
+
post_parent: number;
|
|
54
|
+
guid: string;
|
|
55
|
+
menu_order: number;
|
|
56
|
+
post_type: string;
|
|
57
|
+
post_mime_type: string;
|
|
58
|
+
comment_count: number;
|
|
59
|
+
post_date?: string | undefined;
|
|
60
|
+
post_date_gmt?: string | undefined;
|
|
61
|
+
post_modified?: string | undefined;
|
|
62
|
+
post_modified_gmt?: string | undefined;
|
|
63
|
+
}[]]>;
|
|
64
|
+
convertToData(post: types.Tables["posts"], autosave?: boolean): Record<string, any>;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=revision.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revision.util.d.ts","sourceRoot":"","sources":["../../../src/core/utils/revision.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,eAAe,GAAG,OAAO,CAC5B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,UAAU,EACnD,YAAY,GAAG,cAAc,GAAG,cAAc,CAC/C,CAAC;AAEF,qBACa,YAAY;IAQrB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;IARlB,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAI3C;gBAED,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ;IAItB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU;IAwB9C,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkCvE,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,UAAQ;CAsB5D"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var RevisionUtil_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RevisionUtil = void 0;
|
|
14
|
+
const component_1 = require("../../decorators/component");
|
|
15
|
+
const components_1 = require("../components");
|
|
16
|
+
const post_util_1 = require("./post.util");
|
|
17
|
+
const config_1 = require("../../config");
|
|
18
|
+
const query_util_1 = require("./query.util");
|
|
19
|
+
let RevisionUtil = class RevisionUtil {
|
|
20
|
+
static { RevisionUtil_1 = this; }
|
|
21
|
+
components;
|
|
22
|
+
config;
|
|
23
|
+
postUtil;
|
|
24
|
+
// _wp_post_revision_fields
|
|
25
|
+
static revisionFields = {
|
|
26
|
+
post_title: "Title",
|
|
27
|
+
post_content: "Content",
|
|
28
|
+
post_excerpt: "Excerpt",
|
|
29
|
+
};
|
|
30
|
+
constructor(components, config, postUtil) {
|
|
31
|
+
this.components = components;
|
|
32
|
+
this.config = config;
|
|
33
|
+
this.postUtil = postUtil;
|
|
34
|
+
}
|
|
35
|
+
// wp_get_post_autosave
|
|
36
|
+
async getAutosave(postId, userId = 0) {
|
|
37
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
38
|
+
const posts = await queryUtil.posts((query) => {
|
|
39
|
+
if (userId > 0) {
|
|
40
|
+
query.where("post_author", userId);
|
|
41
|
+
}
|
|
42
|
+
query
|
|
43
|
+
.where("post_parent", postId)
|
|
44
|
+
.where("post_type", "revision")
|
|
45
|
+
.where("post_status", "inherit")
|
|
46
|
+
.where("post_name", `${postId}-autosave-v1`)
|
|
47
|
+
.builder.limit(1);
|
|
48
|
+
});
|
|
49
|
+
if (!posts) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
53
|
+
return await postUtil.get(posts[0].ID);
|
|
54
|
+
}
|
|
55
|
+
// wp_get_post_revisions
|
|
56
|
+
async getList(postOrId, fn) {
|
|
57
|
+
const post = typeof postOrId == "number"
|
|
58
|
+
? await this.postUtil.get(postOrId)
|
|
59
|
+
: postOrId;
|
|
60
|
+
if (!post.props || !post.props.ID) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const postId = post.props.ID;
|
|
64
|
+
if (0 >= this.config.config.constants.WP_POST_REVISIONS) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
68
|
+
const revisions = (await queryUtil.posts((query) => {
|
|
69
|
+
const { column } = query.alias;
|
|
70
|
+
query.from
|
|
71
|
+
.withChildren(postId)
|
|
72
|
+
.where("post_type", "revision")
|
|
73
|
+
.where("post_status", "inherit")
|
|
74
|
+
.builder.orderBy(column("posts", "ID"), "desc");
|
|
75
|
+
if (fn) {
|
|
76
|
+
fn(query);
|
|
77
|
+
}
|
|
78
|
+
})) ?? [];
|
|
79
|
+
return revisions;
|
|
80
|
+
}
|
|
81
|
+
// _wp_post_revision_data
|
|
82
|
+
convertToData(post, autosave = false) {
|
|
83
|
+
const revisionData = {};
|
|
84
|
+
const commonFields = Object.keys(RevisionUtil_1.revisionFields);
|
|
85
|
+
for (const field of commonFields) {
|
|
86
|
+
revisionData[field] = post[field] ?? "";
|
|
87
|
+
}
|
|
88
|
+
revisionData["post_parent"] = post.ID;
|
|
89
|
+
revisionData["post_status"] = "inherit";
|
|
90
|
+
revisionData["post_type"] = "revision";
|
|
91
|
+
revisionData["post_name"] = autosave
|
|
92
|
+
? `${post.ID}-autosave-v1`
|
|
93
|
+
: `${post.ID}-revision-v1`;
|
|
94
|
+
revisionData["post_date"] = post.post_modified || "";
|
|
95
|
+
revisionData["post_date_gmt"] = post.post_modified_gmt || "";
|
|
96
|
+
return revisionData;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.RevisionUtil = RevisionUtil;
|
|
100
|
+
exports.RevisionUtil = RevisionUtil = RevisionUtil_1 = __decorate([
|
|
101
|
+
(0, component_1.component)(),
|
|
102
|
+
__metadata("design:paramtypes", [components_1.Components,
|
|
103
|
+
config_1.Config,
|
|
104
|
+
post_util_1.PostUtil])
|
|
105
|
+
], RevisionUtil);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Config } from "../../config";
|
|
2
|
+
import { Components } from "../components";
|
|
3
|
+
import { Logger } from "../logger";
|
|
4
|
+
import type * as types from "../../types";
|
|
5
|
+
export declare class RolesUtil {
|
|
6
|
+
private config;
|
|
7
|
+
private logger;
|
|
8
|
+
private components;
|
|
9
|
+
constructor(config: Config, logger: Logger, components: Components);
|
|
10
|
+
/**
|
|
11
|
+
* Reformat user roles to be stored in DB
|
|
12
|
+
*
|
|
13
|
+
* @param userRoles - User roles
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
reformatInDB(userRoles: Record<string, types.Role>): Record<string, {
|
|
17
|
+
name: string;
|
|
18
|
+
capabilities: Record<string, 1>;
|
|
19
|
+
}>;
|
|
20
|
+
get(blogId?: number): Promise<Record<string, types.Role>>;
|
|
21
|
+
count(blogId?: number): Promise<Record<string, number | undefined>>;
|
|
22
|
+
getSuperAdmins(args: {
|
|
23
|
+
blogId: number;
|
|
24
|
+
siteId?: never;
|
|
25
|
+
} | {
|
|
26
|
+
blogId?: never;
|
|
27
|
+
siteId: number;
|
|
28
|
+
}): Promise<string[]>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=roles.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.util.d.ts","sourceRoot":"","sources":["../../../src/core/utils/roles.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAMnC,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,qBACa,SAAS;IAElB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,UAAU;gBAFV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU;IAGhC;;;;;OAKG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAChE,MAAM,EACN;QACE,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;KACjC,CACF;IAiBK,GAAG,CAAC,MAAM,GAAE,MAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IA8D5D,KAAK,CAAC,MAAM,GAAE,MAAU;IAmCxB,cAAc,CAClB,IAAI,EACA;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAA;KAAE,GAClC;QAAE,MAAM,CAAC,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAmCzC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
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.RolesUtil = void 0;
|
|
46
|
+
const config_1 = require("../../config");
|
|
47
|
+
const constants_1 = require("../../constants");
|
|
48
|
+
const component_1 = require("../../decorators/component");
|
|
49
|
+
const defaults = __importStar(require("../../defaults"));
|
|
50
|
+
const val = __importStar(require("../../validators"));
|
|
51
|
+
const components_1 = require("../components");
|
|
52
|
+
const logger_1 = require("../logger");
|
|
53
|
+
const options_1 = require("../options");
|
|
54
|
+
const tables_1 = require("../tables");
|
|
55
|
+
const meta_util_1 = require("./meta.util");
|
|
56
|
+
const query_util_1 = require("./query.util");
|
|
57
|
+
let RolesUtil = class RolesUtil {
|
|
58
|
+
config;
|
|
59
|
+
logger;
|
|
60
|
+
components;
|
|
61
|
+
constructor(config, logger, components) {
|
|
62
|
+
this.config = config;
|
|
63
|
+
this.logger = logger;
|
|
64
|
+
this.components = components;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Reformat user roles to be stored in DB
|
|
68
|
+
*
|
|
69
|
+
* @param userRoles - User roles
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
reformatInDB(userRoles) {
|
|
73
|
+
return Object.entries(userRoles).reduce((a, b) => ({
|
|
74
|
+
...a,
|
|
75
|
+
[b[0]]: {
|
|
76
|
+
name: b[1].name,
|
|
77
|
+
capabilities: b[1].capabilities.reduce((a, b) => ({ ...a, [b]: 1 }), {}),
|
|
78
|
+
},
|
|
79
|
+
}), {});
|
|
80
|
+
}
|
|
81
|
+
// Get roles of blog
|
|
82
|
+
async get(blogId = 1) {
|
|
83
|
+
const tables = this.components.get(tables_1.Tables);
|
|
84
|
+
tables.index = blogId;
|
|
85
|
+
const optionsKey = `${tables.prefix}user_roles`;
|
|
86
|
+
const options = this.components.get(options_1.Options);
|
|
87
|
+
const roleRecord = (await options
|
|
88
|
+
.usingBlog(blogId)
|
|
89
|
+
.get(optionsKey)) ?? {};
|
|
90
|
+
const roles = Object.entries(roleRecord)
|
|
91
|
+
.map(([roleName, role]) => ({
|
|
92
|
+
[roleName]: {
|
|
93
|
+
name: role.name,
|
|
94
|
+
// 1. The format of capabilities is either Record<string, true> or string[]
|
|
95
|
+
// 2. Reformat it to string[]
|
|
96
|
+
capabilities: Array.isArray(role.capabilities)
|
|
97
|
+
? role.capabilities
|
|
98
|
+
: Object.entries(role.capabilities).map(([c]) => c),
|
|
99
|
+
},
|
|
100
|
+
}))
|
|
101
|
+
.reduce((a, b) => ({ ...a, ...b }), {});
|
|
102
|
+
if (!roles) {
|
|
103
|
+
this.logger.warn("User roles are not defined in DB. Use default roles");
|
|
104
|
+
return defaults.roles;
|
|
105
|
+
}
|
|
106
|
+
if (this.config.isMultiSite()) {
|
|
107
|
+
const mergeCapabilities = (roles) => {
|
|
108
|
+
const capabilities = new Set();
|
|
109
|
+
for (const role of roles) {
|
|
110
|
+
if (!role || !Array.isArray(role["capabilities"])) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
role["capabilities"].map((capability) => capabilities.add(capability));
|
|
114
|
+
}
|
|
115
|
+
return Array.from(capabilities);
|
|
116
|
+
};
|
|
117
|
+
roles["superadmin"] = {
|
|
118
|
+
...this.config.config.roles["superadmin"],
|
|
119
|
+
capabilities: mergeCapabilities([
|
|
120
|
+
this.config.config.roles["superadmin"],
|
|
121
|
+
roles["administrator"],
|
|
122
|
+
]),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// Set anonymous
|
|
126
|
+
roles["anonymous"] = this.config.config.roles["anonymous"];
|
|
127
|
+
return roles;
|
|
128
|
+
}
|
|
129
|
+
// Return number of roles
|
|
130
|
+
async count(blogId = 1) {
|
|
131
|
+
const roles = await this.get(blogId);
|
|
132
|
+
const roleNames = Object.keys(roles).filter((roleName) => !["superadmin", "anonymous"].includes(roleName));
|
|
133
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
134
|
+
const superAdmins = await this.getSuperAdmins({ blogId });
|
|
135
|
+
const counts = {};
|
|
136
|
+
for (const roleName of roleNames) {
|
|
137
|
+
const count = await queryUtil.usingBlog(blogId).users((query) => {
|
|
138
|
+
query.withRoles([roleName]).select(["ID"]);
|
|
139
|
+
query.count("users", "ID");
|
|
140
|
+
}, val.query.resultCount);
|
|
141
|
+
counts[roleName] = count?.count ?? 0;
|
|
142
|
+
}
|
|
143
|
+
// Anonymous users
|
|
144
|
+
const countAnonymous = await queryUtil.usingBlog(blogId).users((query) => {
|
|
145
|
+
query
|
|
146
|
+
.select(["ID"])
|
|
147
|
+
.hasNoRole()
|
|
148
|
+
.andWhereNot((query) => {
|
|
149
|
+
query.whereIn("user_login", superAdmins);
|
|
150
|
+
});
|
|
151
|
+
query.count("users", "ID");
|
|
152
|
+
}, val.query.resultCount);
|
|
153
|
+
counts["anonymous"] = countAnonymous?.count ?? 0;
|
|
154
|
+
return counts;
|
|
155
|
+
}
|
|
156
|
+
async getSuperAdmins(args) {
|
|
157
|
+
if (!this.config.isMultiSite()) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
161
|
+
const metaUtil = this.components.get(meta_util_1.MetaUtil);
|
|
162
|
+
let siteId;
|
|
163
|
+
if (args.siteId) {
|
|
164
|
+
siteId = args.siteId;
|
|
165
|
+
}
|
|
166
|
+
else if (args.blogId) {
|
|
167
|
+
const blogId = args.blogId;
|
|
168
|
+
const blogs = await queryUtil.blogs((query) => {
|
|
169
|
+
query.where("blog_id", blogId);
|
|
170
|
+
});
|
|
171
|
+
if (!blogs) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
siteId = blogs[0].site_id;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
const superAdmins = await metaUtil.getValue("site", siteId, "site_admins");
|
|
180
|
+
return superAdmins ?? [];
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
exports.RolesUtil = RolesUtil;
|
|
184
|
+
exports.RolesUtil = RolesUtil = __decorate([
|
|
185
|
+
(0, component_1.component)({ scope: constants_1.Scope.Transient }),
|
|
186
|
+
__metadata("design:paramtypes", [config_1.Config,
|
|
187
|
+
logger_1.Logger,
|
|
188
|
+
components_1.Components])
|
|
189
|
+
], RolesUtil);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Config } from "../../config";
|
|
2
|
+
import { Components } from "../components";
|
|
3
|
+
import { User } from "../user";
|
|
4
|
+
import { SiteUtil } from "./site.util";
|
|
5
|
+
type RegistrationType = "all" | "none" | "blog" | "user";
|
|
6
|
+
export declare class SignupUtil {
|
|
7
|
+
private components;
|
|
8
|
+
private config;
|
|
9
|
+
private siteUtil;
|
|
10
|
+
constructor(components: Components, config: Config, siteUtil: SiteUtil);
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @returns string returns registration type. The value can be
|
|
14
|
+
* 'all', 'none', 'blog', or 'user'.
|
|
15
|
+
*/
|
|
16
|
+
getRegistrationType(): Promise<RegistrationType>;
|
|
17
|
+
canUserSignup(): Promise<boolean>;
|
|
18
|
+
alreadySignedUp(args: {
|
|
19
|
+
userLoginOrEmail: string;
|
|
20
|
+
domain?: never;
|
|
21
|
+
path?: never;
|
|
22
|
+
} | {
|
|
23
|
+
userLoginOrEmail?: never;
|
|
24
|
+
domain: string;
|
|
25
|
+
path: string;
|
|
26
|
+
}, options?: {
|
|
27
|
+
days: number;
|
|
28
|
+
}): Promise<boolean>;
|
|
29
|
+
validateUser(name: string, email: string): Promise<[boolean, string | undefined]>;
|
|
30
|
+
validateBlog(name: string, title: string, user?: User): Promise<[boolean, string | undefined]>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=signup.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signup.util.d.ts","sourceRoot":"","sources":["../../../src/core/utils/signup.util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,KAAK,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,qBACa,UAAU;IAEnB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;gBAFR,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ;IAI5B;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAkBhD,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAMjC,eAAe,CACnB,IAAI,EACA;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAC,IAAI,CAAC,EAAE,KAAK,CAAA;KAAE,GAC1D;QACE,gBAAgB,CAAC,EAAE,KAAK,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,EAEL,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IA4CtB,YAAY,CAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAwDnC,YAAY,CAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CA4E1C"}
|
|
@@ -0,0 +1,227 @@
|
|
|
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.SignupUtil = void 0;
|
|
46
|
+
const zod_1 = require("zod");
|
|
47
|
+
const common_1 = require("../../common");
|
|
48
|
+
const config_1 = require("../../config");
|
|
49
|
+
const component_1 = require("../../decorators/component");
|
|
50
|
+
const val = __importStar(require("../../validators"));
|
|
51
|
+
const components_1 = require("../components");
|
|
52
|
+
const current_1 = require("../current");
|
|
53
|
+
const query_util_1 = require("./query.util");
|
|
54
|
+
const site_util_1 = require("./site.util");
|
|
55
|
+
const options_1 = require("../options");
|
|
56
|
+
let SignupUtil = class SignupUtil {
|
|
57
|
+
components;
|
|
58
|
+
config;
|
|
59
|
+
siteUtil;
|
|
60
|
+
constructor(components, config, siteUtil) {
|
|
61
|
+
this.components = components;
|
|
62
|
+
this.config = config;
|
|
63
|
+
this.siteUtil = siteUtil;
|
|
64
|
+
}
|
|
65
|
+
// $active_signup
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @returns string returns registration type. The value can be
|
|
69
|
+
* 'all', 'none', 'blog', or 'user'.
|
|
70
|
+
*/
|
|
71
|
+
async getRegistrationType() {
|
|
72
|
+
if (!this.config.isMultiSite()) {
|
|
73
|
+
return "none";
|
|
74
|
+
}
|
|
75
|
+
const options = this.components.get(options_1.Options);
|
|
76
|
+
const current = this.components.get(current_1.Current);
|
|
77
|
+
const activeSignup = await options.get("registration", {
|
|
78
|
+
siteId: current.siteId,
|
|
79
|
+
});
|
|
80
|
+
return activeSignup &&
|
|
81
|
+
["all", "none", "blog", "user"].includes(activeSignup)
|
|
82
|
+
? activeSignup
|
|
83
|
+
: "none";
|
|
84
|
+
}
|
|
85
|
+
// users_can_register_signup_filter
|
|
86
|
+
async canUserSignup() {
|
|
87
|
+
const registrationType = await this.getRegistrationType();
|
|
88
|
+
return registrationType === "all" || registrationType === "user";
|
|
89
|
+
}
|
|
90
|
+
async alreadySignedUp(args, options) {
|
|
91
|
+
const { userLoginOrEmail, domain, path } = args;
|
|
92
|
+
const { days = 2 } = options ?? {};
|
|
93
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
94
|
+
if (!userLoginOrEmail && (!domain || !path)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const signup = await queryUtil.common("signups", (query) => {
|
|
98
|
+
if (userLoginOrEmail) {
|
|
99
|
+
query
|
|
100
|
+
.where("user_email", userLoginOrEmail)
|
|
101
|
+
.or.where("user_login", userLoginOrEmail);
|
|
102
|
+
}
|
|
103
|
+
else if (domain && path) {
|
|
104
|
+
query.where("domain", domain).where("path", path);
|
|
105
|
+
}
|
|
106
|
+
query.builder.first();
|
|
107
|
+
}, val.database.wpSignups);
|
|
108
|
+
if (!signup || !signup.registered) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const registered = (typeof signup.registered == "string"
|
|
112
|
+
? new Date(signup.registered)
|
|
113
|
+
: signup.registered)?.getTime();
|
|
114
|
+
// Throw error if email was recently registered
|
|
115
|
+
if (new Date().getTime() - registered <= days * 24 * 60 * 60 * 1000) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
// wpmu_validate_user_signup
|
|
121
|
+
async validateUser(name, email) {
|
|
122
|
+
if (!this.config.isMultiSite()) {
|
|
123
|
+
return [false, "Not multisite"];
|
|
124
|
+
}
|
|
125
|
+
const formattedName = common_1.formatting.username(name).replace(/\s+/g, "");
|
|
126
|
+
if (0 >= name.length || name !== formattedName || /[^a-z0-9]/.test(name)) {
|
|
127
|
+
return [
|
|
128
|
+
false,
|
|
129
|
+
"Usernames can only contain lowercase letters (a-z) and numbers",
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
const reservedNames = await this.siteUtil.getReservedNames();
|
|
133
|
+
if (reservedNames.includes(name)) {
|
|
134
|
+
return [false, "Username is not allowed (reserved)"];
|
|
135
|
+
}
|
|
136
|
+
const parsedEmail = zod_1.z.string().email().min(4).max(60).safeParse(email);
|
|
137
|
+
if (!parsedEmail.success || (await this.siteUtil.isEmailUnsafe(email))) {
|
|
138
|
+
return [false, "Invalid email address (unsafe or format)"];
|
|
139
|
+
}
|
|
140
|
+
if (/^[0-9]*$/.test(name)) {
|
|
141
|
+
return [false, "Invalid name (numbers only)"];
|
|
142
|
+
}
|
|
143
|
+
if (!(await this.siteUtil.isLimitedEmailDomains(email))) {
|
|
144
|
+
return [false, "Invalid email address (limited email domains)"];
|
|
145
|
+
}
|
|
146
|
+
const parsedName = val.trx.userLogin.safeParse(name);
|
|
147
|
+
if (!parsedName.success) {
|
|
148
|
+
return [false, parsedName.error.message];
|
|
149
|
+
}
|
|
150
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
151
|
+
const users = await queryUtil.users((query) => {
|
|
152
|
+
query.where("user_login", name).or.where("user_email", email);
|
|
153
|
+
});
|
|
154
|
+
if (users && users.length > 0) {
|
|
155
|
+
return [false, "User already exists"];
|
|
156
|
+
}
|
|
157
|
+
if ((await this.alreadySignedUp({ userLoginOrEmail: name })) ||
|
|
158
|
+
(await this.alreadySignedUp({ userLoginOrEmail: email }))) {
|
|
159
|
+
return [false, "User already signed up"];
|
|
160
|
+
}
|
|
161
|
+
return [true, undefined];
|
|
162
|
+
}
|
|
163
|
+
// wpmu_validate_blog_signup
|
|
164
|
+
async validateBlog(name, title, user) {
|
|
165
|
+
const current = this.components.get(current_1.Current);
|
|
166
|
+
const currentSiteId = current.siteId;
|
|
167
|
+
if (!current.site?.props.site.domain || !current.site?.props.site.path) {
|
|
168
|
+
return [false, "Invalid current domain or path"];
|
|
169
|
+
}
|
|
170
|
+
const basePath = current.site.props.site.path;
|
|
171
|
+
const domain = current.site.props.site.domain;
|
|
172
|
+
title = common_1.formatting.stripTags(title);
|
|
173
|
+
const reservedNames = await this.siteUtil.getReservedNames();
|
|
174
|
+
if (/[^a-z0-9]+/.test(name)) {
|
|
175
|
+
return [false, "Invalid blogname (numbers and lowercase letters)"];
|
|
176
|
+
}
|
|
177
|
+
if (reservedNames.includes(name) || name.length < 4) {
|
|
178
|
+
return [false, "Invalid blogname (reserved or length)"];
|
|
179
|
+
}
|
|
180
|
+
const subdomainInstall = this.config.config.multisite.subdomainInstall;
|
|
181
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
182
|
+
if (!subdomainInstall &&
|
|
183
|
+
(await queryUtil.usingBlog(currentSiteId).posts((query) => {
|
|
184
|
+
query
|
|
185
|
+
.where("post_type", "page")
|
|
186
|
+
.where("post_name", name)
|
|
187
|
+
.builder.limit(1);
|
|
188
|
+
}))) {
|
|
189
|
+
return [false, "Invalid blogname (site name)"];
|
|
190
|
+
}
|
|
191
|
+
queryUtil.resetBlog();
|
|
192
|
+
if (/^[0-9]*$/.test(name)) {
|
|
193
|
+
return [false, "Invalid name (numbers only)"];
|
|
194
|
+
}
|
|
195
|
+
title = common_1.formatting.unslash(title);
|
|
196
|
+
if (0 >= title.length) {
|
|
197
|
+
return [false, "Invalid title"];
|
|
198
|
+
}
|
|
199
|
+
const myDomain = subdomainInstall
|
|
200
|
+
? `${name}.${domain.replace(/^www\./, "")}`
|
|
201
|
+
: domain;
|
|
202
|
+
const path = subdomainInstall ? basePath : `${basePath}${name}/`;
|
|
203
|
+
const sites = await queryUtil.sites((query) => {
|
|
204
|
+
query.where("domain", myDomain).where("path", path);
|
|
205
|
+
});
|
|
206
|
+
if (sites) {
|
|
207
|
+
return [false, "Site already exists"];
|
|
208
|
+
}
|
|
209
|
+
const existingUser = await queryUtil.users((query) => {
|
|
210
|
+
query.where("user_login", name).builder.first();
|
|
211
|
+
}, val.database.wpUsers);
|
|
212
|
+
if (existingUser && (!user || user.props?.user_login !== name)) {
|
|
213
|
+
return [false, "Invalid name (user_login)"];
|
|
214
|
+
}
|
|
215
|
+
if (await this.alreadySignedUp({ domain, path })) {
|
|
216
|
+
return [false, "Already signed up"];
|
|
217
|
+
}
|
|
218
|
+
return [true, undefined];
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
exports.SignupUtil = SignupUtil;
|
|
222
|
+
exports.SignupUtil = SignupUtil = __decorate([
|
|
223
|
+
(0, component_1.component)(),
|
|
224
|
+
__metadata("design:paramtypes", [components_1.Components,
|
|
225
|
+
config_1.Config,
|
|
226
|
+
site_util_1.SiteUtil])
|
|
227
|
+
], SignupUtil);
|