@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,285 @@
|
|
|
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.TermCrud = void 0;
|
|
46
|
+
const config_1 = require("../config");
|
|
47
|
+
const components_1 = require("../core/components");
|
|
48
|
+
const post_util_1 = require("../core/utils/post.util");
|
|
49
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
50
|
+
const taxonomy_util_1 = require("../core/utils/taxonomy.util");
|
|
51
|
+
const term_util_1 = require("../core/utils/term.util");
|
|
52
|
+
const component_1 = require("../decorators/component");
|
|
53
|
+
const transactions_1 = require("../transactions");
|
|
54
|
+
const val = __importStar(require("../validators"));
|
|
55
|
+
const crud_1 = require("./crud");
|
|
56
|
+
const error_1 = require("./error");
|
|
57
|
+
let TermCrud = class TermCrud extends crud_1.Crud {
|
|
58
|
+
config;
|
|
59
|
+
constructor(components, config) {
|
|
60
|
+
super(components);
|
|
61
|
+
this.config = config;
|
|
62
|
+
}
|
|
63
|
+
async get(termId, options) {
|
|
64
|
+
const { context = "view", taxonomyName } = options ?? {};
|
|
65
|
+
const { user } = await this.getUser();
|
|
66
|
+
const termUtil = this.components.get(term_util_1.TermUtil);
|
|
67
|
+
const term = await termUtil.get(termId, taxonomyName);
|
|
68
|
+
if (!term.props?.term_id || 0 >= term.props.term_id) {
|
|
69
|
+
throw new Error("Term not found");
|
|
70
|
+
}
|
|
71
|
+
if (context === "edit" && !(await user.can("edit_term", termId))) {
|
|
72
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this term");
|
|
73
|
+
}
|
|
74
|
+
let data = {};
|
|
75
|
+
if (context == "edit") {
|
|
76
|
+
data = {
|
|
77
|
+
...term.props,
|
|
78
|
+
children: await term.children(),
|
|
79
|
+
metas: await term.meta.props(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
data = {
|
|
84
|
+
term_id: term.props.term_id,
|
|
85
|
+
count: term.props.count,
|
|
86
|
+
description: term.props.description,
|
|
87
|
+
name: term.props.name,
|
|
88
|
+
slug: term.props.slug,
|
|
89
|
+
parent: term.props.parent,
|
|
90
|
+
taxonomy: term.taxonomyName,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return this.returnValue(data);
|
|
94
|
+
}
|
|
95
|
+
async update(termId, taxonomyName, data) {
|
|
96
|
+
const { name, parent: parentId, slug, description } = data;
|
|
97
|
+
if (!name && !parent && !slug) {
|
|
98
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Nothing to update");
|
|
99
|
+
}
|
|
100
|
+
const term = (await this.get(termId, { context: "edit", taxonomyName }))
|
|
101
|
+
.data;
|
|
102
|
+
const termTrx = this.components.get(transactions_1.TermTrx);
|
|
103
|
+
await termTrx.update(term.term_id, taxonomyName, {
|
|
104
|
+
parentId,
|
|
105
|
+
slug,
|
|
106
|
+
name,
|
|
107
|
+
description,
|
|
108
|
+
});
|
|
109
|
+
return this.returnValue(true);
|
|
110
|
+
}
|
|
111
|
+
async canCreateTerm(taxonomyName) {
|
|
112
|
+
const { user } = await this.getUser();
|
|
113
|
+
const taxonomyUtil = this.components.get(taxonomy_util_1.TaxonomyUtil);
|
|
114
|
+
const taxonomy = await taxonomyUtil.get(taxonomyName);
|
|
115
|
+
const isHierarchical = taxonomy.props?.hierarchical;
|
|
116
|
+
if ((isHierarchical &&
|
|
117
|
+
!(await user.can(taxonomy.props?.capabilities?.["edit_terms"]))) ||
|
|
118
|
+
(!isHierarchical &&
|
|
119
|
+
!(await user.can(taxonomy.props?.capabilities?.["assign_terms"])))) {
|
|
120
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to create terms in this taxonomy");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async create(data) {
|
|
124
|
+
const { name, taxonomyName, parent: parentId, slug, description } = data;
|
|
125
|
+
await this.canCreateTerm(taxonomyName);
|
|
126
|
+
const termTrx = this.components.get(transactions_1.TermTrx);
|
|
127
|
+
return this.returnValue(await termTrx.insert(name, taxonomyName, {
|
|
128
|
+
parentId,
|
|
129
|
+
slug,
|
|
130
|
+
description,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
async syncObject(objectId, namesOrTermIds, taxonomyName, append = false) {
|
|
134
|
+
await this.canCreateTerm(taxonomyName);
|
|
135
|
+
const termTrx = this.components.get(transactions_1.TermTrx);
|
|
136
|
+
return this.returnValue(await termTrx.syncObject(objectId, namesOrTermIds, taxonomyName, append));
|
|
137
|
+
}
|
|
138
|
+
async delete(termId, taxonomyName) {
|
|
139
|
+
const { user } = await this.getUser();
|
|
140
|
+
if (!(await user.can("delete_term", termId))) {
|
|
141
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to delete this term");
|
|
142
|
+
}
|
|
143
|
+
const termTrx = this.components.get(transactions_1.TermTrx);
|
|
144
|
+
return this.returnValue(await termTrx.remove(termId, taxonomyName));
|
|
145
|
+
}
|
|
146
|
+
async taxonomies() {
|
|
147
|
+
const { user } = await this.getUser();
|
|
148
|
+
const role = await user.role();
|
|
149
|
+
if (role.is("anonymous")) {
|
|
150
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
151
|
+
}
|
|
152
|
+
const taxonomies = this.config.config.taxonomy.settings;
|
|
153
|
+
const data = [];
|
|
154
|
+
for (const entry of Object.entries(taxonomies)) {
|
|
155
|
+
const [name, taxonomy] = entry;
|
|
156
|
+
if (!taxonomy.showUi) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
data.push({
|
|
160
|
+
name,
|
|
161
|
+
hierarchical: taxonomy.hierarchical,
|
|
162
|
+
capabilities: taxonomy.capabilities,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return this.returnValue(data);
|
|
166
|
+
}
|
|
167
|
+
async list(taxonomyName, args, options) {
|
|
168
|
+
const { context = "view" } = options ?? {};
|
|
169
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
170
|
+
const termUtil = this.components.get(term_util_1.TermUtil);
|
|
171
|
+
const taxonomyUtil = this.components.get(taxonomy_util_1.TaxonomyUtil);
|
|
172
|
+
const parsedArgs = val.crud.termListParams.parse(args ?? {});
|
|
173
|
+
const { user } = await this.getUser();
|
|
174
|
+
const taxonomy = await taxonomyUtil.get(taxonomyName);
|
|
175
|
+
if (context === "edit" &&
|
|
176
|
+
!(await user.can(taxonomy.props?.capabilities?.["edit_terms"]))) {
|
|
177
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to edit this term");
|
|
178
|
+
}
|
|
179
|
+
if (parsedArgs.post) {
|
|
180
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
181
|
+
const post = await postUtil.get(parsedArgs.post);
|
|
182
|
+
if (!post.props?.ID || 0 >= post.props.ID) {
|
|
183
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid post ID");
|
|
184
|
+
}
|
|
185
|
+
if (taxonomy.props?.objectType !== post.props.post_type) {
|
|
186
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "post isn't associated with this taxonomy");
|
|
187
|
+
}
|
|
188
|
+
if (!(await postUtil.isPubliclyViewable(post)) &&
|
|
189
|
+
!(await user.can("read_post", post.props.ID))) {
|
|
190
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Sorry, you are not allowed to view terms for this post");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (parsedArgs.orderby == "term_order" && !parsedArgs.post) {
|
|
194
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "term_order can only be used with post");
|
|
195
|
+
}
|
|
196
|
+
const buildQuery = (query) => {
|
|
197
|
+
const { column } = query.alias;
|
|
198
|
+
const offset = (parsedArgs.page - 1) * parsedArgs.per_page;
|
|
199
|
+
const limit = parsedArgs.per_page;
|
|
200
|
+
query.where("taxonomy", taxonomyName);
|
|
201
|
+
query.builder
|
|
202
|
+
.offset(offset)
|
|
203
|
+
.limit(limit)
|
|
204
|
+
.groupBy(column("terms", "term_id"));
|
|
205
|
+
if (parsedArgs.orderby) {
|
|
206
|
+
query.builder.orderBy(parsedArgs.orderby == "description"
|
|
207
|
+
? column("term_taxonomy", parsedArgs.orderby)
|
|
208
|
+
: parsedArgs.orderby == "term_order"
|
|
209
|
+
? column("term_relationships", parsedArgs.orderby)
|
|
210
|
+
: column("terms", parsedArgs.orderby), parsedArgs.order);
|
|
211
|
+
}
|
|
212
|
+
if (Array.isArray(parsedArgs.include)) {
|
|
213
|
+
query.whereIn("term_id", parsedArgs.include);
|
|
214
|
+
}
|
|
215
|
+
if (Array.isArray(parsedArgs.exclude)) {
|
|
216
|
+
query.andWhereNot((query) => query.whereIn("term_id", parsedArgs.exclude));
|
|
217
|
+
}
|
|
218
|
+
if (parsedArgs.slug) {
|
|
219
|
+
query.where("slug", parsedArgs.slug);
|
|
220
|
+
}
|
|
221
|
+
if (parsedArgs.hide_empty) {
|
|
222
|
+
query.where("count", 0, ">");
|
|
223
|
+
}
|
|
224
|
+
if (parsedArgs.parent && taxonomy.props?.hierarchical) {
|
|
225
|
+
query.where("parent", parsedArgs.parent);
|
|
226
|
+
}
|
|
227
|
+
if (parsedArgs.post) {
|
|
228
|
+
query.withObjectIds([parsedArgs.post]);
|
|
229
|
+
}
|
|
230
|
+
if (parsedArgs.search) {
|
|
231
|
+
query.andWhere((query) => {
|
|
232
|
+
const searchColumns = ["slug", "name"];
|
|
233
|
+
for (const searchColumn of searchColumns) {
|
|
234
|
+
parsedArgs.search &&
|
|
235
|
+
query.or.whereLike(searchColumn, parsedArgs.search);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
const terms = (await queryUtil.terms((query) => {
|
|
241
|
+
buildQuery(query);
|
|
242
|
+
})) ?? [];
|
|
243
|
+
const counts = await queryUtil.terms((query) => {
|
|
244
|
+
buildQuery(query);
|
|
245
|
+
query.count("terms", "term_id");
|
|
246
|
+
}, val.query.resultCount);
|
|
247
|
+
const data = [];
|
|
248
|
+
for (const term of await termUtil.toTerms(terms)) {
|
|
249
|
+
const props = term.props;
|
|
250
|
+
if (!props)
|
|
251
|
+
continue;
|
|
252
|
+
if (context == "edit") {
|
|
253
|
+
data.push({
|
|
254
|
+
...props,
|
|
255
|
+
metas: await term.meta.props(),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
data.push({
|
|
260
|
+
term_id: props.term_id,
|
|
261
|
+
count: props.count,
|
|
262
|
+
description: props.description,
|
|
263
|
+
name: props.name,
|
|
264
|
+
slug: props.slug,
|
|
265
|
+
parent: props.parent,
|
|
266
|
+
taxonomy: taxonomyName,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const pagination = this.pagination({
|
|
271
|
+
page: parsedArgs.page,
|
|
272
|
+
limit: parsedArgs.per_page,
|
|
273
|
+
count: counts?.count ?? 0,
|
|
274
|
+
});
|
|
275
|
+
return this.returnValue(data, {
|
|
276
|
+
pagination,
|
|
277
|
+
context,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
exports.TermCrud = TermCrud;
|
|
282
|
+
exports.TermCrud = TermCrud = __decorate([
|
|
283
|
+
(0, component_1.component)(),
|
|
284
|
+
__metadata("design:paramtypes", [components_1.Components, config_1.Config])
|
|
285
|
+
], TermCrud);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Config } from "../config";
|
|
2
|
+
import { Components } from "../core/components";
|
|
3
|
+
import { Logger } from "../core/logger";
|
|
4
|
+
import { Crud } from "./crud";
|
|
5
|
+
export declare class UserSelfRegistrationCrud extends Crud {
|
|
6
|
+
private config;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(components: Components, config: Config, logger: Logger);
|
|
9
|
+
private checkPermission;
|
|
10
|
+
private checkEligibility;
|
|
11
|
+
update(input: {
|
|
12
|
+
eligibility: boolean;
|
|
13
|
+
}, options?: {
|
|
14
|
+
siteId?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
data: boolean;
|
|
17
|
+
info: undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Register a new user without activation key
|
|
21
|
+
*
|
|
22
|
+
* Use this when user registers through external id provider
|
|
23
|
+
*
|
|
24
|
+
* @param args - user_login, email, blog_id
|
|
25
|
+
* @returns boolean
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
registerWithoutActivation(args: {
|
|
29
|
+
email: string;
|
|
30
|
+
user_login?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
data: {
|
|
34
|
+
user_id: number;
|
|
35
|
+
user_login: string;
|
|
36
|
+
user_email: string;
|
|
37
|
+
first_name: string;
|
|
38
|
+
last_name: string;
|
|
39
|
+
};
|
|
40
|
+
info: undefined;
|
|
41
|
+
}>;
|
|
42
|
+
register(args: {
|
|
43
|
+
user_login: string;
|
|
44
|
+
email: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
data: boolean;
|
|
47
|
+
info: undefined;
|
|
48
|
+
}>;
|
|
49
|
+
activate(args: {
|
|
50
|
+
key: string;
|
|
51
|
+
user_login: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
data: [boolean, string];
|
|
54
|
+
info: undefined;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=user-self-registration.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-self-registration.crud.d.ts","sourceRoot":"","sources":["../../src/crud/user-self-registration.crud.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAOxC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,qBACa,wBAAyB,SAAQ,IAAI;IAG9C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;gBAFd,UAAU,EAAE,UAAU,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;YAKV,eAAe;YAmBf,gBAAgB;IAQxB,MAAM,CACV,KAAK,EAAE;QACL,WAAW,EAAE,OAAO,CAAC;KACtB,EACD,OAAO,GAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ;;;;IAaR;;;;;;;;OAQG;IACG,yBAAyB,CAAC,IAAI,EAAE;QACpC,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;;;;;;;;;;IA+DK,QAAQ,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;;;;IAapD,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;;;;CAmBzD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
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.UserSelfRegistrationCrud = void 0;
|
|
46
|
+
const common_1 = require("../common");
|
|
47
|
+
const config_1 = require("../config");
|
|
48
|
+
const components_1 = require("../core/components");
|
|
49
|
+
const current_1 = require("../core/current");
|
|
50
|
+
const logger_1 = require("../core/logger");
|
|
51
|
+
const options_1 = require("../core/options");
|
|
52
|
+
const user_self_registration_util_1 = require("../core/utils/user-self-registration.util");
|
|
53
|
+
const user_util_1 = require("../core/utils/user.util");
|
|
54
|
+
const component_1 = require("../decorators/component");
|
|
55
|
+
const transactions_1 = require("../transactions");
|
|
56
|
+
const vals = __importStar(require("../validators"));
|
|
57
|
+
const crud_1 = require("./crud");
|
|
58
|
+
const error_1 = require("./error");
|
|
59
|
+
let UserSelfRegistrationCrud = class UserSelfRegistrationCrud extends crud_1.Crud {
|
|
60
|
+
config;
|
|
61
|
+
logger;
|
|
62
|
+
constructor(components, config, logger) {
|
|
63
|
+
super(components);
|
|
64
|
+
this.config = config;
|
|
65
|
+
this.logger = logger;
|
|
66
|
+
}
|
|
67
|
+
async checkPermission(siteId) {
|
|
68
|
+
const { user } = await this.getUser();
|
|
69
|
+
// Multi site
|
|
70
|
+
if (this.config.isMultiSite()) {
|
|
71
|
+
const current = this.components.get(current_1.Current);
|
|
72
|
+
siteId = siteId ?? current.siteId;
|
|
73
|
+
if (!siteId || !(await user.can("manage_site_users", [siteId]))) {
|
|
74
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Single site
|
|
78
|
+
if (!this.config.isMultiSite() && !(await user.can("edit_users"))) {
|
|
79
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async checkEligibility(userSelfRegistrationUtil) {
|
|
83
|
+
if (!(await userSelfRegistrationUtil.canSignup())) {
|
|
84
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Not allowed");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async update(input, options = {}) {
|
|
88
|
+
await this.checkPermission(options.siteId);
|
|
89
|
+
const userSelfRegistrationUtil = this.components.get(user_self_registration_util_1.UserSelfRegistrationUtil);
|
|
90
|
+
return this.returnValue(await userSelfRegistrationUtil.changeEligibility(input.eligibility));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Register a new user without activation key
|
|
94
|
+
*
|
|
95
|
+
* Use this when user registers through external id provider
|
|
96
|
+
*
|
|
97
|
+
* @param args - user_login, email, blog_id
|
|
98
|
+
* @returns boolean
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
async registerWithoutActivation(args) {
|
|
102
|
+
const { email } = args;
|
|
103
|
+
const userSelfRegistrationUtil = this.components.get(user_self_registration_util_1.UserSelfRegistrationUtil);
|
|
104
|
+
await this.checkEligibility(userSelfRegistrationUtil);
|
|
105
|
+
const parsedEmail = vals.trx.userInsert.shape.user_email.safeParse(email);
|
|
106
|
+
if (!parsedEmail) {
|
|
107
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid email");
|
|
108
|
+
}
|
|
109
|
+
const userUtil = this.components.get(user_util_1.UserUtil);
|
|
110
|
+
let userLogin = args.user_login;
|
|
111
|
+
if (!userLogin) {
|
|
112
|
+
userLogin = await userUtil.getUniqueUserLogin();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const user = await userUtil.get(userLogin);
|
|
116
|
+
// User already exists
|
|
117
|
+
if (user.props?.ID) {
|
|
118
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "User already exists");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const { firstName, lastName } = common_1.formatting.parseName(args.name ?? "");
|
|
122
|
+
// Create a new user
|
|
123
|
+
const options = this.components.get(options_1.Options);
|
|
124
|
+
const defaultRole = await options.get("default_role");
|
|
125
|
+
if (!defaultRole) {
|
|
126
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Default role not found");
|
|
127
|
+
}
|
|
128
|
+
const userTrx = this.components.get(transactions_1.UserTrx);
|
|
129
|
+
const result = await userTrx.upsert({
|
|
130
|
+
user_login: userLogin,
|
|
131
|
+
display_name: userLogin,
|
|
132
|
+
user_email: email,
|
|
133
|
+
first_name: firstName,
|
|
134
|
+
last_name: lastName,
|
|
135
|
+
role: [defaultRole],
|
|
136
|
+
}, {
|
|
137
|
+
attachRole: true,
|
|
138
|
+
});
|
|
139
|
+
return this.returnValue({
|
|
140
|
+
user_id: result,
|
|
141
|
+
user_login: userLogin,
|
|
142
|
+
user_email: email,
|
|
143
|
+
first_name: firstName,
|
|
144
|
+
last_name: lastName,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async register(args) {
|
|
148
|
+
const userSelfRegistrationUtil = this.components.get(user_self_registration_util_1.UserSelfRegistrationUtil);
|
|
149
|
+
await this.checkEligibility(userSelfRegistrationUtil);
|
|
150
|
+
const { user_login: userLogin, email } = args;
|
|
151
|
+
const result = await userSelfRegistrationUtil.registerNew(userLogin, email);
|
|
152
|
+
return this.returnValue(!!result.id);
|
|
153
|
+
}
|
|
154
|
+
async activate(args) {
|
|
155
|
+
const { key: activationKey, user_login: userLogin } = args;
|
|
156
|
+
const userSelfRegistrationUtil = this.components.get(user_self_registration_util_1.UserSelfRegistrationUtil);
|
|
157
|
+
await this.checkEligibility(userSelfRegistrationUtil);
|
|
158
|
+
//try {
|
|
159
|
+
const result = await userSelfRegistrationUtil.activate(activationKey, userLogin);
|
|
160
|
+
return this.returnValue(result);
|
|
161
|
+
// } catch (e) {
|
|
162
|
+
// this.logger.error(String(e));
|
|
163
|
+
// throw new CrudError(StatusMessage.BAD_REQUEST, String(e));
|
|
164
|
+
// }
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
exports.UserSelfRegistrationCrud = UserSelfRegistrationCrud;
|
|
168
|
+
exports.UserSelfRegistrationCrud = UserSelfRegistrationCrud = __decorate([
|
|
169
|
+
(0, component_1.component)(),
|
|
170
|
+
__metadata("design:paramtypes", [components_1.Components,
|
|
171
|
+
config_1.Config,
|
|
172
|
+
logger_1.Logger])
|
|
173
|
+
], UserSelfRegistrationCrud);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Config } from "../config";
|
|
3
|
+
import { Components } from "../core/components";
|
|
4
|
+
import { User } from "../core/user";
|
|
5
|
+
import { UserUtil } from "../core/utils/user.util";
|
|
6
|
+
import * as val from "../validators";
|
|
7
|
+
import { Crud } from "./crud";
|
|
8
|
+
import type * as types from "../types";
|
|
9
|
+
type UserUpsert = z.infer<typeof val.trx.userUpsert>;
|
|
10
|
+
type DataType<T extends "view" | "edit" | "embed"> = T extends "edit" ? Exclude<User["props"], "user_pass"> & {
|
|
11
|
+
metas: Record<string, any>;
|
|
12
|
+
roles: string[];
|
|
13
|
+
capabilities: string[];
|
|
14
|
+
posts: number;
|
|
15
|
+
} : {
|
|
16
|
+
ID: number;
|
|
17
|
+
display_name: string;
|
|
18
|
+
user_nicename: string;
|
|
19
|
+
user_login: string;
|
|
20
|
+
user_url: string;
|
|
21
|
+
};
|
|
22
|
+
type ReturnTypeUserUtilGetSites = Awaited<ReturnType<InstanceType<typeof UserUtil>["getSites"]>>;
|
|
23
|
+
type ReturnTypeUserUtilGetBlogs = Awaited<ReturnType<InstanceType<typeof UserUtil>["getBlogs"]>>;
|
|
24
|
+
type Blog = Pick<NonNullable<ReturnTypeUserUtilGetSites["primary_blog"]> & ReturnTypeUserUtilGetBlogs[number], "site_id" | "blog_id" | "blogname" | "rolenames" | "capabilities"> & {
|
|
25
|
+
blog_roles: Record<string, types.Role> | undefined;
|
|
26
|
+
};
|
|
27
|
+
type DataTypeGetSites = {
|
|
28
|
+
user: ReturnTypeUserUtilGetSites["user"];
|
|
29
|
+
primary_blog: Blog;
|
|
30
|
+
is_multisite: ReturnTypeUserUtilGetSites["is_multisite"];
|
|
31
|
+
sites: undefined | {
|
|
32
|
+
site_id: number;
|
|
33
|
+
sitename: string;
|
|
34
|
+
siteurl: string;
|
|
35
|
+
is_superadmin: boolean;
|
|
36
|
+
blogs: Blog[] | undefined;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
export declare class UserCrud extends Crud {
|
|
40
|
+
private config;
|
|
41
|
+
constructor(components: Components, config: Config);
|
|
42
|
+
getAsUpsert(userId: number): Promise<{
|
|
43
|
+
data: {
|
|
44
|
+
description: string;
|
|
45
|
+
spam: number;
|
|
46
|
+
deleted: number;
|
|
47
|
+
user_login: string;
|
|
48
|
+
user_email: string;
|
|
49
|
+
user_pass: string;
|
|
50
|
+
user_nicename: string;
|
|
51
|
+
user_activation_key: string;
|
|
52
|
+
user_status: number;
|
|
53
|
+
display_name: string;
|
|
54
|
+
meta_input: Record<string, any>;
|
|
55
|
+
nickname: string;
|
|
56
|
+
first_name: string;
|
|
57
|
+
last_name: string;
|
|
58
|
+
rich_editing: number | "false" | "true";
|
|
59
|
+
syntax_highlighting: number | "false" | "true";
|
|
60
|
+
comment_shortcuts: number | "false" | "true";
|
|
61
|
+
admin_color: string;
|
|
62
|
+
use_ssl: string;
|
|
63
|
+
show_admin_bar_front: number | "false" | "true";
|
|
64
|
+
role?: string[] | "editor" | "author" | "superadmin" | "administrator" | "contributor" | "subscriber" | "anonymous" | ("editor" | "author" | "superadmin" | "administrator" | "contributor" | "subscriber" | "anonymous")[] | undefined;
|
|
65
|
+
ID?: number | undefined;
|
|
66
|
+
user_url?: string | undefined;
|
|
67
|
+
user_registered?: string | undefined;
|
|
68
|
+
locale?: string | undefined;
|
|
69
|
+
};
|
|
70
|
+
info: undefined;
|
|
71
|
+
}>;
|
|
72
|
+
private checkRoleUpdatePermission;
|
|
73
|
+
get<T extends "view" | "edit" | "embed">(userId?: number, options?: Partial<{
|
|
74
|
+
context: T;
|
|
75
|
+
}>): Promise<{
|
|
76
|
+
data: DataType<T>;
|
|
77
|
+
info: undefined;
|
|
78
|
+
}>;
|
|
79
|
+
getBlogs(userId: number): Promise<{
|
|
80
|
+
data: {
|
|
81
|
+
site_id: number;
|
|
82
|
+
blog_id: number;
|
|
83
|
+
blogname: string | undefined;
|
|
84
|
+
rolenames: string[] | undefined;
|
|
85
|
+
}[];
|
|
86
|
+
info: undefined;
|
|
87
|
+
}>;
|
|
88
|
+
getAvailableSites(): Promise<{
|
|
89
|
+
data: DataTypeGetSites;
|
|
90
|
+
info: undefined;
|
|
91
|
+
}>;
|
|
92
|
+
create(input: Partial<UserUpsert>): Promise<{
|
|
93
|
+
data: types.WpUsers;
|
|
94
|
+
info: undefined;
|
|
95
|
+
}>;
|
|
96
|
+
updateSuperAdmin(userId: number, options?: Partial<{
|
|
97
|
+
siteId: number;
|
|
98
|
+
blogId: number;
|
|
99
|
+
remove: boolean;
|
|
100
|
+
}>): Promise<{
|
|
101
|
+
data: boolean;
|
|
102
|
+
info: undefined;
|
|
103
|
+
}>;
|
|
104
|
+
updateRole(userId: number, role: string[], options?: Partial<{
|
|
105
|
+
siteId: number;
|
|
106
|
+
blogId: number;
|
|
107
|
+
}>): Promise<{
|
|
108
|
+
data: boolean;
|
|
109
|
+
info: undefined;
|
|
110
|
+
}>;
|
|
111
|
+
update(userId: number, data: Partial<UserUpsert>, options?: Partial<{
|
|
112
|
+
siteId: number;
|
|
113
|
+
blogId: number;
|
|
114
|
+
attachRole: boolean;
|
|
115
|
+
removeRole: boolean;
|
|
116
|
+
}>): Promise<{
|
|
117
|
+
data: number;
|
|
118
|
+
info: undefined;
|
|
119
|
+
}>;
|
|
120
|
+
updatePassword(userId: number, newPassword: string): Promise<{
|
|
121
|
+
data: number;
|
|
122
|
+
info: undefined;
|
|
123
|
+
}>;
|
|
124
|
+
delete(userId: number, options?: Partial<{
|
|
125
|
+
reassign: number;
|
|
126
|
+
reassignList: Record<number, number>;
|
|
127
|
+
}>): Promise<{
|
|
128
|
+
data: boolean;
|
|
129
|
+
info: undefined;
|
|
130
|
+
}>;
|
|
131
|
+
list<T extends "view" | "edit" | "embed">(args?: Partial<z.infer<typeof val.crud.userListParams>>, options?: {
|
|
132
|
+
context?: T;
|
|
133
|
+
}): Promise<{
|
|
134
|
+
data: DataType<T>[];
|
|
135
|
+
info: {
|
|
136
|
+
pagination: {
|
|
137
|
+
page: number;
|
|
138
|
+
limit: number;
|
|
139
|
+
totalPage: number;
|
|
140
|
+
count: number;
|
|
141
|
+
};
|
|
142
|
+
context: string | T;
|
|
143
|
+
};
|
|
144
|
+
}>;
|
|
145
|
+
}
|
|
146
|
+
export {};
|
|
147
|
+
//# sourceMappingURL=user.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.crud.d.ts","sourceRoot":"","sources":["../../src/crud/user.crud.ts"],"names":[],"mappings":"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"}
|