@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,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Components } from "../core/components";
|
|
3
|
+
import { Logger } from "../core/logger";
|
|
4
|
+
import { Validator } from "../core/validator";
|
|
5
|
+
import Database from "../database";
|
|
6
|
+
import * as val from "../validators";
|
|
7
|
+
import { Trx } from "./trx";
|
|
8
|
+
type DataUpsert = z.infer<typeof val.trx.linkUpsert>;
|
|
9
|
+
export declare class LinkTrx extends Trx {
|
|
10
|
+
private database;
|
|
11
|
+
private logger;
|
|
12
|
+
private components;
|
|
13
|
+
private validator;
|
|
14
|
+
constructor(database: Database, logger: Logger, components: Components, validator: Validator);
|
|
15
|
+
private defaultCategory;
|
|
16
|
+
changeUser(fromUserId: number, toUserId: number): Promise<boolean>;
|
|
17
|
+
remove(linkId: number): Promise<void>;
|
|
18
|
+
upsert(input: Partial<DataUpsert>): Promise<number>;
|
|
19
|
+
updateCategory(linkId?: number, linkCategory?: number[]): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=link.trx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.trx.d.ts","sourceRoot":"","sources":["../../src/transactions/link.trx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAErD,qBACa,OAAQ,SAAQ,GAAG;IAE5B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;gBAHT,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS;YAKhB,eAAe;IASvB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAoB/C,MAAM,CAAC,MAAM,EAAE,MAAM;IAqBrB,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;IA4FjC,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,YAAY,GAAE,MAAM,EAAO;CAYrE"}
|
|
@@ -0,0 +1,208 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.LinkTrx = void 0;
|
|
49
|
+
const common_1 = require("../common");
|
|
50
|
+
const components_1 = require("../core/components");
|
|
51
|
+
const current_1 = require("../core/current");
|
|
52
|
+
const logger_1 = require("../core/logger");
|
|
53
|
+
const options_1 = require("../core/options");
|
|
54
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
55
|
+
const validator_1 = require("../core/validator");
|
|
56
|
+
const database_1 = __importDefault(require("../database"));
|
|
57
|
+
const component_1 = require("../decorators/component");
|
|
58
|
+
const val = __importStar(require("../validators"));
|
|
59
|
+
const term_trx_1 = require("./term.trx");
|
|
60
|
+
const trx_1 = require("./trx");
|
|
61
|
+
let LinkTrx = class LinkTrx extends trx_1.Trx {
|
|
62
|
+
database;
|
|
63
|
+
logger;
|
|
64
|
+
components;
|
|
65
|
+
validator;
|
|
66
|
+
constructor(database, logger, components, validator) {
|
|
67
|
+
super(components);
|
|
68
|
+
this.database = database;
|
|
69
|
+
this.logger = logger;
|
|
70
|
+
this.components = components;
|
|
71
|
+
this.validator = validator;
|
|
72
|
+
}
|
|
73
|
+
async defaultCategory() {
|
|
74
|
+
const options = this.components.get(options_1.Options);
|
|
75
|
+
const defaultLinkCategory = await options.get("default_link_category");
|
|
76
|
+
return defaultLinkCategory ? [defaultLinkCategory] : [];
|
|
77
|
+
}
|
|
78
|
+
// part of remove_user_from_blog
|
|
79
|
+
async changeUser(fromUserId, toUserId) {
|
|
80
|
+
const trx = await this.database.transaction;
|
|
81
|
+
try {
|
|
82
|
+
await trx
|
|
83
|
+
.table(this.tables.get("links"))
|
|
84
|
+
.where("link_owner", fromUserId)
|
|
85
|
+
.update({
|
|
86
|
+
link_owner: toUserId,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
await trx.rollback();
|
|
91
|
+
throw new Error(`Failed to change user from: ${fromUserId} to: ${toUserId}`);
|
|
92
|
+
}
|
|
93
|
+
await trx.commit();
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
// wp_delete_link
|
|
97
|
+
async remove(linkId) {
|
|
98
|
+
const termTrx = this.components.get(term_trx_1.TermTrx);
|
|
99
|
+
const current = this.components.get(current_1.Current);
|
|
100
|
+
const trx = await this.database.transaction;
|
|
101
|
+
try {
|
|
102
|
+
await trx
|
|
103
|
+
.table(current.tables.get("links"))
|
|
104
|
+
.where("link_id", linkId)
|
|
105
|
+
.del();
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
trx.rollback();
|
|
109
|
+
throw new Error(`Failed to remove link - ${e}`);
|
|
110
|
+
}
|
|
111
|
+
await trx.commit();
|
|
112
|
+
// Remove terms
|
|
113
|
+
await termTrx.removeObjectTermRelationships(linkId, ["link_category"]);
|
|
114
|
+
}
|
|
115
|
+
// wp_insert_link
|
|
116
|
+
// wp_update_link
|
|
117
|
+
async upsert(input) {
|
|
118
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
119
|
+
let update = false;
|
|
120
|
+
let linkBefore = undefined;
|
|
121
|
+
let linkId = 0;
|
|
122
|
+
if (input.link_id && 0 < input.link_id) {
|
|
123
|
+
linkId = input.link_id;
|
|
124
|
+
update = true;
|
|
125
|
+
linkBefore = await queryUtil.common("links", (query) => {
|
|
126
|
+
query.where("link_id", linkId).builder.first();
|
|
127
|
+
}, val.database.wpLinks);
|
|
128
|
+
if (!linkBefore) {
|
|
129
|
+
throw new Error(`Link not found - ${input.link_id}`);
|
|
130
|
+
}
|
|
131
|
+
input = {
|
|
132
|
+
...linkBefore,
|
|
133
|
+
...input,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const parsedInput = val.trx.linkUpsert.parse(input);
|
|
137
|
+
if (0 >= parsedInput.link_url.length) {
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
if (0 >= parsedInput.link_name.length) {
|
|
141
|
+
parsedInput.link_name = parsedInput.link_url;
|
|
142
|
+
}
|
|
143
|
+
// Make sure we set a valid category.
|
|
144
|
+
if (!parsedInput.link_category) {
|
|
145
|
+
parsedInput.link_category = await this.defaultCategory();
|
|
146
|
+
}
|
|
147
|
+
let dataUpsert = {};
|
|
148
|
+
try {
|
|
149
|
+
dataUpsert = this.validator.execAny(update ? val.trx.linkUpdate : val.trx.linkInsert, Object.entries(parsedInput)
|
|
150
|
+
.map(([key, value]) => ({
|
|
151
|
+
[key]: common_1.formatting.unslash(value),
|
|
152
|
+
}))
|
|
153
|
+
.reduce((obj, item) => ({ ...obj, ...item }), {}));
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
this.logger.info(`parse error: ${e}`, { parsedInput });
|
|
157
|
+
throw e;
|
|
158
|
+
}
|
|
159
|
+
if (!dataUpsert) {
|
|
160
|
+
throw new Error(`Invalid post data - ${JSON.stringify(parsedInput)}`);
|
|
161
|
+
}
|
|
162
|
+
if (!linkId)
|
|
163
|
+
linkId = parsedInput.link_id ?? 0;
|
|
164
|
+
const trx = await this.database.transaction;
|
|
165
|
+
try {
|
|
166
|
+
if (update) {
|
|
167
|
+
await trx
|
|
168
|
+
.table(this.tables.get("links"))
|
|
169
|
+
.where("link_id", parsedInput.link_id)
|
|
170
|
+
.update(dataUpsert);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
await trx
|
|
174
|
+
.insert(dataUpsert)
|
|
175
|
+
.into(this.tables.get("links"))
|
|
176
|
+
.then((v) => {
|
|
177
|
+
linkId = v[0];
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
await trx.rollback();
|
|
183
|
+
throw new Error(`Failed to insert link - ${e}`);
|
|
184
|
+
}
|
|
185
|
+
await trx.commit();
|
|
186
|
+
await this.updateCategory(linkId, parsedInput.link_category);
|
|
187
|
+
return linkId;
|
|
188
|
+
}
|
|
189
|
+
// wp_set_link_cats
|
|
190
|
+
async updateCategory(linkId = 0, linkCategory = []) {
|
|
191
|
+
if (0 >= linkCategory.length) {
|
|
192
|
+
linkCategory = await this.defaultCategory();
|
|
193
|
+
}
|
|
194
|
+
const linkCategories = Array.from(new Set(linkCategory));
|
|
195
|
+
const termTrx = this.components.get(term_trx_1.TermTrx);
|
|
196
|
+
if (linkCategories.length > 0) {
|
|
197
|
+
await termTrx.syncObject(linkId, linkCategories, "link_category");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
exports.LinkTrx = LinkTrx;
|
|
202
|
+
exports.LinkTrx = LinkTrx = __decorate([
|
|
203
|
+
(0, component_1.transactions)(),
|
|
204
|
+
__metadata("design:paramtypes", [database_1.default,
|
|
205
|
+
logger_1.Logger,
|
|
206
|
+
components_1.Components,
|
|
207
|
+
validator_1.Validator])
|
|
208
|
+
], LinkTrx);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Components } from "../core/components";
|
|
2
|
+
import { Validator } from "../core/validator";
|
|
3
|
+
import Database from "../database";
|
|
4
|
+
import { Trx } from "./trx";
|
|
5
|
+
import type * as types from "../types";
|
|
6
|
+
type RemoveParams = {
|
|
7
|
+
key: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
} & ({
|
|
10
|
+
objectId: number;
|
|
11
|
+
deleteAll?: false;
|
|
12
|
+
} | {
|
|
13
|
+
deleteAll: true;
|
|
14
|
+
objectId?: undefined;
|
|
15
|
+
});
|
|
16
|
+
export declare class MetaTrx extends Trx {
|
|
17
|
+
private database;
|
|
18
|
+
private components;
|
|
19
|
+
private validator;
|
|
20
|
+
constructor(database: Database, components: Components, validator: Validator);
|
|
21
|
+
bulkUpsertObject(table: types.MetaTable, objectId: number, data: Record<string, any>): Promise<void>;
|
|
22
|
+
removeObject(table: types.MetaTable, objectId: number): Promise<boolean>;
|
|
23
|
+
remove(table: types.MetaTable, args: RemoveParams): Promise<boolean>;
|
|
24
|
+
upsert(table: types.MetaTable, objectId: number, key: string, value: any, args?: {
|
|
25
|
+
unique?: boolean;
|
|
26
|
+
serialize?: boolean;
|
|
27
|
+
}): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=meta.trx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.trx.d.ts","sourceRoot":"","sources":["../../src/transactions/meta.trx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AACvC,KAAK,YAAY,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,CAClD;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GACD;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CACJ,CAAC;AAEF,qBACa,OAAQ,SAAQ,GAAG;IAE5B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;gBAFT,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS;IAKxB,gBAAgB,CACpB,KAAK,EAAE,KAAK,CAAC,SAAS,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IASrB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM;IAerD,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY;IAkCjD,MAAM,CACV,KAAK,EAAE,KAAK,CAAC,SAAS,EACtB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,EACV,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB;CAwFJ"}
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.MetaTrx = void 0;
|
|
49
|
+
const common_1 = require("../common");
|
|
50
|
+
const components_1 = require("../core/components");
|
|
51
|
+
const query_util_1 = require("../core/utils/query.util");
|
|
52
|
+
const validator_1 = require("../core/validator");
|
|
53
|
+
const database_1 = __importDefault(require("../database"));
|
|
54
|
+
const component_1 = require("../decorators/component");
|
|
55
|
+
const val = __importStar(require("../validators"));
|
|
56
|
+
const trx_1 = require("./trx");
|
|
57
|
+
let MetaTrx = class MetaTrx extends trx_1.Trx {
|
|
58
|
+
database;
|
|
59
|
+
components;
|
|
60
|
+
validator;
|
|
61
|
+
constructor(database, components, validator) {
|
|
62
|
+
super(components);
|
|
63
|
+
this.database = database;
|
|
64
|
+
this.components = components;
|
|
65
|
+
this.validator = validator;
|
|
66
|
+
}
|
|
67
|
+
async bulkUpsertObject(table, objectId, data) {
|
|
68
|
+
for (const [key, value] of Object.entries(data)) {
|
|
69
|
+
await this.upsert(table, objectId, key, value, {
|
|
70
|
+
serialize: typeof value === "object" || Array.isArray(value),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async removeObject(table, objectId) {
|
|
75
|
+
const metaTable = this.tables.get(`${table}meta`);
|
|
76
|
+
const column = `${table}_id`;
|
|
77
|
+
const trx = await this.database.transaction;
|
|
78
|
+
try {
|
|
79
|
+
await trx.table(metaTable).where(column, objectId).del();
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
await trx.rollback();
|
|
83
|
+
throw new Error(`Failed to delete - ${e}`);
|
|
84
|
+
}
|
|
85
|
+
await trx.commit();
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
async remove(table, args) {
|
|
89
|
+
const { value, objectId, deleteAll } = args;
|
|
90
|
+
let { key } = args;
|
|
91
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
92
|
+
const metaTable = this.tables.get(`${table}meta`);
|
|
93
|
+
const metaColumn = table == "user" ? "umeta_id" : "meta_id";
|
|
94
|
+
key = common_1.formatting.unslash(key);
|
|
95
|
+
const metaIds = ((await queryUtil.meta(table, (query) => {
|
|
96
|
+
if (!deleteAll && objectId) {
|
|
97
|
+
query.withIds([objectId]);
|
|
98
|
+
}
|
|
99
|
+
value ? query.where(key, value) : query.withKeys([key]);
|
|
100
|
+
})) ?? []).map((v) => (table == "user" ? v.umeta_id : v.meta_id));
|
|
101
|
+
if (0 >= metaIds.length) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
const trx = await this.database.transaction;
|
|
105
|
+
try {
|
|
106
|
+
await trx.table(metaTable).whereIn(metaColumn, metaIds).del();
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
await trx.rollback();
|
|
110
|
+
throw new Error(`Failed to delete - ${e}`);
|
|
111
|
+
}
|
|
112
|
+
await trx.commit();
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
async upsert(table, objectId, key, value, args) {
|
|
116
|
+
const { unique = true, serialize = false } = args || {};
|
|
117
|
+
const queryUtil = this.components.get(query_util_1.QueryUtil);
|
|
118
|
+
const metaTable = this.tables.get(`${table}meta`);
|
|
119
|
+
const column = common_1.formatting.key(`${table}_id`);
|
|
120
|
+
key = common_1.formatting.unslash(key);
|
|
121
|
+
if (serialize) {
|
|
122
|
+
value = (0, common_1.phpSerialize)(value);
|
|
123
|
+
}
|
|
124
|
+
else if (typeof value === "boolean") {
|
|
125
|
+
value = true === value ? "1" : "0";
|
|
126
|
+
}
|
|
127
|
+
else if (typeof value == "undefined") {
|
|
128
|
+
value = "";
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
value = common_1.formatting.unslash(value);
|
|
132
|
+
}
|
|
133
|
+
// Compare existing value to new value if unique = true and the key exists only once.
|
|
134
|
+
if (unique) {
|
|
135
|
+
const oldMeta = await queryUtil.meta(table, (query) => {
|
|
136
|
+
query.withIds([objectId]).withKeys([key]);
|
|
137
|
+
});
|
|
138
|
+
if (oldMeta && 1 === oldMeta.length && oldMeta[0].meta_value === value) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const metaIds = ((await queryUtil.meta(table, (query) => {
|
|
143
|
+
query.withIds([objectId]).withKeys([key]);
|
|
144
|
+
})) ?? []).map((v) => (table === "user" ? v.umeta_id : v.meta_id));
|
|
145
|
+
if (0 >= metaIds.length) {
|
|
146
|
+
const dataInsert = this.validator.execSafeAny(val.trx.metaInsert(table), {
|
|
147
|
+
[column]: objectId,
|
|
148
|
+
meta_key: key,
|
|
149
|
+
meta_value: value,
|
|
150
|
+
});
|
|
151
|
+
if (!dataInsert) {
|
|
152
|
+
throw new Error(`Invalid Data ${JSON.stringify({
|
|
153
|
+
[column]: objectId,
|
|
154
|
+
meta_key: key,
|
|
155
|
+
meta_value: value,
|
|
156
|
+
})}`);
|
|
157
|
+
}
|
|
158
|
+
const trx = await this.database.transaction;
|
|
159
|
+
try {
|
|
160
|
+
await trx.insert(dataInsert).into(metaTable);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
await trx.rollback();
|
|
164
|
+
throw new Error(`Failed to insert ${e}`);
|
|
165
|
+
}
|
|
166
|
+
await trx.commit();
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
const dataUpdate = this.validator.execSafeAny(val.trx.metaUpdate, {
|
|
170
|
+
meta_value: value,
|
|
171
|
+
});
|
|
172
|
+
if (!dataUpdate) {
|
|
173
|
+
throw new Error(`Invalid Data - ${value}`);
|
|
174
|
+
}
|
|
175
|
+
const trx = await this.database.transaction;
|
|
176
|
+
try {
|
|
177
|
+
await trx
|
|
178
|
+
.table(metaTable)
|
|
179
|
+
.where(column, objectId)
|
|
180
|
+
.where("meta_key", key)
|
|
181
|
+
.update(dataUpdate);
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
await trx.rollback();
|
|
185
|
+
throw new Error(`Failed to update ${e}`);
|
|
186
|
+
}
|
|
187
|
+
await trx.commit();
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
exports.MetaTrx = MetaTrx;
|
|
192
|
+
exports.MetaTrx = MetaTrx = __decorate([
|
|
193
|
+
(0, component_1.transactions)(),
|
|
194
|
+
__metadata("design:paramtypes", [database_1.default,
|
|
195
|
+
components_1.Components,
|
|
196
|
+
validator_1.Validator])
|
|
197
|
+
], MetaTrx);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Config } from "../config";
|
|
2
|
+
import { Components } from "../core/components";
|
|
3
|
+
import { Logger } from "../core/logger";
|
|
4
|
+
import { Validator } from "../core/validator";
|
|
5
|
+
import Database from "../database";
|
|
6
|
+
import { Trx } from "./trx";
|
|
7
|
+
import type * as types from "../types";
|
|
8
|
+
export declare class OptionsTrx extends Trx {
|
|
9
|
+
private database;
|
|
10
|
+
private logger;
|
|
11
|
+
private components;
|
|
12
|
+
private config;
|
|
13
|
+
private validator;
|
|
14
|
+
constructor(database: Database, logger: Logger, components: Components, config: Config, validator: Validator);
|
|
15
|
+
update(key: types.DefaultOptionNames, value: any, autoload?: "yes" | "no"): Promise<boolean>;
|
|
16
|
+
update(key: string, value: string, autoload?: "yes" | "no"): Promise<boolean>;
|
|
17
|
+
insert(key: types.DefaultOptionNames, value: string | number | object | boolean, options?: {
|
|
18
|
+
autoload?: "yes" | "no";
|
|
19
|
+
upsert?: boolean;
|
|
20
|
+
seriazlie?: boolean;
|
|
21
|
+
force?: boolean;
|
|
22
|
+
}): Promise<number>;
|
|
23
|
+
insert(key: string, value: string | number | object | boolean, options?: {
|
|
24
|
+
autoload?: "yes" | "no";
|
|
25
|
+
upsert?: boolean;
|
|
26
|
+
seriazlie?: boolean;
|
|
27
|
+
force?: boolean;
|
|
28
|
+
}): Promise<number>;
|
|
29
|
+
remove(key: string): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=options.trx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.trx.d.ts","sourceRoot":"","sources":["../../src/transactions/options.trx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AACvC,qBACa,UAAW,SAAQ,GAAG;IAE/B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;gBAJT,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS;IAKxB,MAAM,CACV,GAAG,EAAE,KAAK,CAAC,kBAAkB,EAC7B,KAAK,EAAE,GAAG,EACV,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,GACtB,OAAO,CAAC,OAAO,CAAC;IACb,MAAM,CACV,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,GACtB,OAAO,CAAC,OAAO,CAAC;IAmDb,MAAM,CACV,GAAG,EAAE,KAAK,CAAC,kBAAkB,EAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EACzC,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GACA,OAAO,CAAC,MAAM,CAAC;IACZ,MAAM,CACV,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EACzC,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GACA,OAAO,CAAC,MAAM,CAAC;IAsEZ,MAAM,CAAC,GAAG,EAAE,MAAM;CAwBzB"}
|