directus 9.22.4 → 9.23.3
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 +19 -14
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +2 -2
- package/dist/auth/drivers/ldap.js +47 -36
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +13 -10
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +22 -15
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +23 -16
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +10 -7
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +4 -4
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +59 -16
- package/dist/cli/commands/bootstrap/index.js +2 -2
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +21 -20
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +2 -1
- package/dist/cli/utils/create-db-connection.js +2 -1
- package/dist/cli/utils/create-env/env-stub.liquid +1 -1
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/drivers.d.ts +3 -9
- package/dist/constants.d.ts +3 -9
- package/dist/constants.js +5 -10
- package/dist/controllers/activity.js +1 -2
- package/dist/controllers/assets.js +17 -12
- package/dist/controllers/auth.js +29 -15
- package/dist/controllers/dashboards.js +5 -2
- package/dist/controllers/extensions.js +7 -7
- package/dist/controllers/fields.js +4 -4
- package/dist/controllers/files.js +11 -6
- package/dist/controllers/flows.js +5 -2
- package/dist/controllers/folders.js +5 -2
- package/dist/controllers/graphql.js +6 -0
- package/dist/controllers/items.js +5 -2
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +5 -2
- package/dist/controllers/operations.js +5 -2
- package/dist/controllers/panels.js +5 -2
- package/dist/controllers/permissions.js +5 -2
- package/dist/controllers/presets.js +5 -2
- package/dist/controllers/roles.js +5 -2
- package/dist/controllers/schema.d.ts +2 -0
- package/dist/controllers/schema.js +98 -0
- package/dist/controllers/shares.js +8 -5
- package/dist/controllers/users.js +16 -20
- package/dist/controllers/utils.js +6 -11
- package/dist/controllers/webhooks.js +5 -2
- 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 -5
- package/dist/database/helpers/fn/types.js +5 -4
- 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 +2 -2
- 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 +5 -2
- package/dist/database/helpers/schema/dialects/oracle.js +23 -0
- package/dist/database/helpers/schema/types.d.ts +9 -7
- package/dist/database/helpers/schema/types.js +7 -1
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +2 -1
- package/dist/database/index.js +8 -8
- 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/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/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +19 -28
- 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/fields/collections.yaml +2 -0
- package/dist/database/system-data/fields/index.d.ts +1 -1
- package/dist/database/system-data/fields/index.js +1 -2
- 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 +19 -4
- 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 +34 -24
- package/dist/flows.js +56 -30
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +19 -3
- package/dist/messenger.js +8 -6
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +12 -5
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +7 -7
- 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 +2 -2
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +9 -10
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +3 -3
- 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} +3 -3
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +18 -14
- package/dist/middleware/sanitize-query.d.ts +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 +14 -3
- 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 +21 -20
- package/dist/operations/trigger/index.d.ts +2 -0
- package/dist/operations/trigger/index.js +27 -11
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +8 -8
- package/dist/request/index.d.ts +5 -0
- package/dist/request/index.js +18 -0
- package/dist/request/index.test.d.ts +1 -0
- package/dist/request/request-interceptor.d.ts +2 -0
- package/dist/request/request-interceptor.js +33 -0
- package/dist/request/request-interceptor.test.d.ts +1 -0
- package/dist/request/response-interceptor.d.ts +2 -0
- package/dist/request/response-interceptor.js +9 -0
- package/dist/request/response-interceptor.test.d.ts +1 -0
- package/dist/request/validate-ip.d.ts +1 -0
- package/dist/request/validate-ip.js +27 -0
- package/dist/request/validate-ip.test.d.ts +1 -0
- package/dist/server.js +8 -9
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +7 -6
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +33 -26
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +18 -15
- 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 +52 -48
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +49 -48
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +70 -108
- 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 +181 -170
- 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 +29 -9
- package/dist/services/import-export.d.ts +7 -5
- package/dist/services/import-export.js +41 -24
- package/dist/services/import-export.test.d.ts +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +67 -42
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +9 -5
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +10 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +7 -6
- 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 +47 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +34 -13
- package/dist/services/schema.d.ts +15 -0
- package/dist/services/schema.js +56 -0
- package/dist/services/schema.test.d.ts +1 -0
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +69 -13
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +2 -2
- package/dist/services/shares.js +14 -15
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +132 -116
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +3 -3
- package/dist/services/users.js +89 -62
- 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/types/assets.d.ts +2 -2
- 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/database.d.ts +3 -0
- package/dist/types/database.js +4 -0
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/items.d.ts +7 -2
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +25 -3
- package/dist/types/snapshot.js +14 -0
- package/dist/utils/apply-diff.d.ts +9 -0
- package/dist/utils/apply-diff.js +256 -0
- package/dist/utils/apply-diff.test.d.ts +1 -0
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +15 -16
- package/dist/utils/apply-snapshot.d.ts +3 -5
- package/dist/utils/apply-snapshot.js +9 -240
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/filter-items.d.ts +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-cache-headers.d.ts +4 -2
- package/dist/utils/get-cache-headers.js +21 -21
- package/dist/utils/get-cache-headers.test.d.ts +1 -0
- 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-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 +1 -2
- 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-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.d.ts +4 -0
- package/dist/utils/get-milliseconds.js +14 -0
- package/dist/utils/get-milliseconds.test.d.ts +1 -0
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +1 -1
- 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 +19 -21
- package/dist/utils/get-snapshot-diff.js +10 -7
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +35 -14
- package/dist/utils/get-versioned-hash.d.ts +1 -0
- package/dist/utils/get-versioned-hash.js +12 -0
- package/dist/utils/get-versioned-hash.test.d.ts +1 -0
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/map-values-deep.d.ts +1 -0
- package/dist/utils/map-values-deep.js +29 -0
- package/dist/utils/map-values-deep.test.d.ts +1 -0
- 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/redact-header-cookies.d.ts +1 -0
- package/dist/utils/redact-header-cookies.js +11 -0
- package/dist/utils/redact-header-cookies.test.d.ts +1 -0
- 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 +1 -1
- package/dist/utils/sanitize-schema.d.ts +30 -0
- package/dist/utils/sanitize-schema.js +80 -0
- package/dist/utils/sanitize-schema.test.d.ts +1 -0
- 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 +3 -3
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +9 -8
- package/dist/utils/url.test.d.ts +1 -0
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.d.ts +7 -0
- package/dist/utils/validate-diff.js +113 -0
- package/dist/utils/validate-diff.test.d.ts +1 -0
- 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-query.test.d.ts +1 -0
- package/dist/utils/validate-snapshot.d.ts +5 -0
- package/dist/utils/validate-snapshot.js +71 -0
- package/dist/utils/validate-snapshot.test.d.ts +1 -0
- package/dist/webhooks.js +4 -3
- package/package.json +62 -62
package/dist/services/items.js
CHANGED
|
@@ -20,6 +20,12 @@ const authorization_1 = require("./authorization");
|
|
|
20
20
|
const index_1 = require("./index");
|
|
21
21
|
const payload_1 = require("./payload");
|
|
22
22
|
class ItemsService {
|
|
23
|
+
collection;
|
|
24
|
+
knex;
|
|
25
|
+
accountability;
|
|
26
|
+
eventScope;
|
|
27
|
+
schema;
|
|
28
|
+
cache;
|
|
23
29
|
constructor(collection, options) {
|
|
24
30
|
this.collection = collection;
|
|
25
31
|
this.knex = options.knex || (0, database_1.default)();
|
|
@@ -72,7 +78,7 @@ class ItemsService {
|
|
|
72
78
|
});
|
|
73
79
|
// Run all hooks that are attached to this event so the end user has the chance to augment the
|
|
74
80
|
// item that is about to be saved
|
|
75
|
-
const payloadAfterHooks =
|
|
81
|
+
const payloadAfterHooks = opts?.emitEvents !== false
|
|
76
82
|
? await emitter_1.default.emitFilter(this.eventScope === 'items'
|
|
77
83
|
? ['items.create', `${this.collection}.items.create`]
|
|
78
84
|
: `${this.eventScope}.create`, payload, {
|
|
@@ -86,6 +92,9 @@ class ItemsService {
|
|
|
86
92
|
const payloadWithPresets = this.accountability
|
|
87
93
|
? await authorizationService.validatePayload('create', this.collection, payloadAfterHooks)
|
|
88
94
|
: payloadAfterHooks;
|
|
95
|
+
if (opts?.preMutationException) {
|
|
96
|
+
throw opts.preMutationException;
|
|
97
|
+
}
|
|
89
98
|
const { payload: payloadWithM2O, revisions: revisionsM2O, nestedActionEvents: nestedActionEventsM2O, } = await payloadService.processM2O(payloadWithPresets, opts);
|
|
90
99
|
const { payload: payloadWithA2O, revisions: revisionsA2O, nestedActionEvents: nestedActionEventsA2O, } = await payloadService.processA2O(payloadWithM2O, opts);
|
|
91
100
|
const payloadWithoutAliases = (0, lodash_1.pick)(payloadWithA2O, (0, lodash_1.without)(fields, ...aliases));
|
|
@@ -100,10 +109,10 @@ class ItemsService {
|
|
|
100
109
|
.then((result) => result[0]);
|
|
101
110
|
const returnedKey = typeof result === 'object' ? result[primaryKeyField] : result;
|
|
102
111
|
if (this.schema.collections[this.collection].fields[primaryKeyField].type === 'uuid') {
|
|
103
|
-
primaryKey = (0, helpers_1.getHelpers)(trx).schema.formatUUID(primaryKey
|
|
112
|
+
primaryKey = (0, helpers_1.getHelpers)(trx).schema.formatUUID(primaryKey ?? returnedKey);
|
|
104
113
|
}
|
|
105
114
|
else {
|
|
106
|
-
primaryKey = primaryKey
|
|
115
|
+
primaryKey = primaryKey ?? returnedKey;
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
118
|
catch (err) {
|
|
@@ -145,26 +154,27 @@ class ItemsService {
|
|
|
145
154
|
knex: trx,
|
|
146
155
|
schema: this.schema,
|
|
147
156
|
});
|
|
157
|
+
const revisionDelta = await payloadService.prepareDelta(payloadAfterHooks);
|
|
148
158
|
const revision = await revisionsService.createOne({
|
|
149
159
|
activity: activity,
|
|
150
160
|
collection: this.collection,
|
|
151
161
|
item: primaryKey,
|
|
152
|
-
data:
|
|
153
|
-
delta:
|
|
162
|
+
data: revisionDelta,
|
|
163
|
+
delta: revisionDelta,
|
|
154
164
|
});
|
|
155
165
|
// Make sure to set the parent field of the child-revision rows
|
|
156
166
|
const childrenRevisions = [...revisionsM2O, ...revisionsA2O, ...revisionsO2M];
|
|
157
167
|
if (childrenRevisions.length > 0) {
|
|
158
168
|
await revisionsService.updateMany(childrenRevisions, { parent: revision });
|
|
159
169
|
}
|
|
160
|
-
if (opts
|
|
170
|
+
if (opts?.onRevisionCreate) {
|
|
161
171
|
opts.onRevisionCreate(revision);
|
|
162
172
|
}
|
|
163
173
|
}
|
|
164
174
|
}
|
|
165
175
|
return primaryKey;
|
|
166
176
|
});
|
|
167
|
-
if (
|
|
177
|
+
if (opts?.emitEvents !== false) {
|
|
168
178
|
const actionEvent = {
|
|
169
179
|
event: this.eventScope === 'items'
|
|
170
180
|
? ['items.create', `${this.collection}.items.create`]
|
|
@@ -180,17 +190,22 @@ class ItemsService {
|
|
|
180
190
|
accountability: this.accountability,
|
|
181
191
|
},
|
|
182
192
|
};
|
|
183
|
-
if (
|
|
184
|
-
|
|
193
|
+
if (opts?.bypassEmitAction) {
|
|
194
|
+
opts.bypassEmitAction(actionEvent);
|
|
185
195
|
}
|
|
186
196
|
else {
|
|
187
|
-
|
|
197
|
+
emitter_1.default.emitAction(actionEvent.event, actionEvent.meta, actionEvent.context);
|
|
188
198
|
}
|
|
189
199
|
for (const nestedActionEvent of nestedActionEvents) {
|
|
190
|
-
|
|
200
|
+
if (opts?.bypassEmitAction) {
|
|
201
|
+
opts.bypassEmitAction(nestedActionEvent);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
emitter_1.default.emitAction(nestedActionEvent.event, nestedActionEvent.meta, nestedActionEvent.context);
|
|
205
|
+
}
|
|
191
206
|
}
|
|
192
207
|
}
|
|
193
|
-
if (this.cache && env_1.default.CACHE_AUTO_PURGE &&
|
|
208
|
+
if (this.cache && env_1.default.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
|
|
194
209
|
await this.cache.clear();
|
|
195
210
|
}
|
|
196
211
|
return primaryKey;
|
|
@@ -211,23 +226,23 @@ class ItemsService {
|
|
|
211
226
|
const primaryKey = await service.createOne(payload, {
|
|
212
227
|
...(opts || {}),
|
|
213
228
|
autoPurgeCache: false,
|
|
214
|
-
bypassEmitAction: (params) =>
|
|
229
|
+
bypassEmitAction: (params) => nestedActionEvents.push(params),
|
|
215
230
|
});
|
|
216
231
|
primaryKeys.push(primaryKey);
|
|
217
232
|
}
|
|
218
233
|
return { primaryKeys, nestedActionEvents };
|
|
219
234
|
});
|
|
220
|
-
if (
|
|
235
|
+
if (opts?.emitEvents !== false) {
|
|
221
236
|
for (const nestedActionEvent of nestedActionEvents) {
|
|
222
|
-
if (
|
|
223
|
-
|
|
237
|
+
if (opts?.bypassEmitAction) {
|
|
238
|
+
opts.bypassEmitAction(nestedActionEvent);
|
|
224
239
|
}
|
|
225
240
|
else {
|
|
226
|
-
|
|
241
|
+
emitter_1.default.emitAction(nestedActionEvent.event, nestedActionEvent.meta, nestedActionEvent.context);
|
|
227
242
|
}
|
|
228
243
|
}
|
|
229
244
|
}
|
|
230
|
-
if (this.cache && env_1.default.CACHE_AUTO_PURGE &&
|
|
245
|
+
if (this.cache && env_1.default.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
|
|
231
246
|
await this.cache.clear();
|
|
232
247
|
}
|
|
233
248
|
return primaryKeys;
|
|
@@ -236,7 +251,7 @@ class ItemsService {
|
|
|
236
251
|
* Get items by query
|
|
237
252
|
*/
|
|
238
253
|
async readByQuery(query, opts) {
|
|
239
|
-
const updatedQuery =
|
|
254
|
+
const updatedQuery = opts?.emitEvents !== false
|
|
240
255
|
? await emitter_1.default.emitFilter(this.eventScope === 'items'
|
|
241
256
|
? ['items.query', `${this.collection}.items.query`]
|
|
242
257
|
: `${this.eventScope}.query`, query, {
|
|
@@ -252,7 +267,7 @@ class ItemsService {
|
|
|
252
267
|
// By setting the permissions action, you can read items using the permissions for another
|
|
253
268
|
// operation's permissions. This is used to dynamically check if you have update/delete
|
|
254
269
|
// access to (a) certain item(s)
|
|
255
|
-
action:
|
|
270
|
+
action: opts?.permissionsAction || 'read',
|
|
256
271
|
knex: this.knex,
|
|
257
272
|
});
|
|
258
273
|
if (this.accountability && this.accountability.admin !== true) {
|
|
@@ -261,17 +276,17 @@ class ItemsService {
|
|
|
261
276
|
knex: this.knex,
|
|
262
277
|
schema: this.schema,
|
|
263
278
|
});
|
|
264
|
-
ast = await authorizationService.processAST(ast, opts
|
|
279
|
+
ast = await authorizationService.processAST(ast, opts?.permissionsAction);
|
|
265
280
|
}
|
|
266
281
|
const records = await (0, run_ast_1.default)(ast, this.schema, {
|
|
267
282
|
knex: this.knex,
|
|
268
283
|
// GraphQL requires relational keys to be returned regardless
|
|
269
|
-
stripNonRequested:
|
|
284
|
+
stripNonRequested: opts?.stripNonRequested !== undefined ? opts.stripNonRequested : true,
|
|
270
285
|
});
|
|
271
286
|
if (records === null) {
|
|
272
287
|
throw new exceptions_1.ForbiddenException();
|
|
273
288
|
}
|
|
274
|
-
const filteredRecords =
|
|
289
|
+
const filteredRecords = opts?.emitEvents !== false
|
|
275
290
|
? await emitter_1.default.emitFilter(this.eventScope === 'items' ? ['items.read', `${this.collection}.items.read`] : `${this.eventScope}.read`, records, {
|
|
276
291
|
query: updatedQuery,
|
|
277
292
|
collection: this.collection,
|
|
@@ -281,7 +296,7 @@ class ItemsService {
|
|
|
281
296
|
accountability: this.accountability,
|
|
282
297
|
})
|
|
283
298
|
: records;
|
|
284
|
-
if (
|
|
299
|
+
if (opts?.emitEvents !== false) {
|
|
285
300
|
emitter_1.default.emitAction(this.eventScope === 'items' ? ['items.read', `${this.collection}.items.read`] : `${this.eventScope}.read`, {
|
|
286
301
|
payload: filteredRecords,
|
|
287
302
|
query: updatedQuery,
|
|
@@ -312,10 +327,9 @@ class ItemsService {
|
|
|
312
327
|
* Get multiple items by primary keys
|
|
313
328
|
*/
|
|
314
329
|
async readMany(keys, query = {}, opts) {
|
|
315
|
-
var _a;
|
|
316
330
|
const primaryKeyField = this.schema.collections[this.collection].primary;
|
|
317
331
|
(0, validate_keys_1.validateKeys)(this.schema, this.collection, primaryKeyField, keys);
|
|
318
|
-
const filterWithKey = { _and: [{ [primaryKeyField]: { _in: keys } },
|
|
332
|
+
const filterWithKey = { _and: [{ [primaryKeyField]: { _in: keys } }, query.filter ?? {}] };
|
|
319
333
|
const queryWithKey = (0, lodash_1.assign)({}, query, { filter: filterWithKey });
|
|
320
334
|
// Set query limit as the number of keys
|
|
321
335
|
if (Array.isArray(keys) && keys.length > 0 && !queryWithKey.limit) {
|
|
@@ -367,7 +381,7 @@ class ItemsService {
|
|
|
367
381
|
});
|
|
368
382
|
}
|
|
369
383
|
finally {
|
|
370
|
-
if (this.cache && env_1.default.CACHE_AUTO_PURGE &&
|
|
384
|
+
if (this.cache && env_1.default.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
|
|
371
385
|
await this.cache.clear();
|
|
372
386
|
}
|
|
373
387
|
}
|
|
@@ -392,7 +406,7 @@ class ItemsService {
|
|
|
392
406
|
});
|
|
393
407
|
// Run all hooks that are attached to this event so the end user has the chance to augment the
|
|
394
408
|
// item that is about to be saved
|
|
395
|
-
const payloadAfterHooks =
|
|
409
|
+
const payloadAfterHooks = opts?.emitEvents !== false
|
|
396
410
|
? await emitter_1.default.emitFilter(this.eventScope === 'items'
|
|
397
411
|
? ['items.update', `${this.collection}.items.update`]
|
|
398
412
|
: `${this.eventScope}.update`, payload, {
|
|
@@ -412,6 +426,9 @@ class ItemsService {
|
|
|
412
426
|
const payloadWithPresets = this.accountability
|
|
413
427
|
? await authorizationService.validatePayload('update', this.collection, payloadAfterHooks)
|
|
414
428
|
: payloadAfterHooks;
|
|
429
|
+
if (opts?.preMutationException) {
|
|
430
|
+
throw opts.preMutationException;
|
|
431
|
+
}
|
|
415
432
|
await this.knex.transaction(async (trx) => {
|
|
416
433
|
const payloadService = new payload_1.PayloadService(this.collection, {
|
|
417
434
|
accountability: this.accountability,
|
|
@@ -473,7 +490,7 @@ class ItemsService {
|
|
|
473
490
|
const revisionIDs = await revisionsService.createMany(revisions);
|
|
474
491
|
for (let i = 0; i < revisionIDs.length; i++) {
|
|
475
492
|
const revisionID = revisionIDs[i];
|
|
476
|
-
if (opts
|
|
493
|
+
if (opts?.onRevisionCreate) {
|
|
477
494
|
opts.onRevisionCreate(revisionID);
|
|
478
495
|
}
|
|
479
496
|
if (i === 0) {
|
|
@@ -489,10 +506,10 @@ class ItemsService {
|
|
|
489
506
|
}
|
|
490
507
|
}
|
|
491
508
|
});
|
|
492
|
-
if (this.cache && env_1.default.CACHE_AUTO_PURGE &&
|
|
509
|
+
if (this.cache && env_1.default.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
|
|
493
510
|
await this.cache.clear();
|
|
494
511
|
}
|
|
495
|
-
if (
|
|
512
|
+
if (opts?.emitEvents !== false) {
|
|
496
513
|
const actionEvent = {
|
|
497
514
|
event: this.eventScope === 'items'
|
|
498
515
|
? ['items.update', `${this.collection}.items.update`]
|
|
@@ -508,14 +525,19 @@ class ItemsService {
|
|
|
508
525
|
accountability: this.accountability,
|
|
509
526
|
},
|
|
510
527
|
};
|
|
511
|
-
if (
|
|
512
|
-
|
|
528
|
+
if (opts?.bypassEmitAction) {
|
|
529
|
+
opts.bypassEmitAction(actionEvent);
|
|
513
530
|
}
|
|
514
531
|
else {
|
|
515
|
-
|
|
532
|
+
emitter_1.default.emitAction(actionEvent.event, actionEvent.meta, actionEvent.context);
|
|
516
533
|
}
|
|
517
534
|
for (const nestedActionEvent of nestedActionEvents) {
|
|
518
|
-
|
|
535
|
+
if (opts?.bypassEmitAction) {
|
|
536
|
+
opts.bypassEmitAction(nestedActionEvent);
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
emitter_1.default.emitAction(nestedActionEvent.event, nestedActionEvent.meta, nestedActionEvent.context);
|
|
540
|
+
}
|
|
519
541
|
}
|
|
520
542
|
}
|
|
521
543
|
return keys;
|
|
@@ -559,7 +581,7 @@ class ItemsService {
|
|
|
559
581
|
}
|
|
560
582
|
return primaryKeys;
|
|
561
583
|
});
|
|
562
|
-
if (this.cache && env_1.default.CACHE_AUTO_PURGE &&
|
|
584
|
+
if (this.cache && env_1.default.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
|
|
563
585
|
await this.cache.clear();
|
|
564
586
|
}
|
|
565
587
|
return primaryKeys;
|
|
@@ -596,7 +618,10 @@ class ItemsService {
|
|
|
596
618
|
});
|
|
597
619
|
await authorizationService.checkAccess('delete', this.collection, keys);
|
|
598
620
|
}
|
|
599
|
-
if (
|
|
621
|
+
if (opts?.preMutationException) {
|
|
622
|
+
throw opts.preMutationException;
|
|
623
|
+
}
|
|
624
|
+
if (opts?.emitEvents !== false) {
|
|
600
625
|
await emitter_1.default.emitFilter(this.eventScope === 'items' ? ['items.delete', `${this.collection}.items.delete`] : `${this.eventScope}.delete`, keys, {
|
|
601
626
|
collection: this.collection,
|
|
602
627
|
}, {
|
|
@@ -623,10 +648,10 @@ class ItemsService {
|
|
|
623
648
|
})));
|
|
624
649
|
}
|
|
625
650
|
});
|
|
626
|
-
if (this.cache && env_1.default.CACHE_AUTO_PURGE &&
|
|
651
|
+
if (this.cache && env_1.default.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
|
|
627
652
|
await this.cache.clear();
|
|
628
653
|
}
|
|
629
|
-
if (
|
|
654
|
+
if (opts?.emitEvents !== false) {
|
|
630
655
|
const actionEvent = {
|
|
631
656
|
event: this.eventScope === 'items'
|
|
632
657
|
? ['items.delete', `${this.collection}.items.delete`]
|
|
@@ -642,11 +667,11 @@ class ItemsService {
|
|
|
642
667
|
accountability: this.accountability,
|
|
643
668
|
},
|
|
644
669
|
};
|
|
645
|
-
if (
|
|
646
|
-
|
|
670
|
+
if (opts?.bypassEmitAction) {
|
|
671
|
+
opts.bypassEmitAction(actionEvent);
|
|
647
672
|
}
|
|
648
673
|
else {
|
|
649
|
-
|
|
674
|
+
emitter_1.default.emitAction(actionEvent.event, actionEvent.meta, actionEvent.context);
|
|
650
675
|
}
|
|
651
676
|
}
|
|
652
677
|
return keys;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { SendMailOptions, Transporter } from 'nodemailer';
|
|
4
|
+
import type { AbstractServiceOptions } from '../../types';
|
|
5
5
|
export type EmailOptions = SendMailOptions & {
|
|
6
6
|
template?: {
|
|
7
7
|
name: string;
|
|
@@ -18,10 +18,14 @@ const liquidEngine = new liquidjs_1.Liquid({
|
|
|
18
18
|
extname: '.liquid',
|
|
19
19
|
});
|
|
20
20
|
class MailService {
|
|
21
|
+
schema;
|
|
22
|
+
accountability;
|
|
23
|
+
knex;
|
|
24
|
+
mailer;
|
|
21
25
|
constructor(opts) {
|
|
22
26
|
this.schema = opts.schema;
|
|
23
27
|
this.accountability = opts.accountability || null;
|
|
24
|
-
this.knex =
|
|
28
|
+
this.knex = opts?.knex || (0, database_1.default)();
|
|
25
29
|
this.mailer = (0, mailer_1.default)();
|
|
26
30
|
if (env_1.default.EMAIL_VERIFY_SETUP) {
|
|
27
31
|
this.mailer.verify((error) => {
|
|
@@ -72,10 +76,10 @@ class MailService {
|
|
|
72
76
|
.from('directus_settings')
|
|
73
77
|
.first();
|
|
74
78
|
return {
|
|
75
|
-
projectName:
|
|
76
|
-
projectColor:
|
|
77
|
-
projectLogo: getProjectLogoURL(projectInfo
|
|
78
|
-
projectUrl:
|
|
79
|
+
projectName: projectInfo?.project_name || 'Directus',
|
|
80
|
+
projectColor: projectInfo?.project_color || '#546e7a',
|
|
81
|
+
projectLogo: getProjectLogoURL(projectInfo?.project_logo),
|
|
82
|
+
projectUrl: projectInfo?.project_url || '',
|
|
79
83
|
};
|
|
80
84
|
function getProjectLogoURL(logoID) {
|
|
81
85
|
const projectLogoUrl = new url_1.Url(env_1.default.PUBLIC_URL);
|
package/dist/services/meta.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Accountability, Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { AbstractServiceOptions } from '../types';
|
|
4
4
|
export declare class MetaService {
|
|
5
5
|
knex: Knex;
|
|
6
6
|
accountability: Accountability | null;
|
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;
|
|
@@ -31,31 +34,29 @@ class MetaService {
|
|
|
31
34
|
}, {});
|
|
32
35
|
}
|
|
33
36
|
async totalCount(collection) {
|
|
34
|
-
var _a, _b, _c, _d, _e;
|
|
35
37
|
const dbQuery = this.knex(collection).count('*', { as: 'count' }).first();
|
|
36
|
-
if (
|
|
37
|
-
const permissionsRecord =
|
|
38
|
+
if (this.accountability?.admin !== true) {
|
|
39
|
+
const permissionsRecord = this.accountability?.permissions?.find((permission) => {
|
|
38
40
|
return permission.action === 'read' && permission.collection === collection;
|
|
39
41
|
});
|
|
40
42
|
if (!permissionsRecord)
|
|
41
43
|
throw new exceptions_1.ForbiddenException();
|
|
42
|
-
const permissions =
|
|
44
|
+
const permissions = permissionsRecord.permissions ?? {};
|
|
43
45
|
(0, apply_query_1.applyFilter)(this.knex, this.schema, dbQuery, permissions, collection, {});
|
|
44
46
|
}
|
|
45
47
|
const result = await dbQuery;
|
|
46
|
-
return Number(
|
|
48
|
+
return Number(result?.count ?? 0);
|
|
47
49
|
}
|
|
48
50
|
async filterCount(collection, query) {
|
|
49
|
-
var _a, _b, _c, _d;
|
|
50
51
|
const dbQuery = this.knex(collection).count('*', { as: 'count' });
|
|
51
52
|
let filter = query.filter || {};
|
|
52
|
-
if (
|
|
53
|
-
const permissionsRecord =
|
|
53
|
+
if (this.accountability?.admin !== true) {
|
|
54
|
+
const permissionsRecord = this.accountability?.permissions?.find((permission) => {
|
|
54
55
|
return permission.action === 'read' && permission.collection === collection;
|
|
55
56
|
});
|
|
56
57
|
if (!permissionsRecord)
|
|
57
58
|
throw new exceptions_1.ForbiddenException();
|
|
58
|
-
const permissions =
|
|
59
|
+
const permissions = permissionsRecord.permissions ?? {};
|
|
59
60
|
if (Object.keys(filter).length > 0) {
|
|
60
61
|
filter = { _and: [permissions, filter] };
|
|
61
62
|
}
|
|
@@ -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,7 +32,6 @@ 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'],
|
|
@@ -42,7 +43,7 @@ class NotificationsService extends items_1.ItemsService {
|
|
|
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
48
|
to: user.email,
|
|
48
49
|
subject: data.subject,
|
|
@@ -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: {
|