directus 9.23.1 → 9.23.4
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/dist/app.js +25 -21
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +57 -46
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +20 -17
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +44 -35
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +50 -41
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +20 -17
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +8 -7
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +66 -18
- package/dist/cli/commands/bootstrap/index.js +7 -6
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +14 -15
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +3 -2
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/cli/utils/drivers.d.ts +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +7 -7
- package/dist/controllers/activity.js +10 -11
- package/dist/controllers/assets.js +31 -25
- package/dist/controllers/auth.js +40 -26
- package/dist/controllers/collections.js +10 -10
- package/dist/controllers/dashboards.js +14 -11
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +20 -20
- package/dist/controllers/files.js +26 -20
- package/dist/controllers/flows.js +16 -13
- package/dist/controllers/folders.js +14 -11
- package/dist/controllers/graphql.js +6 -8
- package/dist/controllers/items.js +22 -19
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +14 -11
- package/dist/controllers/operations.js +14 -11
- package/dist/controllers/panels.js +14 -11
- package/dist/controllers/permissions.js +14 -11
- package/dist/controllers/presets.js +14 -11
- package/dist/controllers/relations.js +10 -10
- package/dist/controllers/revisions.js +3 -3
- package/dist/controllers/roles.js +14 -11
- package/dist/controllers/schema.js +5 -5
- package/dist/controllers/server.js +7 -7
- package/dist/controllers/settings.js +2 -2
- package/dist/controllers/shares.js +21 -18
- package/dist/controllers/users.js +32 -36
- package/dist/controllers/utils.js +10 -15
- package/dist/controllers/webhooks.js +14 -11
- package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mssql.js +10 -11
- package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mysql.js +2 -3
- package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/oracle.js +10 -11
- package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/postgres.js +10 -11
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
- package/dist/database/helpers/fn/types.d.ts +5 -6
- package/dist/database/helpers/fn/types.js +4 -5
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/geometry/types.d.ts +2 -2
- package/dist/database/helpers/geometry/types.js +1 -2
- package/dist/database/helpers/index.d.ts +5 -5
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.js +1 -2
- package/dist/database/helpers/schema/dialects/oracle.d.ts +2 -2
- package/dist/database/helpers/schema/dialects/oracle.js +4 -6
- package/dist/database/helpers/schema/types.d.ts +4 -4
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.js +13 -13
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
- package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
- package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +15 -15
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.js +7 -9
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
- package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
- package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
- package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
- package/dist/database/migrations/run.d.ts +1 -1
- package/dist/database/migrations/run.js +1 -1
- package/dist/database/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +21 -30
- package/dist/database/seeds/run.d.ts +1 -1
- package/dist/database/seeds/run.js +1 -2
- package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.js +2 -2
- package/dist/database/system-data/fields/collections.yaml +2 -0
- package/dist/database/system-data/fields/index.d.ts +1 -1
- package/dist/database/system-data/fields/index.js +3 -4
- package/dist/database/system-data/fields/settings.yaml +4 -0
- package/dist/database/system-data/relations/index.d.ts +1 -1
- package/dist/emitter.d.ts +1 -1
- package/dist/emitter.js +3 -0
- package/dist/env.js +11 -3
- package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mssql.js +5 -6
- package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mysql.js +19 -25
- package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
- package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
- package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
- package/dist/exceptions/database/translate.d.ts +1 -1
- package/dist/exceptions/database/value-out-of-range.js +1 -1
- package/dist/exceptions/range-not-satisfiable.js +2 -3
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +43 -33
- package/dist/flows.js +65 -46
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +35 -19
- package/dist/logger.test.d.ts +1 -0
- package/dist/mailer.js +16 -16
- package/dist/messenger.js +9 -7
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +13 -6
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +16 -16
- package/dist/middleware/check-ip.d.ts +1 -1
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/collection-exists.d.ts +1 -1
- package/dist/middleware/collection-exists.js +5 -5
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/cors.js +7 -7
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +11 -12
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/extract-token.js +2 -2
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +15 -9
- package/dist/middleware/rate-limiter-global.d.ts +5 -0
- package/dist/middleware/rate-limiter-global.js +48 -0
- package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
- package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +5 -5
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +18 -19
- package/dist/middleware/sanitize-query.d.ts +1 -1
- package/dist/middleware/sanitize-query.js +1 -1
- package/dist/middleware/schema.d.ts +1 -1
- package/dist/middleware/use-collection.d.ts +1 -1
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/exec/index.js +15 -4
- package/dist/operations/item-create/index.js +1 -2
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/item-update/index.js +1 -2
- package/dist/operations/notification/index.js +1 -2
- package/dist/operations/request/index.js +19 -19
- package/dist/operations/trigger/index.js +2 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +9 -9
- package/dist/request/validate-ip.js +2 -2
- package/dist/server.js +12 -13
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +17 -16
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +35 -37
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +22 -19
- package/dist/services/authorization.d.ts +3 -3
- package/dist/services/authorization.js +27 -31
- package/dist/services/collections.d.ts +5 -5
- package/dist/services/collections.js +54 -50
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +50 -50
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +33 -27
- package/dist/services/flows.d.ts +2 -2
- package/dist/services/folders.d.ts +1 -1
- package/dist/services/graphql/index.d.ts +4 -4
- package/dist/services/graphql/index.js +259 -252
- package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
- package/dist/services/graphql/utils/process-error.d.ts +2 -2
- package/dist/services/graphql/utils/process-error.js +11 -4
- package/dist/services/import-export.d.ts +3 -3
- package/dist/services/import-export.js +30 -27
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +42 -36
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +14 -10
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +11 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +10 -9
- package/dist/services/operations.d.ts +2 -2
- package/dist/services/panels.d.ts +1 -1
- package/dist/services/payload.d.ts +3 -3
- package/dist/services/payload.js +124 -122
- package/dist/services/permissions.d.ts +3 -3
- package/dist/services/permissions.js +11 -11
- package/dist/services/presets.d.ts +1 -1
- package/dist/services/relations.d.ts +6 -6
- package/dist/services/relations.js +45 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +7 -7
- package/dist/services/schema.d.ts +3 -3
- package/dist/services/schema.js +9 -11
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +88 -32
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +1 -1
- package/dist/services/shares.js +14 -15
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +137 -119
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +2 -6
- package/dist/services/users.js +37 -40
- package/dist/services/utils.d.ts +3 -3
- package/dist/services/utils.js +10 -8
- package/dist/services/webhooks.d.ts +2 -2
- package/dist/services/webhooks.js +2 -1
- package/dist/storage/register-locations.js +1 -1
- package/dist/types/assets.d.ts +1 -1
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collection.d.ts +2 -2
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/items.d.ts +3 -3
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/utils/apply-diff.d.ts +3 -3
- package/dist/utils/apply-diff.js +25 -28
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +10 -12
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +5 -6
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/dynamic-import.js +1 -1
- package/dist/utils/filter-items.d.ts +1 -1
- package/dist/utils/generate-hash.js +1 -1
- package/dist/utils/get-accountability-for-role.d.ts +2 -2
- package/dist/utils/get-accountability-for-role.js +1 -1
- package/dist/utils/get-ast-from-query.d.ts +3 -3
- package/dist/utils/get-ast-from-query.js +22 -28
- package/dist/utils/get-auth-providers.js +1 -1
- package/dist/utils/get-cache-headers.d.ts +1 -1
- package/dist/utils/get-cache-headers.js +6 -7
- package/dist/utils/get-cache-key.d.ts +1 -1
- package/dist/utils/get-cache-key.js +2 -3
- package/dist/utils/get-collection-from-alias.d.ts +1 -1
- package/dist/utils/get-collection-from-alias.js +1 -0
- package/dist/utils/get-column-path.d.ts +2 -2
- package/dist/utils/get-column-path.js +3 -4
- package/dist/utils/get-column.d.ts +4 -4
- package/dist/utils/get-column.js +4 -5
- package/dist/utils/get-default-value.d.ts +2 -2
- package/dist/utils/get-default-value.js +2 -3
- package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
- package/dist/utils/get-graphql-query-and-variables.js +1 -2
- package/dist/utils/get-graphql-type.d.ts +2 -2
- package/dist/utils/get-graphql-type.js +1 -1
- package/dist/utils/get-ip-from-req.d.ts +1 -1
- package/dist/utils/get-ip-from-req.js +2 -2
- package/dist/utils/get-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.js +1 -2
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +12 -12
- package/dist/utils/get-relation-info.d.ts +1 -1
- package/dist/utils/get-relation-info.js +3 -5
- package/dist/utils/get-relation-type.d.ts +1 -1
- package/dist/utils/get-relation-type.js +3 -4
- package/dist/utils/get-schema.d.ts +2 -2
- package/dist/utils/get-schema.js +20 -22
- package/dist/utils/get-snapshot-diff.js +2 -3
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +6 -8
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/is-url-allowed.js +5 -2
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.js +3 -4
- package/dist/utils/merge-permissions.d.ts +3 -3
- package/dist/utils/reduce-schema.d.ts +1 -1
- package/dist/utils/reduce-schema.js +12 -12
- package/dist/utils/sanitize-query.d.ts +1 -1
- package/dist/utils/sanitize-query.js +27 -27
- package/dist/utils/sanitize-schema.d.ts +2 -2
- package/dist/utils/should-skip-cache.d.ts +7 -0
- package/dist/utils/should-skip-cache.js +21 -0
- package/dist/utils/should-skip-cache.test.d.ts +1 -0
- package/dist/utils/track.js +16 -16
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +7 -2
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.js +7 -8
- package/dist/utils/validate-keys.d.ts +2 -2
- package/dist/utils/validate-keys.js +1 -1
- package/dist/utils/validate-query.d.ts +1 -1
- package/dist/utils/validate-query.js +3 -3
- package/dist/utils/validate-storage.js +8 -8
- package/dist/webhooks.js +3 -3
- package/package.json +36 -37
- package/dist/utils/with-timeout.d.ts +0 -1
- package/dist/utils/with-timeout.js +0 -16
package/dist/services/meta.js
CHANGED
|
@@ -8,6 +8,9 @@ const database_1 = __importDefault(require("../database"));
|
|
|
8
8
|
const exceptions_1 = require("../exceptions");
|
|
9
9
|
const apply_query_1 = require("../utils/apply-query");
|
|
10
10
|
class MetaService {
|
|
11
|
+
knex;
|
|
12
|
+
accountability;
|
|
13
|
+
schema;
|
|
11
14
|
constructor(options) {
|
|
12
15
|
this.knex = options.knex || (0, database_1.default)();
|
|
13
16
|
this.accountability = options.accountability || null;
|
|
@@ -22,6 +25,7 @@ class MetaService {
|
|
|
22
25
|
return this.totalCount(collection);
|
|
23
26
|
if (metaVal === 'filter_count')
|
|
24
27
|
return this.filterCount(collection, query);
|
|
28
|
+
return undefined;
|
|
25
29
|
}));
|
|
26
30
|
return results.reduce((metaObject, value, index) => {
|
|
27
31
|
return {
|
|
@@ -31,31 +35,29 @@ class MetaService {
|
|
|
31
35
|
}, {});
|
|
32
36
|
}
|
|
33
37
|
async totalCount(collection) {
|
|
34
|
-
var _a, _b, _c, _d, _e;
|
|
35
38
|
const dbQuery = this.knex(collection).count('*', { as: 'count' }).first();
|
|
36
|
-
if (
|
|
37
|
-
const permissionsRecord =
|
|
39
|
+
if (this.accountability?.admin !== true) {
|
|
40
|
+
const permissionsRecord = this.accountability?.permissions?.find((permission) => {
|
|
38
41
|
return permission.action === 'read' && permission.collection === collection;
|
|
39
42
|
});
|
|
40
43
|
if (!permissionsRecord)
|
|
41
44
|
throw new exceptions_1.ForbiddenException();
|
|
42
|
-
const permissions =
|
|
45
|
+
const permissions = permissionsRecord.permissions ?? {};
|
|
43
46
|
(0, apply_query_1.applyFilter)(this.knex, this.schema, dbQuery, permissions, collection, {});
|
|
44
47
|
}
|
|
45
48
|
const result = await dbQuery;
|
|
46
|
-
return Number(
|
|
49
|
+
return Number(result?.count ?? 0);
|
|
47
50
|
}
|
|
48
51
|
async filterCount(collection, query) {
|
|
49
|
-
var _a, _b, _c, _d;
|
|
50
52
|
const dbQuery = this.knex(collection).count('*', { as: 'count' });
|
|
51
53
|
let filter = query.filter || {};
|
|
52
|
-
if (
|
|
53
|
-
const permissionsRecord =
|
|
54
|
+
if (this.accountability?.admin !== true) {
|
|
55
|
+
const permissionsRecord = this.accountability?.permissions?.find((permission) => {
|
|
54
56
|
return permission.action === 'read' && permission.collection === collection;
|
|
55
57
|
});
|
|
56
58
|
if (!permissionsRecord)
|
|
57
59
|
throw new exceptions_1.ForbiddenException();
|
|
58
|
-
const permissions =
|
|
60
|
+
const permissions = permissionsRecord.permissions ?? {};
|
|
59
61
|
if (Object.keys(filter).length > 0) {
|
|
60
62
|
filter = { _and: [permissions, filter] };
|
|
61
63
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Notification } from '@directus/shared/types';
|
|
2
|
+
import type { AbstractServiceOptions, MutationOptions, PrimaryKey } from '../types';
|
|
2
3
|
import { ItemsService } from './items';
|
|
3
|
-
import { Notification } from '@directus/shared/types';
|
|
4
|
-
import { UsersService } from './users';
|
|
5
4
|
import { MailService } from './mail';
|
|
5
|
+
import { UsersService } from './users';
|
|
6
6
|
export declare class NotificationsService extends ItemsService {
|
|
7
7
|
usersService: UsersService;
|
|
8
8
|
mailService: MailService;
|
|
@@ -4,14 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NotificationsService = void 0;
|
|
7
|
-
const
|
|
7
|
+
const env_1 = __importDefault(require("../env"));
|
|
8
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
8
9
|
const md_1 = require("../utils/md");
|
|
9
10
|
const url_1 = require("../utils/url");
|
|
10
|
-
const
|
|
11
|
+
const items_1 = require("./items");
|
|
11
12
|
const mail_1 = require("./mail");
|
|
12
|
-
const
|
|
13
|
-
const env_1 = __importDefault(require("../env"));
|
|
13
|
+
const users_1 = require("./users");
|
|
14
14
|
class NotificationsService extends items_1.ItemsService {
|
|
15
|
+
usersService;
|
|
16
|
+
mailService;
|
|
15
17
|
constructor(options) {
|
|
16
18
|
super('directus_notifications', options);
|
|
17
19
|
this.usersService = new users_1.UsersService({ schema: this.schema });
|
|
@@ -30,21 +32,20 @@ class NotificationsService extends items_1.ItemsService {
|
|
|
30
32
|
return response;
|
|
31
33
|
}
|
|
32
34
|
async sendEmail(data) {
|
|
33
|
-
var _a;
|
|
34
35
|
if (data.recipient) {
|
|
35
36
|
const user = await this.usersService.readOne(data.recipient, {
|
|
36
37
|
fields: ['id', 'email', 'email_notifications', 'role.app_access'],
|
|
37
38
|
});
|
|
38
|
-
const manageUserAccountUrl = new url_1.Url(env_1.default
|
|
39
|
+
const manageUserAccountUrl = new url_1.Url(env_1.default['PUBLIC_URL']).addPath('admin', 'users', user['id']).toString();
|
|
39
40
|
const html = data.message ? (0, md_1.md)(data.message) : '';
|
|
40
|
-
if (user
|
|
41
|
+
if (user['email'] && user['email_notifications'] === true) {
|
|
41
42
|
try {
|
|
42
43
|
await this.mailService.send({
|
|
43
44
|
template: {
|
|
44
45
|
name: 'base',
|
|
45
|
-
data:
|
|
46
|
+
data: user['role']?.app_access ? { url: manageUserAccountUrl, html } : { html },
|
|
46
47
|
},
|
|
47
|
-
to: user
|
|
48
|
+
to: user['email'],
|
|
48
49
|
subject: data.subject,
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OperationRaw } from '@directus/shared/types';
|
|
2
|
-
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
1
|
+
import type { OperationRaw } from '@directus/shared/types';
|
|
2
|
+
import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
3
3
|
import { ItemsService } from './items';
|
|
4
4
|
export declare class OperationsService extends ItemsService<OperationRaw> {
|
|
5
5
|
constructor(options: AbstractServiceOptions);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { Knex } from 'knex';
|
|
1
|
+
import type { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
3
|
import { Helpers } from '../database/helpers';
|
|
4
|
-
import { AbstractServiceOptions, ActionEventParams, Item, MutationOptions, PrimaryKey } from '../types';
|
|
4
|
+
import type { AbstractServiceOptions, ActionEventParams, Item, MutationOptions, PrimaryKey } from '../types';
|
|
5
5
|
type Action = 'create' | 'read' | 'update';
|
|
6
6
|
type Transformers = {
|
|
7
7
|
[type: string]: (context: {
|
package/dist/services/payload.js
CHANGED
|
@@ -21,100 +21,12 @@ const items_1 = require("./items");
|
|
|
21
21
|
* handled correctly.
|
|
22
22
|
*/
|
|
23
23
|
class PayloadService {
|
|
24
|
+
accountability;
|
|
25
|
+
knex;
|
|
26
|
+
helpers;
|
|
27
|
+
collection;
|
|
28
|
+
schema;
|
|
24
29
|
constructor(collection, options) {
|
|
25
|
-
this.transformers = {
|
|
26
|
-
async hash({ action, value }) {
|
|
27
|
-
if (!value)
|
|
28
|
-
return;
|
|
29
|
-
if (action === 'create' || action === 'update') {
|
|
30
|
-
return await (0, generate_hash_1.generateHash)(String(value));
|
|
31
|
-
}
|
|
32
|
-
return value;
|
|
33
|
-
},
|
|
34
|
-
async uuid({ action, value }) {
|
|
35
|
-
if (action === 'create' && !value) {
|
|
36
|
-
return (0, uuid_1.v4)();
|
|
37
|
-
}
|
|
38
|
-
return value;
|
|
39
|
-
},
|
|
40
|
-
async 'cast-boolean'({ action, value }) {
|
|
41
|
-
if (action === 'read') {
|
|
42
|
-
if (value === true || value === 1 || value === '1') {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
else if (value === false || value === 0 || value === '0') {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
else if (value === null || value === '') {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return value;
|
|
53
|
-
},
|
|
54
|
-
async 'cast-json'({ action, value }) {
|
|
55
|
-
if (action === 'read') {
|
|
56
|
-
if (typeof value === 'string') {
|
|
57
|
-
try {
|
|
58
|
-
return (0, utils_1.parseJSON)(value);
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return value;
|
|
66
|
-
},
|
|
67
|
-
async conceal({ action, value }) {
|
|
68
|
-
if (action === 'read')
|
|
69
|
-
return value ? '**********' : null;
|
|
70
|
-
return value;
|
|
71
|
-
},
|
|
72
|
-
async 'user-created'({ action, value, accountability }) {
|
|
73
|
-
if (action === 'create')
|
|
74
|
-
return (accountability === null || accountability === void 0 ? void 0 : accountability.user) || null;
|
|
75
|
-
return value;
|
|
76
|
-
},
|
|
77
|
-
async 'user-updated'({ action, value, accountability }) {
|
|
78
|
-
if (action === 'update')
|
|
79
|
-
return (accountability === null || accountability === void 0 ? void 0 : accountability.user) || null;
|
|
80
|
-
return value;
|
|
81
|
-
},
|
|
82
|
-
async 'role-created'({ action, value, accountability }) {
|
|
83
|
-
if (action === 'create')
|
|
84
|
-
return (accountability === null || accountability === void 0 ? void 0 : accountability.role) || null;
|
|
85
|
-
return value;
|
|
86
|
-
},
|
|
87
|
-
async 'role-updated'({ action, value, accountability }) {
|
|
88
|
-
if (action === 'update')
|
|
89
|
-
return (accountability === null || accountability === void 0 ? void 0 : accountability.role) || null;
|
|
90
|
-
return value;
|
|
91
|
-
},
|
|
92
|
-
async 'date-created'({ action, value, helpers }) {
|
|
93
|
-
if (action === 'create')
|
|
94
|
-
return new Date(helpers.date.writeTimestamp(new Date().toISOString()));
|
|
95
|
-
return value;
|
|
96
|
-
},
|
|
97
|
-
async 'date-updated'({ action, value, helpers }) {
|
|
98
|
-
if (action === 'update')
|
|
99
|
-
return new Date(helpers.date.writeTimestamp(new Date().toISOString()));
|
|
100
|
-
return value;
|
|
101
|
-
},
|
|
102
|
-
async 'cast-csv'({ action, value }) {
|
|
103
|
-
if (Array.isArray(value) === false && typeof value !== 'string')
|
|
104
|
-
return;
|
|
105
|
-
if (action === 'read') {
|
|
106
|
-
if (Array.isArray(value))
|
|
107
|
-
return value;
|
|
108
|
-
if (value === '')
|
|
109
|
-
return [];
|
|
110
|
-
return value.split(',');
|
|
111
|
-
}
|
|
112
|
-
if (Array.isArray(value)) {
|
|
113
|
-
return value.join(',');
|
|
114
|
-
}
|
|
115
|
-
return value;
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
30
|
this.accountability = options.accountability || null;
|
|
119
31
|
this.knex = options.knex || (0, database_1.default)();
|
|
120
32
|
this.helpers = (0, helpers_1.getHelpers)(this.knex);
|
|
@@ -122,6 +34,99 @@ class PayloadService {
|
|
|
122
34
|
this.schema = options.schema;
|
|
123
35
|
return this;
|
|
124
36
|
}
|
|
37
|
+
transformers = {
|
|
38
|
+
async hash({ action, value }) {
|
|
39
|
+
if (!value)
|
|
40
|
+
return;
|
|
41
|
+
if (action === 'create' || action === 'update') {
|
|
42
|
+
return await (0, generate_hash_1.generateHash)(String(value));
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
},
|
|
46
|
+
async uuid({ action, value }) {
|
|
47
|
+
if (action === 'create' && !value) {
|
|
48
|
+
return (0, uuid_1.v4)();
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
},
|
|
52
|
+
async 'cast-boolean'({ action, value }) {
|
|
53
|
+
if (action === 'read') {
|
|
54
|
+
if (value === true || value === 1 || value === '1') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
else if (value === false || value === 0 || value === '0') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
else if (value === null || value === '') {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
},
|
|
66
|
+
async 'cast-json'({ action, value }) {
|
|
67
|
+
if (action === 'read') {
|
|
68
|
+
if (typeof value === 'string') {
|
|
69
|
+
try {
|
|
70
|
+
return (0, utils_1.parseJSON)(value);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
},
|
|
79
|
+
async conceal({ action, value }) {
|
|
80
|
+
if (action === 'read')
|
|
81
|
+
return value ? '**********' : null;
|
|
82
|
+
return value;
|
|
83
|
+
},
|
|
84
|
+
async 'user-created'({ action, value, accountability }) {
|
|
85
|
+
if (action === 'create')
|
|
86
|
+
return accountability?.user || null;
|
|
87
|
+
return value;
|
|
88
|
+
},
|
|
89
|
+
async 'user-updated'({ action, value, accountability }) {
|
|
90
|
+
if (action === 'update')
|
|
91
|
+
return accountability?.user || null;
|
|
92
|
+
return value;
|
|
93
|
+
},
|
|
94
|
+
async 'role-created'({ action, value, accountability }) {
|
|
95
|
+
if (action === 'create')
|
|
96
|
+
return accountability?.role || null;
|
|
97
|
+
return value;
|
|
98
|
+
},
|
|
99
|
+
async 'role-updated'({ action, value, accountability }) {
|
|
100
|
+
if (action === 'update')
|
|
101
|
+
return accountability?.role || null;
|
|
102
|
+
return value;
|
|
103
|
+
},
|
|
104
|
+
async 'date-created'({ action, value, helpers }) {
|
|
105
|
+
if (action === 'create')
|
|
106
|
+
return new Date(helpers.date.writeTimestamp(new Date().toISOString()));
|
|
107
|
+
return value;
|
|
108
|
+
},
|
|
109
|
+
async 'date-updated'({ action, value, helpers }) {
|
|
110
|
+
if (action === 'update')
|
|
111
|
+
return new Date(helpers.date.writeTimestamp(new Date().toISOString()));
|
|
112
|
+
return value;
|
|
113
|
+
},
|
|
114
|
+
async 'cast-csv'({ action, value }) {
|
|
115
|
+
if (Array.isArray(value) === false && typeof value !== 'string')
|
|
116
|
+
return;
|
|
117
|
+
if (action === 'read') {
|
|
118
|
+
if (Array.isArray(value))
|
|
119
|
+
return value;
|
|
120
|
+
if (value === '')
|
|
121
|
+
return [];
|
|
122
|
+
return value.split(',');
|
|
123
|
+
}
|
|
124
|
+
if (Array.isArray(value)) {
|
|
125
|
+
return value.join(',');
|
|
126
|
+
}
|
|
127
|
+
return value;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
125
130
|
async processValues(action, payload) {
|
|
126
131
|
const processedPayload = (0, utils_1.toArray)(payload);
|
|
127
132
|
if (processedPayload.length === 0)
|
|
@@ -303,7 +308,6 @@ class PayloadService {
|
|
|
303
308
|
* Recursively save/update all nested related Any-to-One items
|
|
304
309
|
*/
|
|
305
310
|
async processA2O(data, opts) {
|
|
306
|
-
var _a, _b;
|
|
307
311
|
const relations = this.schema.relations.filter((relation) => {
|
|
308
312
|
return relation.collection === this.collection;
|
|
309
313
|
});
|
|
@@ -316,7 +320,7 @@ class PayloadService {
|
|
|
316
320
|
});
|
|
317
321
|
for (const relation of relationsToProcess) {
|
|
318
322
|
// If the required a2o configuration fields are missing, this is a m2o instead of an a2o
|
|
319
|
-
if (!
|
|
323
|
+
if (!relation.meta?.one_collection_field || !relation.meta?.one_allowed_collections)
|
|
320
324
|
continue;
|
|
321
325
|
const relatedCollection = payload[relation.meta.one_collection_field];
|
|
322
326
|
if (!relatedCollection) {
|
|
@@ -348,16 +352,16 @@ class PayloadService {
|
|
|
348
352
|
if (Object.keys(fieldsToUpdate).length > 0) {
|
|
349
353
|
await itemsService.updateOne(relatedPrimaryKey, relatedRecord, {
|
|
350
354
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
351
|
-
bypassEmitAction: (params) =>
|
|
352
|
-
emitEvents: opts
|
|
355
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
356
|
+
emitEvents: opts?.emitEvents,
|
|
353
357
|
});
|
|
354
358
|
}
|
|
355
359
|
}
|
|
356
360
|
else {
|
|
357
361
|
relatedPrimaryKey = await itemsService.createOne(relatedRecord, {
|
|
358
362
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
359
|
-
bypassEmitAction: (params) =>
|
|
360
|
-
emitEvents: opts
|
|
363
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
364
|
+
emitEvents: opts?.emitEvents,
|
|
361
365
|
});
|
|
362
366
|
}
|
|
363
367
|
// Overwrite the nested object with just the primary key, so the parent level can be saved correctly
|
|
@@ -408,16 +412,16 @@ class PayloadService {
|
|
|
408
412
|
if (Object.keys(fieldsToUpdate).length > 0) {
|
|
409
413
|
await itemsService.updateOne(relatedPrimaryKey, relatedRecord, {
|
|
410
414
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
411
|
-
bypassEmitAction: (params) =>
|
|
412
|
-
emitEvents: opts
|
|
415
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
416
|
+
emitEvents: opts?.emitEvents,
|
|
413
417
|
});
|
|
414
418
|
}
|
|
415
419
|
}
|
|
416
420
|
else {
|
|
417
421
|
relatedPrimaryKey = await itemsService.createOne(relatedRecord, {
|
|
418
422
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
419
|
-
bypassEmitAction: (params) =>
|
|
420
|
-
emitEvents: opts
|
|
423
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
424
|
+
emitEvents: opts?.emitEvents,
|
|
421
425
|
});
|
|
422
426
|
}
|
|
423
427
|
// Overwrite the nested object with just the primary key, so the parent level can be saved correctly
|
|
@@ -437,8 +441,7 @@ class PayloadService {
|
|
|
437
441
|
const payload = (0, lodash_1.cloneDeep)(data);
|
|
438
442
|
// Only process related records that are actually in the payload
|
|
439
443
|
const relationsToProcess = relations.filter((relation) => {
|
|
440
|
-
|
|
441
|
-
if (!((_a = relation.meta) === null || _a === void 0 ? void 0 : _a.one_field))
|
|
444
|
+
if (!relation.meta?.one_field)
|
|
442
445
|
return false;
|
|
443
446
|
return relation.meta.one_field in payload;
|
|
444
447
|
});
|
|
@@ -498,8 +501,8 @@ class PayloadService {
|
|
|
498
501
|
}
|
|
499
502
|
savedPrimaryKeys.push(...(await itemsService.upsertMany(recordsToUpsert, {
|
|
500
503
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
501
|
-
bypassEmitAction: (params) =>
|
|
502
|
-
emitEvents: opts
|
|
504
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
505
|
+
emitEvents: opts?.emitEvents,
|
|
503
506
|
})));
|
|
504
507
|
const query = {
|
|
505
508
|
filter: {
|
|
@@ -521,15 +524,15 @@ class PayloadService {
|
|
|
521
524
|
if (relation.meta.one_deselect_action === 'delete') {
|
|
522
525
|
// There's no revision for a deletion
|
|
523
526
|
await itemsService.deleteByQuery(query, {
|
|
524
|
-
bypassEmitAction: (params) =>
|
|
525
|
-
emitEvents: opts
|
|
527
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
528
|
+
emitEvents: opts?.emitEvents,
|
|
526
529
|
});
|
|
527
530
|
}
|
|
528
531
|
else {
|
|
529
532
|
await itemsService.updateByQuery(query, { [relation.field]: null }, {
|
|
530
533
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
531
|
-
bypassEmitAction: (params) =>
|
|
532
|
-
emitEvents: opts
|
|
534
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
535
|
+
emitEvents: opts?.emitEvents,
|
|
533
536
|
});
|
|
534
537
|
}
|
|
535
538
|
}
|
|
@@ -553,7 +556,7 @@ class PayloadService {
|
|
|
553
556
|
const record = (0, lodash_1.cloneDeep)(item);
|
|
554
557
|
// add sort field value if it is not supplied in the item
|
|
555
558
|
if (parent !== null && record[sortField] === undefined) {
|
|
556
|
-
record[sortField] =
|
|
559
|
+
record[sortField] = highestOrderNumber?.max ? highestOrderNumber.max + index + 1 : index + 1;
|
|
557
560
|
}
|
|
558
561
|
return {
|
|
559
562
|
...record,
|
|
@@ -569,8 +572,8 @@ class PayloadService {
|
|
|
569
572
|
}
|
|
570
573
|
await itemsService.createMany(createPayload, {
|
|
571
574
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
572
|
-
bypassEmitAction: (params) =>
|
|
573
|
-
emitEvents: opts
|
|
575
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
576
|
+
emitEvents: opts?.emitEvents,
|
|
574
577
|
});
|
|
575
578
|
}
|
|
576
579
|
if (alterations.update) {
|
|
@@ -581,8 +584,8 @@ class PayloadService {
|
|
|
581
584
|
[relation.field]: parent || payload[currentPrimaryKeyField],
|
|
582
585
|
}, {
|
|
583
586
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
584
|
-
bypassEmitAction: (params) =>
|
|
585
|
-
emitEvents: opts
|
|
587
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
588
|
+
emitEvents: opts?.emitEvents,
|
|
586
589
|
});
|
|
587
590
|
}
|
|
588
591
|
}
|
|
@@ -605,15 +608,15 @@ class PayloadService {
|
|
|
605
608
|
};
|
|
606
609
|
if (relation.meta.one_deselect_action === 'delete') {
|
|
607
610
|
await itemsService.deleteByQuery(query, {
|
|
608
|
-
bypassEmitAction: (params) =>
|
|
609
|
-
emitEvents: opts
|
|
611
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
612
|
+
emitEvents: opts?.emitEvents,
|
|
610
613
|
});
|
|
611
614
|
}
|
|
612
615
|
else {
|
|
613
616
|
await itemsService.updateByQuery(query, { [relation.field]: null }, {
|
|
614
617
|
onRevisionCreate: (pk) => revisions.push(pk),
|
|
615
|
-
bypassEmitAction: (params) =>
|
|
616
|
-
emitEvents: opts
|
|
618
|
+
bypassEmitAction: (params) => opts?.bypassEmitAction ? opts.bypassEmitAction(params) : nestedActionEvents.push(params),
|
|
619
|
+
emitEvents: opts?.emitEvents,
|
|
617
620
|
});
|
|
618
621
|
}
|
|
619
622
|
}
|
|
@@ -626,10 +629,9 @@ class PayloadService {
|
|
|
626
629
|
* between delta and data
|
|
627
630
|
*/
|
|
628
631
|
async prepareDelta(data) {
|
|
629
|
-
var _a;
|
|
630
632
|
let payload = (0, lodash_1.cloneDeep)(data);
|
|
631
633
|
for (const key in payload) {
|
|
632
|
-
if (
|
|
634
|
+
if (payload[key]?.isRawInstance) {
|
|
633
635
|
payload[key] = payload[key].bindings[0];
|
|
634
636
|
}
|
|
635
637
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { PermissionsAction, Query } from '@directus/shared/types';
|
|
2
|
+
import type Keyv from 'keyv';
|
|
1
3
|
import { ItemsService, QueryOptions } from '../services/items';
|
|
2
|
-
import { AbstractServiceOptions, Item,
|
|
3
|
-
import { Query, PermissionsAction } from '@directus/shared/types';
|
|
4
|
-
import Keyv from 'keyv';
|
|
4
|
+
import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
5
5
|
export declare class PermissionsService extends ItemsService {
|
|
6
6
|
systemCache: Keyv<any>;
|
|
7
7
|
constructor(options: AbstractServiceOptions);
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PermissionsService = void 0;
|
|
4
|
+
const cache_1 = require("../cache");
|
|
4
5
|
const app_access_permissions_1 = require("../database/system-data/app-access-permissions");
|
|
5
6
|
const items_1 = require("../services/items");
|
|
6
7
|
const filter_items_1 = require("../utils/filter-items");
|
|
7
|
-
const cache_1 = require("../cache");
|
|
8
8
|
class PermissionsService extends items_1.ItemsService {
|
|
9
|
+
systemCache;
|
|
9
10
|
constructor(options) {
|
|
10
11
|
super('directus_permissions', options);
|
|
11
12
|
const { systemCache } = (0, cache_1.getCache)();
|
|
12
13
|
this.systemCache = systemCache;
|
|
13
14
|
}
|
|
14
15
|
getAllowedFields(action, collection) {
|
|
15
|
-
|
|
16
|
-
const results = (_c = (_b = (_a = this.accountability) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.filter((permission) => {
|
|
16
|
+
const results = this.accountability?.permissions?.filter((permission) => {
|
|
17
17
|
let matchesCollection = true;
|
|
18
18
|
if (collection) {
|
|
19
19
|
matchesCollection = permission.collection === collection;
|
|
20
20
|
}
|
|
21
21
|
const matchesAction = permission.action === action;
|
|
22
22
|
return collection ? matchesCollection && matchesAction : matchesAction;
|
|
23
|
-
})
|
|
23
|
+
}) ?? [];
|
|
24
24
|
const fieldsPerCollection = {};
|
|
25
25
|
for (const result of results) {
|
|
26
26
|
const { collection, fields } = result;
|
|
27
27
|
if (!fieldsPerCollection[collection])
|
|
28
28
|
fieldsPerCollection[collection] = [];
|
|
29
|
-
fieldsPerCollection[collection].push(...(fields
|
|
29
|
+
fieldsPerCollection[collection].push(...(fields ?? []));
|
|
30
30
|
}
|
|
31
31
|
return fieldsPerCollection;
|
|
32
32
|
}
|
|
@@ -52,32 +52,32 @@ class PermissionsService extends items_1.ItemsService {
|
|
|
52
52
|
}
|
|
53
53
|
async createOne(data, opts) {
|
|
54
54
|
const res = await super.createOne(data, opts);
|
|
55
|
-
await (0, cache_1.clearSystemCache)();
|
|
55
|
+
await (0, cache_1.clearSystemCache)({ autoPurgeCache: opts?.autoPurgeCache });
|
|
56
56
|
return res;
|
|
57
57
|
}
|
|
58
58
|
async createMany(data, opts) {
|
|
59
59
|
const res = await super.createMany(data, opts);
|
|
60
|
-
await (0, cache_1.clearSystemCache)();
|
|
60
|
+
await (0, cache_1.clearSystemCache)({ autoPurgeCache: opts?.autoPurgeCache });
|
|
61
61
|
return res;
|
|
62
62
|
}
|
|
63
63
|
async updateBatch(data, opts) {
|
|
64
64
|
const res = await super.updateBatch(data, opts);
|
|
65
|
-
await (0, cache_1.clearSystemCache)();
|
|
65
|
+
await (0, cache_1.clearSystemCache)({ autoPurgeCache: opts?.autoPurgeCache });
|
|
66
66
|
return res;
|
|
67
67
|
}
|
|
68
68
|
async updateMany(keys, data, opts) {
|
|
69
69
|
const res = await super.updateMany(keys, data, opts);
|
|
70
|
-
await (0, cache_1.clearSystemCache)();
|
|
70
|
+
await (0, cache_1.clearSystemCache)({ autoPurgeCache: opts?.autoPurgeCache });
|
|
71
71
|
return res;
|
|
72
72
|
}
|
|
73
73
|
async upsertMany(payloads, opts) {
|
|
74
74
|
const res = await super.upsertMany(payloads, opts);
|
|
75
|
-
await (0, cache_1.clearSystemCache)();
|
|
75
|
+
await (0, cache_1.clearSystemCache)({ autoPurgeCache: opts?.autoPurgeCache });
|
|
76
76
|
return res;
|
|
77
77
|
}
|
|
78
78
|
async deleteMany(keys, opts) {
|
|
79
79
|
const res = await super.deleteMany(keys, opts);
|
|
80
|
-
await (0, cache_1.clearSystemCache)();
|
|
80
|
+
await (0, cache_1.clearSystemCache)({ autoPurgeCache: opts?.autoPurgeCache });
|
|
81
81
|
return res;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
2
|
-
import { SchemaOverview, Relation, RelationMeta, Accountability } from '@directus/shared/types';
|
|
3
|
-
import { ItemsService, QueryOptions } from './items';
|
|
4
|
-
import { PermissionsService } from './permissions';
|
|
5
1
|
import SchemaInspector from '@directus/schema';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
2
|
+
import type { Accountability, Relation, RelationMeta, SchemaOverview } from '@directus/shared/types';
|
|
3
|
+
import type Keyv from 'keyv';
|
|
4
|
+
import type { Knex } from 'knex';
|
|
8
5
|
import { Helpers } from '../database/helpers';
|
|
6
|
+
import type { AbstractServiceOptions, MutationOptions } from '../types';
|
|
7
|
+
import { ItemsService, QueryOptions } from './items';
|
|
8
|
+
import { PermissionsService } from './permissions';
|
|
9
9
|
export declare class RelationsService {
|
|
10
10
|
knex: Knex;
|
|
11
11
|
permissionsService: PermissionsService;
|