@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
package/crud/crud.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
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 __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Crud = void 0;
|
|
37
|
+
const config_1 = require("../config");
|
|
38
|
+
const current_1 = require("../core/current");
|
|
39
|
+
const blog_util_1 = require("../core/utils/blog.util");
|
|
40
|
+
const post_util_1 = require("../core/utils/post.util");
|
|
41
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
42
|
+
const roles_util_1 = require("../core/utils/roles.util");
|
|
43
|
+
const val = __importStar(require("../validators"));
|
|
44
|
+
const error_1 = require("./error");
|
|
45
|
+
class Crud {
|
|
46
|
+
components;
|
|
47
|
+
constructor(components) {
|
|
48
|
+
this.components = components;
|
|
49
|
+
}
|
|
50
|
+
async getUser() {
|
|
51
|
+
const current = this.components.get(current_1.Current);
|
|
52
|
+
const user = current.user;
|
|
53
|
+
const role = await user?.role();
|
|
54
|
+
if (!user || (!user?.props?.ID && !role?.is("anonymous"))) {
|
|
55
|
+
throw new Error("User not found");
|
|
56
|
+
}
|
|
57
|
+
return { user, userId: user.props?.ID, userProps: user.props };
|
|
58
|
+
}
|
|
59
|
+
async checkPostsPermission(action, postType, defaultUser) {
|
|
60
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
61
|
+
const postTypeObject = postUtil.getTypeObject(postType);
|
|
62
|
+
const { user: currentUser } = await this.getUser();
|
|
63
|
+
const user = defaultUser ?? currentUser;
|
|
64
|
+
return postTypeObject?.capabilities &&
|
|
65
|
+
postTypeObject.capabilities[action] &&
|
|
66
|
+
(await user.can(postTypeObject.capabilities[action]))
|
|
67
|
+
? true
|
|
68
|
+
: false;
|
|
69
|
+
}
|
|
70
|
+
originalBlogId = 0;
|
|
71
|
+
originalSiteId = 0;
|
|
72
|
+
async switchBlog(args) {
|
|
73
|
+
const config = this.components.get(config_1.Config);
|
|
74
|
+
if (!config.isMultiSite()) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let { siteId = undefined } = args;
|
|
78
|
+
const { blogId = undefined } = args;
|
|
79
|
+
if (!siteId && !blogId) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const current = this.components.get(current_1.Current);
|
|
83
|
+
const { user: currentUser } = await this.getUser();
|
|
84
|
+
if (blogId) {
|
|
85
|
+
const blogUtil = this.components.get(blog_util_1.BlogUtil);
|
|
86
|
+
const blog = await blogUtil.get(blogId);
|
|
87
|
+
if (!blog?.props || (siteId && siteId !== blog?.props.site_id)) {
|
|
88
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid Blog");
|
|
89
|
+
}
|
|
90
|
+
if (!siteId) {
|
|
91
|
+
siteId = blog.props.site_id;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (siteId) {
|
|
95
|
+
if (!currentUser.props?.user_login) {
|
|
96
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
97
|
+
}
|
|
98
|
+
const userLogin = currentUser.props?.user_login;
|
|
99
|
+
const rolesUtil = this.components.get(roles_util_1.RolesUtil);
|
|
100
|
+
const superAdmins = await rolesUtil.getSuperAdmins({ siteId });
|
|
101
|
+
if (!superAdmins.includes(userLogin)) {
|
|
102
|
+
// Only superadmin has access to all users in site (network)
|
|
103
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!siteId) {
|
|
107
|
+
throw new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid site");
|
|
108
|
+
}
|
|
109
|
+
this.originalBlogId = current.blogId;
|
|
110
|
+
this.originalSiteId = current.siteId;
|
|
111
|
+
await current.switchSite(siteId, blogId);
|
|
112
|
+
await current.assumeUser(currentUser.props?.ID);
|
|
113
|
+
}
|
|
114
|
+
async restoreBlog() {
|
|
115
|
+
const config = this.components.get(config_1.Config);
|
|
116
|
+
if (0 >= this.originalSiteId ||
|
|
117
|
+
0 >= this.originalBlogId ||
|
|
118
|
+
!config.isMultiSite()) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const { user: currentUser } = await this.getUser();
|
|
122
|
+
const current = this.components.get(current_1.Current);
|
|
123
|
+
await current.switchSite(this.originalSiteId, this.originalBlogId);
|
|
124
|
+
await current.assumeUser(currentUser.props?.ID);
|
|
125
|
+
}
|
|
126
|
+
async getAvailableBlogs(args) {
|
|
127
|
+
const { siteIds, canArgs } = args;
|
|
128
|
+
let { blogIds = [] } = args;
|
|
129
|
+
const errors = [];
|
|
130
|
+
const current = this.components.get(current_1.Current);
|
|
131
|
+
const originalBlogId = current.blogId;
|
|
132
|
+
const originalSiteId = current.siteId;
|
|
133
|
+
const originalUserId = current.user?.props?.ID;
|
|
134
|
+
try {
|
|
135
|
+
const { user: currentUser } = await this.getUser();
|
|
136
|
+
if (!currentUser.props?.ID) {
|
|
137
|
+
errors.push(new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "User not found"));
|
|
138
|
+
return [[], errors];
|
|
139
|
+
}
|
|
140
|
+
const config = this.components.get(config_1.Config);
|
|
141
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
142
|
+
const userId = currentUser.props?.ID;
|
|
143
|
+
if (!config.isMultiSite()) {
|
|
144
|
+
blogIds = [1];
|
|
145
|
+
}
|
|
146
|
+
else if (siteIds) {
|
|
147
|
+
const blogs = (await queryUtil.blogs((query) => {
|
|
148
|
+
query.whereIn("site_id", siteIds);
|
|
149
|
+
})) ?? [];
|
|
150
|
+
blogs.map((blog) => blogIds.push(blog.blog_id));
|
|
151
|
+
}
|
|
152
|
+
const blogs = [];
|
|
153
|
+
for (const blogId of blogIds) {
|
|
154
|
+
let blog;
|
|
155
|
+
if (!config.isMultiSite()) {
|
|
156
|
+
blog = { blog_id: blogId, site_id: 0 };
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const result = await queryUtil.blogs((query) => {
|
|
160
|
+
query.where("blog_id", blogId).builder.first();
|
|
161
|
+
}, val.database.wpBlogs);
|
|
162
|
+
if (!result) {
|
|
163
|
+
errors.push(new error_1.CrudError(error_1.StatusMessage.BAD_REQUEST, "Invalid input"));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
blog = {
|
|
167
|
+
blog_id: result.blog_id,
|
|
168
|
+
site_id: result.site_id,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const siteId = blog.site_id;
|
|
172
|
+
await current.switchSite(siteId, blogId);
|
|
173
|
+
await current.assumeUser(userId);
|
|
174
|
+
if (!current?.user) {
|
|
175
|
+
errors.push(new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "User not found"));
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
for (const canArg of canArgs) {
|
|
179
|
+
if (!(await current.user.can(...canArg))) {
|
|
180
|
+
errors.push(new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "User not found"));
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
blogs.push(blog);
|
|
185
|
+
}
|
|
186
|
+
return [blogs, errors];
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
await current.switchSite(originalSiteId, originalBlogId);
|
|
190
|
+
await current.assumeUser(originalUserId);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async checkBlogsPermission(args) {
|
|
194
|
+
const result = await this.getAvailableBlogs(args);
|
|
195
|
+
if (result[1].length > 0) {
|
|
196
|
+
throw result[1][0];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async canEditPosts(postType, defaultUser) {
|
|
200
|
+
return await this.checkPostsPermission("edit_posts", postType, defaultUser);
|
|
201
|
+
}
|
|
202
|
+
async canDeletePosts(postType, defaultUser) {
|
|
203
|
+
return await this.checkPostsPermission("delete_posts", postType, defaultUser);
|
|
204
|
+
}
|
|
205
|
+
async canReadPrivatePosts(postType, defaultUser) {
|
|
206
|
+
return await this.checkPostsPermission("read_private_posts", postType, defaultUser);
|
|
207
|
+
}
|
|
208
|
+
// check_read_permission
|
|
209
|
+
async canReadPost(post) {
|
|
210
|
+
const postUtil = this.components.get(post_util_1.PostUtil);
|
|
211
|
+
const postTypeObject = postUtil.getTypeObject(post.post_type);
|
|
212
|
+
if (!postTypeObject) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
const { user: currentUser } = await this.getUser();
|
|
216
|
+
if ("publish" == post.post_status ||
|
|
217
|
+
(await currentUser.can("read_post", post.ID))) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
const postStatusObject = postUtil.getStatusObject(post.post_status);
|
|
221
|
+
if (postStatusObject && postStatusObject.public) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
// Can we read the parent if we're inheriting?
|
|
225
|
+
if ("inherit" === post.post_status && post.post_parent > 0) {
|
|
226
|
+
const parentPost = await postUtil.get(post.post_parent);
|
|
227
|
+
if (parentPost.props) {
|
|
228
|
+
return await this.canReadPost(parentPost.props);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/*
|
|
232
|
+
* If there isn't a parent, but the status is set to inherit, assume
|
|
233
|
+
* it's published (as per get_post_status()).
|
|
234
|
+
*/
|
|
235
|
+
if ("inherit" === post.post_status) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
checkPasswordProtectedPost(post, password) {
|
|
241
|
+
return post.post_password == "" || post.post_password == password;
|
|
242
|
+
}
|
|
243
|
+
pagination(params) {
|
|
244
|
+
return {
|
|
245
|
+
page: params.page,
|
|
246
|
+
limit: params.limit,
|
|
247
|
+
totalPage: Math.ceil(params.count / params.limit),
|
|
248
|
+
count: params.count,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
returnValue(data, info = undefined) {
|
|
252
|
+
return {
|
|
253
|
+
data,
|
|
254
|
+
info,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
258
|
+
async get(...arg2) {
|
|
259
|
+
throw new Error("Get method not defined");
|
|
260
|
+
}
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
262
|
+
async create(...arg2) {
|
|
263
|
+
throw new Error("Create method not defined");
|
|
264
|
+
}
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
266
|
+
async update(...arg2) {
|
|
267
|
+
throw new Error("Update method not defined");
|
|
268
|
+
}
|
|
269
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
270
|
+
async delete(...arg2) {
|
|
271
|
+
throw new Error("Delete method not defined");
|
|
272
|
+
}
|
|
273
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
274
|
+
async list(...arg2) {
|
|
275
|
+
throw new Error("List method not defined");
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.Crud = Crud;
|
package/crud/error.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type StatusCode = 400 | 401 | 404 | 500;
|
|
2
|
+
export declare enum StatusMessage {
|
|
3
|
+
BAD_REQUEST = "BAD_REQUEST",
|
|
4
|
+
UNAUTHORIZED = "UNAUTHORIZED",
|
|
5
|
+
NOT_FOUND = "NOT_FOUND",
|
|
6
|
+
INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
|
|
7
|
+
}
|
|
8
|
+
export declare class StatusCodeMapper {
|
|
9
|
+
private static statusMap;
|
|
10
|
+
private static reverseStatusMap;
|
|
11
|
+
static getCode(message: StatusMessage): StatusCode;
|
|
12
|
+
static getMessage(statusCode: StatusCode): StatusMessage;
|
|
13
|
+
}
|
|
14
|
+
declare class CustomError extends Error {
|
|
15
|
+
statusCode: StatusCode;
|
|
16
|
+
isOperational: boolean;
|
|
17
|
+
constructor(message: string, statusMessage: StatusMessage, isOperational?: boolean, stack?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class CrudError extends CustomError {
|
|
20
|
+
constructor(statusMessage: StatusMessage | undefined, detail: string);
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/crud/error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE/C,oBAAY,aAAa;IACvB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,qBAAqB,0BAA0B;CAChD;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,SAAS,CAKb;IAEX,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAMU;WAE3B,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,UAAU;WAI3C,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;CAKhE;AAED,cAAM,WAAY,SAAQ,KAAK;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;gBAG5B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,aAAa,EAC5B,aAAa,GAAE,OAAc,EAC7B,KAAK,SAAK;CAWb;AAED,qBAAa,SAAU,SAAQ,WAAW;gBAEtC,aAAa,EAAE,aAAa,YAAsC,EAClE,MAAM,EAAE,MAAM;CAKjB"}
|
package/crud/error.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudError = exports.StatusCodeMapper = exports.StatusMessage = void 0;
|
|
4
|
+
var StatusMessage;
|
|
5
|
+
(function (StatusMessage) {
|
|
6
|
+
StatusMessage["BAD_REQUEST"] = "BAD_REQUEST";
|
|
7
|
+
StatusMessage["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
8
|
+
StatusMessage["NOT_FOUND"] = "NOT_FOUND";
|
|
9
|
+
StatusMessage["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
10
|
+
})(StatusMessage || (exports.StatusMessage = StatusMessage = {}));
|
|
11
|
+
class StatusCodeMapper {
|
|
12
|
+
static statusMap = {
|
|
13
|
+
[StatusMessage.BAD_REQUEST]: 400,
|
|
14
|
+
[StatusMessage.UNAUTHORIZED]: 401,
|
|
15
|
+
[StatusMessage.NOT_FOUND]: 404,
|
|
16
|
+
[StatusMessage.INTERNAL_SERVER_ERROR]: 500,
|
|
17
|
+
};
|
|
18
|
+
static reverseStatusMap = Object.fromEntries(Object.entries(StatusCodeMapper.statusMap).map(([key, value]) => [
|
|
19
|
+
value,
|
|
20
|
+
key,
|
|
21
|
+
]));
|
|
22
|
+
static getCode(message) {
|
|
23
|
+
return this.statusMap[message] || 500; // Default to 500 if not found
|
|
24
|
+
}
|
|
25
|
+
static getMessage(statusCode) {
|
|
26
|
+
return (this.reverseStatusMap[statusCode] ?? StatusMessage.INTERNAL_SERVER_ERROR);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.StatusCodeMapper = StatusCodeMapper;
|
|
30
|
+
class CustomError extends Error {
|
|
31
|
+
statusCode;
|
|
32
|
+
isOperational;
|
|
33
|
+
constructor(message, statusMessage, isOperational = true, stack = "") {
|
|
34
|
+
super(message);
|
|
35
|
+
this.statusCode = StatusCodeMapper.getCode(statusMessage);
|
|
36
|
+
this.isOperational = isOperational;
|
|
37
|
+
if (stack) {
|
|
38
|
+
this.stack = stack;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
Error.captureStackTrace(this, this.constructor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class CrudError extends CustomError {
|
|
46
|
+
constructor(statusMessage = StatusMessage.INTERNAL_SERVER_ERROR, detail) {
|
|
47
|
+
super(`Error: ${detail}`, statusMessage, true);
|
|
48
|
+
Object.setPrototypeOf(this, CrudError.prototype);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.CrudError = CrudError;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Config } from "../config";
|
|
3
|
+
import { Components } from "../core/components";
|
|
4
|
+
import { Logger } from "../core/logger";
|
|
5
|
+
import * as val from "../validators";
|
|
6
|
+
import { Crud } from "./crud";
|
|
7
|
+
import type * as types from "../types";
|
|
8
|
+
type Data = Exclude<z.infer<typeof val.trx.postUpsert.shape.meta_input>, undefined>;
|
|
9
|
+
export declare class MetaCrud extends Crud {
|
|
10
|
+
private config;
|
|
11
|
+
private logger;
|
|
12
|
+
constructor(components: Components, config: Config, logger: Logger);
|
|
13
|
+
private hasObject;
|
|
14
|
+
private sync;
|
|
15
|
+
get(table: types.MetaTable, objectId: number, keys?: string[]): Promise<{
|
|
16
|
+
data: Record<string, any>;
|
|
17
|
+
info: undefined;
|
|
18
|
+
}>;
|
|
19
|
+
create(table: types.MetaTable, objectId: number, data: Data): Promise<{
|
|
20
|
+
data: number;
|
|
21
|
+
info: undefined;
|
|
22
|
+
}>;
|
|
23
|
+
update(table: types.MetaTable, objectId: number, data: Data, mode?: "update" | "sync"): Promise<{
|
|
24
|
+
data: boolean;
|
|
25
|
+
info: number;
|
|
26
|
+
}>;
|
|
27
|
+
delete(table: types.MetaTable, objectId: number, metaKeys: string[]): Promise<{
|
|
28
|
+
data: number;
|
|
29
|
+
info: undefined;
|
|
30
|
+
}>;
|
|
31
|
+
list(table: types.MetaTable, args?: Partial<z.infer<typeof val.crud.termListParams>>, options?: {
|
|
32
|
+
unserialize?: boolean;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
data: ({
|
|
35
|
+
meta_value: string | number | bigint | boolean | symbol | object | Function | null | undefined;
|
|
36
|
+
meta_id: number;
|
|
37
|
+
blog_id: number;
|
|
38
|
+
meta_key: string | null;
|
|
39
|
+
} | {
|
|
40
|
+
meta_value: string | number | bigint | boolean | symbol | object | Function | null | undefined;
|
|
41
|
+
meta_id: number;
|
|
42
|
+
meta_key: string | null;
|
|
43
|
+
comment_id: number;
|
|
44
|
+
} | {
|
|
45
|
+
meta_value: string | number | bigint | boolean | symbol | object | Function | null | undefined;
|
|
46
|
+
meta_id: number;
|
|
47
|
+
meta_key: string | null;
|
|
48
|
+
post_id: number;
|
|
49
|
+
} | {
|
|
50
|
+
meta_value: string | number | bigint | boolean | symbol | object | Function | null | undefined;
|
|
51
|
+
meta_id: number;
|
|
52
|
+
meta_key: string | null;
|
|
53
|
+
site_id: number;
|
|
54
|
+
} | {
|
|
55
|
+
meta_value: string | number | bigint | boolean | symbol | object | Function | null | undefined;
|
|
56
|
+
meta_id: number;
|
|
57
|
+
meta_key: string | null;
|
|
58
|
+
term_id: number;
|
|
59
|
+
} | {
|
|
60
|
+
meta_value: string | number | bigint | boolean | symbol | object | Function | null | undefined;
|
|
61
|
+
meta_key: string | null;
|
|
62
|
+
user_id: number;
|
|
63
|
+
umeta_id: number;
|
|
64
|
+
})[];
|
|
65
|
+
info: undefined;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=meta.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.crud.d.ts","sourceRoot":"","sources":["../../src/crud/meta.crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAKxC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AAEvC,KAAK,IAAI,GAAG,OAAO,CACjB,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,EACnD,SAAS,CACV,CAAC;AAEF,qBACa,QAAS,SAAQ,IAAI;IAG9B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;gBAFd,UAAU,EAAE,UAAU,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;YAKV,SAAS;YA4CT,IAAI;IAmFZ,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE;;;;IAyB7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;;;;IAK3D,MAAM,CACV,KAAK,EAAE,KAAK,CAAC,SAAS,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,IAAI,GAAE,QAAQ,GAAG,MAAiB;;;;IAM9B,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;;;;IA4BnE,IAAI,CACR,KAAK,EAAE,KAAK,CAAC,SAAS,EACtB,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EACvD,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEJ"}
|
|
@@ -0,0 +1,244 @@
|
|
|
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.MetaCrud = void 0;
|
|
46
|
+
const common_1 = require("../common");
|
|
47
|
+
const diff_1 = require("../common/diff");
|
|
48
|
+
const config_1 = require("../config");
|
|
49
|
+
const components_1 = require("../core/components");
|
|
50
|
+
const logger_1 = require("../core/logger");
|
|
51
|
+
const meta_util_1 = require("../core/utils/meta.util");
|
|
52
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
53
|
+
const component_1 = require("../decorators/component");
|
|
54
|
+
const transactions_1 = require("../transactions");
|
|
55
|
+
const val = __importStar(require("../validators"));
|
|
56
|
+
const crud_1 = require("./crud");
|
|
57
|
+
const error_1 = require("./error");
|
|
58
|
+
let MetaCrud = class MetaCrud extends crud_1.Crud {
|
|
59
|
+
config;
|
|
60
|
+
logger;
|
|
61
|
+
constructor(components, config, logger) {
|
|
62
|
+
super(components);
|
|
63
|
+
this.config = config;
|
|
64
|
+
this.logger = logger;
|
|
65
|
+
}
|
|
66
|
+
async hasObject(table, objectId) {
|
|
67
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
68
|
+
switch (table) {
|
|
69
|
+
case "blog":
|
|
70
|
+
return (typeof (await queryUtil.blogs((query) => {
|
|
71
|
+
query.where("blog_id", objectId);
|
|
72
|
+
})) !== "undefined");
|
|
73
|
+
case "comment":
|
|
74
|
+
return (typeof (await queryUtil.comments((query) => {
|
|
75
|
+
query.where("ID", objectId);
|
|
76
|
+
})) !== "undefined");
|
|
77
|
+
case "post":
|
|
78
|
+
return (typeof (await queryUtil.posts((query) => {
|
|
79
|
+
query.where("ID", objectId);
|
|
80
|
+
})) !== "undefined");
|
|
81
|
+
case "site":
|
|
82
|
+
return (typeof (await queryUtil.sites((query) => {
|
|
83
|
+
query.where("id", objectId);
|
|
84
|
+
})) !== "undefined");
|
|
85
|
+
case "term":
|
|
86
|
+
return (typeof (await queryUtil.terms((query) => {
|
|
87
|
+
query.where("term_id", objectId);
|
|
88
|
+
})) !== "undefined");
|
|
89
|
+
case "user":
|
|
90
|
+
return (typeof (await queryUtil.users((query) => {
|
|
91
|
+
query.where("ID", objectId);
|
|
92
|
+
})) !== "undefined");
|
|
93
|
+
default:
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async sync(table, objectId, data, mode) {
|
|
98
|
+
if (!(await this.hasObject(table, objectId))) {
|
|
99
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `object not found - ${objectId}`);
|
|
100
|
+
}
|
|
101
|
+
if (typeof data === "undefined") {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const { user } = await this.getUser();
|
|
105
|
+
const currentMetas = (await this.get(table, objectId)).data ?? {};
|
|
106
|
+
const diffFormData = (0, diff_1.diffObject)(data, currentMetas);
|
|
107
|
+
if (!diffFormData) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const metaTrx = this.components.get(transactions_1.MetaTrx);
|
|
111
|
+
const metaUtil = this.components.get(meta_util_1.MetaUtil);
|
|
112
|
+
const metaKeys = Object.keys(common_1.formatting.primitive(diffFormData));
|
|
113
|
+
for (const metaKey of metaKeys) {
|
|
114
|
+
if (metaUtil.isProtected(metaKey, table)) {
|
|
115
|
+
this.logger.info(`Protected meta key ${metaKey}`, { metaKey });
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
// Update
|
|
119
|
+
if ((mode == "sync" && data[metaKey]) ||
|
|
120
|
+
(mode == "update" &&
|
|
121
|
+
currentMetas &&
|
|
122
|
+
currentMetas[metaKey] &&
|
|
123
|
+
data[metaKey] &&
|
|
124
|
+
currentMetas[metaKey] !== data[metaKey])) {
|
|
125
|
+
if (!(await user.can(`edit_${table}_meta`, objectId, metaKey))) {
|
|
126
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, `Sorry, you are not allowed to edit the ${table} custom field - ${metaKey}`);
|
|
127
|
+
}
|
|
128
|
+
await metaTrx.upsert(table, objectId, metaKey, data[metaKey]);
|
|
129
|
+
// Create
|
|
130
|
+
}
|
|
131
|
+
else if (mode == "create" &&
|
|
132
|
+
(!currentMetas || !currentMetas[metaKey])) {
|
|
133
|
+
if (!(await user.can(`add_${table}_meta`, objectId, metaKey))) {
|
|
134
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, `Sorry, you are not allowed to create the ${table} custom field`);
|
|
135
|
+
}
|
|
136
|
+
await metaTrx.upsert(table, objectId, metaKey, data[metaKey]);
|
|
137
|
+
// Delete
|
|
138
|
+
}
|
|
139
|
+
else if (mode == "sync" && !data[metaKey]) {
|
|
140
|
+
if (!(await user.can(`delete_${table}_meta`, objectId, metaKey))) {
|
|
141
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, `Sorry, you are not allowed to delete the ${table} custom field`);
|
|
142
|
+
}
|
|
143
|
+
await metaTrx.remove(table, {
|
|
144
|
+
key: metaKey,
|
|
145
|
+
objectId,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async get(table, objectId, keys) {
|
|
151
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
152
|
+
const metas = await queryUtil.meta(table, (query) => {
|
|
153
|
+
query.withIds([objectId]);
|
|
154
|
+
if (keys) {
|
|
155
|
+
query.withKeys(keys);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
if (!metas) {
|
|
159
|
+
return this.returnValue({});
|
|
160
|
+
}
|
|
161
|
+
return this.returnValue(metas.reduce((a, v) => ({
|
|
162
|
+
...a,
|
|
163
|
+
[`${v.meta_key}`]: common_1.formatting.primitive(v.meta_value),
|
|
164
|
+
}), {}));
|
|
165
|
+
}
|
|
166
|
+
async create(table, objectId, data) {
|
|
167
|
+
await this.sync(table, objectId, data, "create");
|
|
168
|
+
return this.returnValue(objectId);
|
|
169
|
+
}
|
|
170
|
+
async update(table, objectId, data, mode = "update") {
|
|
171
|
+
await this.sync(table, objectId, data, mode);
|
|
172
|
+
return this.returnValue(true, objectId);
|
|
173
|
+
}
|
|
174
|
+
async delete(table, objectId, metaKeys) {
|
|
175
|
+
if (!(await this.hasObject(table, objectId))) {
|
|
176
|
+
throw new error_1.CrudError(error_1.StatusMessage.NOT_FOUND, `object not found - ${objectId}`);
|
|
177
|
+
}
|
|
178
|
+
const { user } = await this.getUser();
|
|
179
|
+
const metaTrx = this.components.get(transactions_1.MetaTrx);
|
|
180
|
+
for (const metaKey of metaKeys) {
|
|
181
|
+
if (!(await user.can(`delete_${table}_meta`, objectId, metaKey))) {
|
|
182
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, `Sorry, you are not allowed to delete the ${table} custom field`);
|
|
183
|
+
}
|
|
184
|
+
await metaTrx.remove(table, {
|
|
185
|
+
key: metaKey,
|
|
186
|
+
objectId,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return this.returnValue(objectId);
|
|
190
|
+
}
|
|
191
|
+
async list(table, args, options) {
|
|
192
|
+
const { user } = await this.getUser();
|
|
193
|
+
const role = await user.role();
|
|
194
|
+
// Only admin or superadmin is permitted to list all metas
|
|
195
|
+
if ((this.config.isMultiSite() && !role.isSuperAdmin()) ||
|
|
196
|
+
!role.isAdmin()) {
|
|
197
|
+
throw new error_1.CrudError(error_1.StatusMessage.UNAUTHORIZED, "Not permitted");
|
|
198
|
+
}
|
|
199
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
200
|
+
const parsedArgs = val.crud.metaListParams.parse(args ?? {});
|
|
201
|
+
const buildQuery = (table, query) => {
|
|
202
|
+
const { column } = query.alias;
|
|
203
|
+
const offset = (parsedArgs.page - 1) * parsedArgs.per_page;
|
|
204
|
+
const limit = parsedArgs.per_page;
|
|
205
|
+
query.builder.offset(offset).limit(limit);
|
|
206
|
+
if (parsedArgs.orderby) {
|
|
207
|
+
query.builder.orderBy(column(`${table}meta`, parsedArgs.orderby), parsedArgs.order);
|
|
208
|
+
}
|
|
209
|
+
if (Array.isArray(parsedArgs.include)) {
|
|
210
|
+
query.withIds(parsedArgs.include);
|
|
211
|
+
}
|
|
212
|
+
if (Array.isArray(parsedArgs.exclude)) {
|
|
213
|
+
query.withIds(parsedArgs.exclude, {
|
|
214
|
+
not: true,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (parsedArgs.search) {
|
|
218
|
+
query.whereKeyLike(parsedArgs.search);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const metas = await queryUtil.meta(table, (query) => {
|
|
222
|
+
query.setPrimaryTable(table).joinPrimary();
|
|
223
|
+
buildQuery(table, query);
|
|
224
|
+
});
|
|
225
|
+
if (!metas) {
|
|
226
|
+
return this.returnValue([]);
|
|
227
|
+
}
|
|
228
|
+
return this.returnValue(!options?.unserialize
|
|
229
|
+
? metas
|
|
230
|
+
: metas.map((meta) => {
|
|
231
|
+
return {
|
|
232
|
+
...meta,
|
|
233
|
+
meta_value: common_1.formatting.primitive(meta.meta_value),
|
|
234
|
+
};
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.MetaCrud = MetaCrud;
|
|
239
|
+
exports.MetaCrud = MetaCrud = __decorate([
|
|
240
|
+
(0, component_1.component)(),
|
|
241
|
+
__metadata("design:paramtypes", [components_1.Components,
|
|
242
|
+
config_1.Config,
|
|
243
|
+
logger_1.Logger])
|
|
244
|
+
], MetaCrud);
|