@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,395 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Capabilities = void 0;
|
|
13
|
+
const constants_1 = require("../../../constants");
|
|
14
|
+
const hooks_1 = require("../../../decorators/hooks");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
let Capabilities = class Capabilities {
|
|
17
|
+
// delete_user
|
|
18
|
+
async canDeleteUser(...args) {
|
|
19
|
+
const [capabilities, context, user, targetUserId] = args;
|
|
20
|
+
capabilities.delete("delete_user");
|
|
21
|
+
if (!context.config.isMultiSite()) {
|
|
22
|
+
return capabilities.add("delete_users");
|
|
23
|
+
}
|
|
24
|
+
const userLogin = user?.props?.user_login;
|
|
25
|
+
if (typeof targetUserId !== "number" || !userLogin) {
|
|
26
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
27
|
+
}
|
|
28
|
+
const targetSiteIds = await context.utils.user.getSiteIds(targetUserId);
|
|
29
|
+
if (targetSiteIds.length > 0) {
|
|
30
|
+
const [isTrue] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
31
|
+
siteIds: targetSiteIds,
|
|
32
|
+
});
|
|
33
|
+
if (!isTrue) {
|
|
34
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return capabilities;
|
|
38
|
+
}
|
|
39
|
+
// manage_network_user
|
|
40
|
+
async canManageNetworkUser(...args) {
|
|
41
|
+
const [capabilities, context, action, user, targetUserId] = args;
|
|
42
|
+
if (action !== "manage_network_user") {
|
|
43
|
+
return capabilities;
|
|
44
|
+
}
|
|
45
|
+
capabilities.delete("manage_network_user");
|
|
46
|
+
if (!context.config.isMultiSite()) {
|
|
47
|
+
return capabilities.add("edit_users");
|
|
48
|
+
}
|
|
49
|
+
const userLogin = user?.props?.user_login;
|
|
50
|
+
if (typeof targetUserId !== "number" || !userLogin) {
|
|
51
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
52
|
+
}
|
|
53
|
+
const targetSiteIds = await context.utils.user.getSiteIds(targetUserId);
|
|
54
|
+
if (targetSiteIds.length > 0) {
|
|
55
|
+
const [isTrue] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
56
|
+
siteIds: targetSiteIds,
|
|
57
|
+
});
|
|
58
|
+
if (!isTrue) {
|
|
59
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return capabilities;
|
|
63
|
+
}
|
|
64
|
+
// manage_network_users
|
|
65
|
+
async canManageNetworkUsers(...args) {
|
|
66
|
+
const [capabilities, context, user, filterArgs] = args;
|
|
67
|
+
if (!context.config.isMultiSite()) {
|
|
68
|
+
capabilities.delete("manage_network_users");
|
|
69
|
+
return capabilities.add("edit_users");
|
|
70
|
+
}
|
|
71
|
+
const parsed = zod_1.z.array(zod_1.z.number()).safeParse(filterArgs);
|
|
72
|
+
if (!parsed.success) {
|
|
73
|
+
return capabilities;
|
|
74
|
+
}
|
|
75
|
+
const blogIds = parsed.data;
|
|
76
|
+
const siteIds = ((await context.utils.query.blogs((query) => {
|
|
77
|
+
query.whereIn("blog_id", blogIds);
|
|
78
|
+
})) ?? []).map((blog) => blog.site_id);
|
|
79
|
+
if (0 >= siteIds.length) {
|
|
80
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
81
|
+
}
|
|
82
|
+
return await this.canManageSiteUsers(capabilities, context, "manage_site_users", user, siteIds);
|
|
83
|
+
}
|
|
84
|
+
// list_blog_users
|
|
85
|
+
async canListBlogUsers(...args) {
|
|
86
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
87
|
+
if (action !== "list_blog_users") {
|
|
88
|
+
return capabilities;
|
|
89
|
+
}
|
|
90
|
+
capabilities.delete("list_blog_users");
|
|
91
|
+
if (!context.config.isMultiSite()) {
|
|
92
|
+
return capabilities.add("list_users");
|
|
93
|
+
}
|
|
94
|
+
let blogIds = [];
|
|
95
|
+
if (!filterArgs ||
|
|
96
|
+
!Array.isArray(filterArgs) ||
|
|
97
|
+
filterArgs.length !==
|
|
98
|
+
filterArgs.filter((v) => typeof v == "number").length) {
|
|
99
|
+
if (!context.current.blogId) {
|
|
100
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
101
|
+
}
|
|
102
|
+
blogIds.push(context.current.blogId);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
blogIds = filterArgs;
|
|
106
|
+
}
|
|
107
|
+
if (!(await user.hasCapabilities(["list_users"], {
|
|
108
|
+
blogIds,
|
|
109
|
+
}))) {
|
|
110
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
111
|
+
}
|
|
112
|
+
return capabilities;
|
|
113
|
+
}
|
|
114
|
+
// manage_blog_users
|
|
115
|
+
async canManageBlogUsers(...args) {
|
|
116
|
+
const [capabilities, context, action, user, ...filterArgs] = args;
|
|
117
|
+
if (action !== "manage_blog_users") {
|
|
118
|
+
return capabilities;
|
|
119
|
+
}
|
|
120
|
+
capabilities.delete("manage_blog_users");
|
|
121
|
+
const result = await this.canManageNetworkUsers(capabilities, context, user, ...filterArgs);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
// manage_site_users
|
|
125
|
+
async canManageSiteUsers(...args) {
|
|
126
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
127
|
+
if (action !== "manage_site_users") {
|
|
128
|
+
return capabilities;
|
|
129
|
+
}
|
|
130
|
+
capabilities.delete("manage_site_users");
|
|
131
|
+
if (!context.config.isMultiSite()) {
|
|
132
|
+
return capabilities.add("edit_users");
|
|
133
|
+
}
|
|
134
|
+
if (!filterArgs ||
|
|
135
|
+
!Array.isArray(filterArgs) ||
|
|
136
|
+
filterArgs.length !==
|
|
137
|
+
filterArgs.filter((v) => typeof v == "number").length) {
|
|
138
|
+
return capabilities;
|
|
139
|
+
}
|
|
140
|
+
const siteIds = filterArgs;
|
|
141
|
+
const userLogin = user?.props?.user_login;
|
|
142
|
+
if (!userLogin) {
|
|
143
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
144
|
+
}
|
|
145
|
+
const [isTrue] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
146
|
+
siteIds,
|
|
147
|
+
});
|
|
148
|
+
if (!isTrue) {
|
|
149
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
150
|
+
}
|
|
151
|
+
return capabilities;
|
|
152
|
+
}
|
|
153
|
+
// edit_admin_roles
|
|
154
|
+
// manage_roles
|
|
155
|
+
async canEditAdminRole(...args) {
|
|
156
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
157
|
+
if (action !== "edit_admin_roles" && action !== "manage_roles") {
|
|
158
|
+
return capabilities;
|
|
159
|
+
}
|
|
160
|
+
capabilities.delete("edit_admin_roles");
|
|
161
|
+
capabilities.delete("manage_roles");
|
|
162
|
+
if (!user.props?.user_login) {
|
|
163
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
164
|
+
}
|
|
165
|
+
if (!context.config.isMultiSite()) {
|
|
166
|
+
capabilities.add("edit_users");
|
|
167
|
+
return capabilities;
|
|
168
|
+
}
|
|
169
|
+
// Check for superadmin in multisite
|
|
170
|
+
const blogId = filterArgs ?? context.current.blogId;
|
|
171
|
+
if (!blogId) {
|
|
172
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
173
|
+
}
|
|
174
|
+
const [isTrue] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
175
|
+
blogIds: [blogId],
|
|
176
|
+
});
|
|
177
|
+
if (!isTrue) {
|
|
178
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
179
|
+
}
|
|
180
|
+
return capabilities;
|
|
181
|
+
}
|
|
182
|
+
// manage_network
|
|
183
|
+
// manage_network_options
|
|
184
|
+
async canManageNetwork(...args) {
|
|
185
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
186
|
+
if (action !== "manage_network" && action !== "manage_network_options") {
|
|
187
|
+
return capabilities;
|
|
188
|
+
}
|
|
189
|
+
capabilities.delete("manage_network");
|
|
190
|
+
capabilities.delete("manage_network_options");
|
|
191
|
+
if (!context.config.isMultiSite()) {
|
|
192
|
+
const role = await user.role();
|
|
193
|
+
if (!role.isAdmin()) {
|
|
194
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
195
|
+
}
|
|
196
|
+
return capabilities;
|
|
197
|
+
}
|
|
198
|
+
const parsed = zod_1.z.array(zod_1.z.number()).safeParse(filterArgs);
|
|
199
|
+
if (!parsed.success) {
|
|
200
|
+
return capabilities;
|
|
201
|
+
}
|
|
202
|
+
const siteIds = parsed.data;
|
|
203
|
+
const [isTrue] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
204
|
+
siteIds,
|
|
205
|
+
});
|
|
206
|
+
if (!isTrue) {
|
|
207
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
208
|
+
}
|
|
209
|
+
return capabilities;
|
|
210
|
+
}
|
|
211
|
+
// edit_user_roles
|
|
212
|
+
async canEditUserRole(...args) {
|
|
213
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
214
|
+
if (action !== "edit_user_roles") {
|
|
215
|
+
return capabilities;
|
|
216
|
+
}
|
|
217
|
+
capabilities.delete("edit_user_roles");
|
|
218
|
+
if (!user?.props?.user_login) {
|
|
219
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
220
|
+
}
|
|
221
|
+
if (!context.config.isMultiSite()) {
|
|
222
|
+
capabilities.add("promote_users");
|
|
223
|
+
capabilities.add("remove_users");
|
|
224
|
+
return capabilities;
|
|
225
|
+
}
|
|
226
|
+
const parsed = zod_1.z.array(zod_1.z.number()).safeParse(filterArgs);
|
|
227
|
+
if (!parsed.success) {
|
|
228
|
+
capabilities.add("promote_users");
|
|
229
|
+
capabilities.add("remove_users");
|
|
230
|
+
return capabilities;
|
|
231
|
+
}
|
|
232
|
+
const blogIds = parsed.data;
|
|
233
|
+
if (!(await user.hasCapabilities(["promote_users", "remove_users"], {
|
|
234
|
+
blogIds,
|
|
235
|
+
}))) {
|
|
236
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
237
|
+
}
|
|
238
|
+
return capabilities;
|
|
239
|
+
}
|
|
240
|
+
// manage_sites
|
|
241
|
+
// delete_sites
|
|
242
|
+
// create_sites
|
|
243
|
+
// manage_options
|
|
244
|
+
async canManageBlogs(...args) {
|
|
245
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
246
|
+
const actions = [
|
|
247
|
+
"manage_sites",
|
|
248
|
+
"delete_sites",
|
|
249
|
+
"create_sites",
|
|
250
|
+
"manage_options",
|
|
251
|
+
];
|
|
252
|
+
if (!context.config.isMultiSite() || !actions.includes(action)) {
|
|
253
|
+
return capabilities;
|
|
254
|
+
}
|
|
255
|
+
const parsed = zod_1.z.array(zod_1.z.number()).safeParse(filterArgs);
|
|
256
|
+
if (!parsed.success) {
|
|
257
|
+
return capabilities;
|
|
258
|
+
}
|
|
259
|
+
const blogIds = parsed.data;
|
|
260
|
+
const [isTrue] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
261
|
+
blogIds,
|
|
262
|
+
});
|
|
263
|
+
if (!isTrue) {
|
|
264
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
265
|
+
}
|
|
266
|
+
capabilities.add(action);
|
|
267
|
+
return capabilities;
|
|
268
|
+
}
|
|
269
|
+
// manage_terms
|
|
270
|
+
// edit_terms
|
|
271
|
+
// delete_terms
|
|
272
|
+
// assign_terms
|
|
273
|
+
async canManageTerms(...args) {
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
275
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
276
|
+
const actions = [
|
|
277
|
+
"manage_terms",
|
|
278
|
+
"edit_terms",
|
|
279
|
+
"delete_terms",
|
|
280
|
+
"assign_terms",
|
|
281
|
+
];
|
|
282
|
+
if (!actions.includes(action)) {
|
|
283
|
+
return capabilities;
|
|
284
|
+
}
|
|
285
|
+
capabilities.delete(action);
|
|
286
|
+
capabilities.add("manage_categories");
|
|
287
|
+
return capabilities;
|
|
288
|
+
}
|
|
289
|
+
// create_users
|
|
290
|
+
async canCreateUsers(...args) {
|
|
291
|
+
const [capabilities, context, action, user, filterArgs] = args;
|
|
292
|
+
if (!context.config.isMultiSite() || action !== "create_users") {
|
|
293
|
+
return capabilities;
|
|
294
|
+
}
|
|
295
|
+
const parsed = zod_1.z.array(zod_1.z.number()).safeParse(filterArgs);
|
|
296
|
+
if (!parsed.success) {
|
|
297
|
+
return capabilities;
|
|
298
|
+
}
|
|
299
|
+
const siteIds = parsed.data;
|
|
300
|
+
const [isSuperAdmin] = await context.utils.user.checkSuperAdminStatus(user, {
|
|
301
|
+
siteIds,
|
|
302
|
+
});
|
|
303
|
+
// Check if a site allows admin to add new users
|
|
304
|
+
if (!isSuperAdmin) {
|
|
305
|
+
for (const siteId of siteIds) {
|
|
306
|
+
const canAddNewUser = await context.options.get("add_new_users", {
|
|
307
|
+
siteId,
|
|
308
|
+
});
|
|
309
|
+
if (1 !== canAddNewUser) {
|
|
310
|
+
return capabilities.add(constants_1.DO_NOT_ALLOW);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// core/capabilities.ts might've disallowed permission.
|
|
315
|
+
capabilities.delete(constants_1.DO_NOT_ALLOW);
|
|
316
|
+
capabilities.add(action);
|
|
317
|
+
return capabilities;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
exports.Capabilities = Capabilities;
|
|
321
|
+
__decorate([
|
|
322
|
+
(0, hooks_1.filter)("core_map_meta_cap_delete_user"),
|
|
323
|
+
__metadata("design:type", Function),
|
|
324
|
+
__metadata("design:paramtypes", [String]),
|
|
325
|
+
__metadata("design:returntype", Promise)
|
|
326
|
+
], Capabilities.prototype, "canDeleteUser", null);
|
|
327
|
+
__decorate([
|
|
328
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
329
|
+
__metadata("design:type", Function),
|
|
330
|
+
__metadata("design:paramtypes", [String]),
|
|
331
|
+
__metadata("design:returntype", Promise)
|
|
332
|
+
], Capabilities.prototype, "canManageNetworkUser", null);
|
|
333
|
+
__decorate([
|
|
334
|
+
(0, hooks_1.filter)("core_map_meta_cap_manage_network_users"),
|
|
335
|
+
__metadata("design:type", Function),
|
|
336
|
+
__metadata("design:paramtypes", [String]),
|
|
337
|
+
__metadata("design:returntype", Promise)
|
|
338
|
+
], Capabilities.prototype, "canManageNetworkUsers", null);
|
|
339
|
+
__decorate([
|
|
340
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
341
|
+
__metadata("design:type", Function),
|
|
342
|
+
__metadata("design:paramtypes", [String]),
|
|
343
|
+
__metadata("design:returntype", Promise)
|
|
344
|
+
], Capabilities.prototype, "canListBlogUsers", null);
|
|
345
|
+
__decorate([
|
|
346
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
347
|
+
__metadata("design:type", Function),
|
|
348
|
+
__metadata("design:paramtypes", [String]),
|
|
349
|
+
__metadata("design:returntype", Promise)
|
|
350
|
+
], Capabilities.prototype, "canManageBlogUsers", null);
|
|
351
|
+
__decorate([
|
|
352
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
353
|
+
__metadata("design:type", Function),
|
|
354
|
+
__metadata("design:paramtypes", [String]),
|
|
355
|
+
__metadata("design:returntype", Promise)
|
|
356
|
+
], Capabilities.prototype, "canManageSiteUsers", null);
|
|
357
|
+
__decorate([
|
|
358
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
359
|
+
__metadata("design:type", Function),
|
|
360
|
+
__metadata("design:paramtypes", [String]),
|
|
361
|
+
__metadata("design:returntype", Promise)
|
|
362
|
+
], Capabilities.prototype, "canEditAdminRole", null);
|
|
363
|
+
__decorate([
|
|
364
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
365
|
+
__metadata("design:type", Function),
|
|
366
|
+
__metadata("design:paramtypes", [String]),
|
|
367
|
+
__metadata("design:returntype", Promise)
|
|
368
|
+
], Capabilities.prototype, "canManageNetwork", null);
|
|
369
|
+
__decorate([
|
|
370
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
371
|
+
__metadata("design:type", Function),
|
|
372
|
+
__metadata("design:paramtypes", [String]),
|
|
373
|
+
__metadata("design:returntype", Promise)
|
|
374
|
+
], Capabilities.prototype, "canEditUserRole", null);
|
|
375
|
+
__decorate([
|
|
376
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
377
|
+
__metadata("design:type", Function),
|
|
378
|
+
__metadata("design:paramtypes", [String]),
|
|
379
|
+
__metadata("design:returntype", Promise)
|
|
380
|
+
], Capabilities.prototype, "canManageBlogs", null);
|
|
381
|
+
__decorate([
|
|
382
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
383
|
+
__metadata("design:type", Function),
|
|
384
|
+
__metadata("design:paramtypes", [String]),
|
|
385
|
+
__metadata("design:returntype", Promise)
|
|
386
|
+
], Capabilities.prototype, "canManageTerms", null);
|
|
387
|
+
__decorate([
|
|
388
|
+
(0, hooks_1.filter)("core_map_meta_cap"),
|
|
389
|
+
__metadata("design:type", Function),
|
|
390
|
+
__metadata("design:paramtypes", [String]),
|
|
391
|
+
__metadata("design:returntype", Promise)
|
|
392
|
+
], Capabilities.prototype, "canCreateUsers", null);
|
|
393
|
+
exports.Capabilities = Capabilities = __decorate([
|
|
394
|
+
(0, hooks_1.hook)("core_filter_capabilities")
|
|
395
|
+
], Capabilities);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as types from "../../types";
|
|
2
|
+
export declare class HooksCommand {
|
|
3
|
+
#private;
|
|
4
|
+
static createFilter<T1, T2 = null>(): types.hooks.CommandFilter<T1, T2>;
|
|
5
|
+
static createNamedFilter<T1 extends keyof types.hooks.Filters>(name: T1): types.hooks.FiltersReturnType<T1> extends Promise<any> ? types.hooks.CommandFilter<Promise<types.hooks.FilterParameters<T1>[0]>, types.hooks.CommandFilterSecondParam<T1>> : types.hooks.CommandFilter<types.hooks.FilterParameters<T1>[0], types.hooks.CommandFilterSecondParam<T1>>;
|
|
6
|
+
static createAction<P>(): types.hooks.CommandAction<P>;
|
|
7
|
+
static createNamedAction<T1 extends keyof types.hooks.Actions>(name: T1): types.hooks.CommandAction<types.hooks.ActionParameters<T1>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=hooks-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-command.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/hooks-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAE1C,qBAAa,YAAY;;IAIvB,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC;IAMvE,MAAM,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAGhE,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GACvD,KAAK,CAAC,KAAK,CAAC,aAAa,CACvB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5C,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,EAAE,CAAC,CACzC,GACD,KAAK,CAAC,KAAK,CAAC,aAAa,CACvB,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EACnC,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,EAAE,CAAC,CACzC;IAGP,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAMtD,MAAM,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAGhE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;CAEnE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HooksCommand = void 0;
|
|
4
|
+
class HooksCommand {
|
|
5
|
+
static #idFilter = 0;
|
|
6
|
+
static #idAction = 0;
|
|
7
|
+
static createFilter() {
|
|
8
|
+
return {
|
|
9
|
+
id: `__command_LmnOp_filter_${this.#idFilter++}`,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
static createNamedFilter(name) {
|
|
13
|
+
return {
|
|
14
|
+
id: name,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
static createAction() {
|
|
18
|
+
return {
|
|
19
|
+
id: `__command_LmnOp_action_${this.#idAction++}`,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static createNamedAction(name) {
|
|
23
|
+
return {
|
|
24
|
+
id: name,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.HooksCommand = HooksCommand;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { Action } from "./action";
|
|
3
|
+
import { Filter } from "./filter";
|
|
4
|
+
import type * as types from "../../types";
|
|
5
|
+
export declare const FILTER: unique symbol;
|
|
6
|
+
export declare const ACTION: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Represents a class that provides reflection utilities for defining and registering hooks.
|
|
9
|
+
*/
|
|
10
|
+
export declare class HooksReflect {
|
|
11
|
+
/**
|
|
12
|
+
* Defines a hook for a given event name with the specified priority.
|
|
13
|
+
*
|
|
14
|
+
* @param metakey - The metadata key used for storing hook information.
|
|
15
|
+
* @param eventName - The name of the event.
|
|
16
|
+
* @param priority - The priority of the hook.
|
|
17
|
+
* @param args - The arguments containing the target, propertyKey, and descriptor.
|
|
18
|
+
*/
|
|
19
|
+
private static define;
|
|
20
|
+
/**
|
|
21
|
+
* Defines a filter hook for a given event name with the specified priority.
|
|
22
|
+
* @param eventName - The name of the event.
|
|
23
|
+
* @param priority - The priority of the hook.
|
|
24
|
+
* @param args - The arguments containing the target, propertyKey, and descriptor.
|
|
25
|
+
*/
|
|
26
|
+
static defineFilter(eventName: string, priority: number, args: [target: any, propertyKey: string, descriptor: PropertyDescriptor]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Defines an action hook for a given event name.
|
|
29
|
+
* @param eventName - The name of the event.
|
|
30
|
+
* @param args - The arguments containing the target, propertyKey, and descriptor.
|
|
31
|
+
*/
|
|
32
|
+
static defineAction(eventName: string, args: [target: any, propertyKey: string, descriptor: PropertyDescriptor]): void;
|
|
33
|
+
/**
|
|
34
|
+
* Registers the defined hooks for the given hook types, instance, and target.
|
|
35
|
+
*
|
|
36
|
+
* @param hookTypes - The hook types to register (filter and action).
|
|
37
|
+
* @param instance - The instance containing the hook methods.
|
|
38
|
+
* @param target - The target object to register the hooks on.
|
|
39
|
+
*/
|
|
40
|
+
static register<TFilters = types.hooks.Filters, TActions = types.hooks.Actions>(hookTypes: [Filter<TFilters>, Action<TActions>], instance: any, target: any): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=hooks-reflect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-reflect.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/hooks-reflect.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAG1C,eAAO,MAAM,MAAM,eAAkC,CAAC;AACtD,eAAO,MAAM,MAAM,eAAkC,CAAC;AAItD;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,MAAM;IAuBrB;;;;;OAKG;WACW,YAAY,CACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,CAAC;IAK1E;;;;OAIG;WACW,YAAY,CACxB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,CAAC;IAK1E;;;;;;OAMG;WACW,QAAQ,CACpB,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAC9B,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAE9B,SAAS,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAC/C,QAAQ,EAAE,GAAG,EACb,MAAM,EAAE,GAAG;CAkBd"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HooksReflect = exports.ACTION = exports.FILTER = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const prefix = "__REFLECT_METADATA_KEY_HOOKS_";
|
|
6
|
+
exports.FILTER = Symbol.for(`${prefix}FILTER__`);
|
|
7
|
+
exports.ACTION = Symbol.for(`${prefix}ACTION__`);
|
|
8
|
+
/**
|
|
9
|
+
* Represents a class that provides reflection utilities for defining and registering hooks.
|
|
10
|
+
*/
|
|
11
|
+
class HooksReflect {
|
|
12
|
+
/**
|
|
13
|
+
* Defines a hook for a given event name with the specified priority.
|
|
14
|
+
*
|
|
15
|
+
* @param metakey - The metadata key used for storing hook information.
|
|
16
|
+
* @param eventName - The name of the event.
|
|
17
|
+
* @param priority - The priority of the hook.
|
|
18
|
+
* @param args - The arguments containing the target, propertyKey, and descriptor.
|
|
19
|
+
*/
|
|
20
|
+
static define(metakey, eventName, priority, args) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
const [target, propertyKey, descriptor] = args;
|
|
23
|
+
const hookMap = Reflect.getMetadata(metakey, target.constructor) ?? new Map();
|
|
24
|
+
const hooks = hookMap.get(eventName) ?? [];
|
|
25
|
+
if (hooks.includes([priority, propertyKey])) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
hookMap.set(eventName, [...hooks, [priority, propertyKey]]);
|
|
29
|
+
Reflect.defineMetadata(metakey, hookMap, target.constructor);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Defines a filter hook for a given event name with the specified priority.
|
|
33
|
+
* @param eventName - The name of the event.
|
|
34
|
+
* @param priority - The priority of the hook.
|
|
35
|
+
* @param args - The arguments containing the target, propertyKey, and descriptor.
|
|
36
|
+
*/
|
|
37
|
+
static defineFilter(eventName, priority, args) {
|
|
38
|
+
HooksReflect.define(exports.FILTER, eventName, priority, args);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Defines an action hook for a given event name.
|
|
42
|
+
* @param eventName - The name of the event.
|
|
43
|
+
* @param args - The arguments containing the target, propertyKey, and descriptor.
|
|
44
|
+
*/
|
|
45
|
+
static defineAction(eventName, args) {
|
|
46
|
+
HooksReflect.define(exports.ACTION, eventName, 0, args);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Registers the defined hooks for the given hook types, instance, and target.
|
|
50
|
+
*
|
|
51
|
+
* @param hookTypes - The hook types to register (filter and action).
|
|
52
|
+
* @param instance - The instance containing the hook methods.
|
|
53
|
+
* @param target - The target object to register the hooks on.
|
|
54
|
+
*/
|
|
55
|
+
static register(hookTypes, instance, target) {
|
|
56
|
+
const [filter, action] = hookTypes;
|
|
57
|
+
for (const metakey of [exports.FILTER, exports.ACTION]) {
|
|
58
|
+
const hookMap = Reflect.getMetadata(metakey, target);
|
|
59
|
+
for (const [eventName, values] of hookMap ?? []) {
|
|
60
|
+
values.forEach(([priority, propertyKey]) => {
|
|
61
|
+
const listener = instance[propertyKey].bind(instance);
|
|
62
|
+
if (metakey === exports.FILTER) {
|
|
63
|
+
filter.add(eventName, listener, priority);
|
|
64
|
+
}
|
|
65
|
+
else if (metakey === exports.ACTION) {
|
|
66
|
+
action.add(eventName, listener);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.HooksReflect = HooksReflect;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type * as types from "../../types";
|
|
2
|
+
import { Action } from "./action";
|
|
3
|
+
import { Filter } from "./filter";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a collection of hooks for filtering and actions.
|
|
6
|
+
*
|
|
7
|
+
* TFilters - The type of filters.
|
|
8
|
+
* TActions - The type of actions.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Hooks<TFilters = types.hooks.Filters, TActions = types.hooks.Actions> {
|
|
11
|
+
#private;
|
|
12
|
+
hooks: Map<string, types.Constructor>;
|
|
13
|
+
/**
|
|
14
|
+
* The map of hooks for each environment.
|
|
15
|
+
*
|
|
16
|
+
* @remarks The structure of the map is as follows:
|
|
17
|
+
* - The key is the environment.
|
|
18
|
+
* - The value is a map of hooks.
|
|
19
|
+
* - The key is the name of the hook which should be unique across all hooks.
|
|
20
|
+
* - The value is the hook class where its methods are decorated with `@filter` or `@action`.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* @hook("example")
|
|
24
|
+
* class ExampleHook {
|
|
25
|
+
* @filter("example_filter")
|
|
26
|
+
* async exampleFilter(n: number) {
|
|
27
|
+
* return n + 10;
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
static hooksEnvMap: Map<string, Map<string, types.Constructor>>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the hook map for the specified environment.
|
|
35
|
+
*
|
|
36
|
+
* @param env - The environment for which to retrieve the hook map.
|
|
37
|
+
* @returns The hook map for the specified environment.
|
|
38
|
+
*/
|
|
39
|
+
static get(env: string): Map<string, types.Constructor<any>>;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the hook map for the specified environment.
|
|
42
|
+
*
|
|
43
|
+
* @param env - The environment for which to set the hook map.
|
|
44
|
+
* @param hookMap - The hook map to set.
|
|
45
|
+
*/
|
|
46
|
+
static set(env: string, hookMap: Map<string, types.Constructor>): void;
|
|
47
|
+
action: Action<TActions>;
|
|
48
|
+
filter: Filter<TFilters>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an instance of Hooks.
|
|
51
|
+
*
|
|
52
|
+
* @param hooks - The map of hooks.
|
|
53
|
+
*/
|
|
54
|
+
constructor(hooks: Map<string, types.Constructor>);
|
|
55
|
+
/**
|
|
56
|
+
* Initializes the hooks.
|
|
57
|
+
* If the hooks have already been initialized, this method does nothing.
|
|
58
|
+
*/
|
|
59
|
+
init(): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC;;;;;GAKG;AACH,qBAAa,KAAK,CAChB,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAC9B,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO;;IAsDX,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC;IApDxD;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAa;IAE5E;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM;IAMtB;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC;IAK/D,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEzB;;;;OAIG;gBACgB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC;IAKxD;;;OAGG;IACH,IAAI;CAWL"}
|