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/users.js
CHANGED
|
@@ -4,23 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.UsersService = void 0;
|
|
7
|
+
const exceptions_1 = require("@directus/shared/exceptions");
|
|
8
|
+
const utils_1 = require("@directus/shared/utils");
|
|
7
9
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
10
|
const lodash_1 = require("lodash");
|
|
11
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
9
12
|
const database_1 = __importDefault(require("../database"));
|
|
10
13
|
const env_1 = __importDefault(require("../env"));
|
|
11
|
-
const exceptions_1 = require("@directus/shared/exceptions");
|
|
12
14
|
const exceptions_2 = require("../exceptions");
|
|
13
15
|
const record_not_unique_1 = require("../exceptions/database/record-not-unique");
|
|
14
16
|
const is_url_allowed_1 = __importDefault(require("../utils/is-url-allowed"));
|
|
15
|
-
const
|
|
17
|
+
const stall_1 = require("../utils/stall");
|
|
16
18
|
const url_1 = require("../utils/url");
|
|
17
19
|
const items_1 = require("./items");
|
|
18
20
|
const mail_1 = require("./mail");
|
|
19
21
|
const settings_1 = require("./settings");
|
|
20
|
-
const stall_1 = require("../utils/stall");
|
|
21
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
22
|
-
const utils_2 = require("@directus/shared/utils");
|
|
23
22
|
class UsersService extends items_1.ItemsService {
|
|
23
|
+
knex;
|
|
24
|
+
accountability;
|
|
25
|
+
schema;
|
|
24
26
|
constructor(options) {
|
|
25
27
|
super('directus_users', options);
|
|
26
28
|
this.knex = options.knex || (0, database_1.default)();
|
|
@@ -96,7 +98,7 @@ class UsersService extends items_1.ItemsService {
|
|
|
96
98
|
.andWhere({ 'directus_roles.admin_access': true })
|
|
97
99
|
.leftJoin('directus_roles', 'directus_users.role', 'directus_roles.id')
|
|
98
100
|
.first();
|
|
99
|
-
const otherAdminUsersCount = +(
|
|
101
|
+
const otherAdminUsersCount = +(otherAdminUsers?.count || 0);
|
|
100
102
|
if (otherAdminUsersCount === 0) {
|
|
101
103
|
throw new exceptions_2.UnprocessableEntityException(`You can't remove the last admin user from the role.`);
|
|
102
104
|
}
|
|
@@ -113,7 +115,7 @@ class UsersService extends items_1.ItemsService {
|
|
|
113
115
|
.andWhere({ 'directus_users.status': 'active' })
|
|
114
116
|
.leftJoin('directus_roles', 'directus_users.role', 'directus_roles.id')
|
|
115
117
|
.first();
|
|
116
|
-
const otherAdminUsersCount = +(
|
|
118
|
+
const otherAdminUsersCount = +(otherAdminUsers?.count || 0);
|
|
117
119
|
if (otherAdminUsersCount === 0) {
|
|
118
120
|
throw new exceptions_2.UnprocessableEntityException(`You can't change the active status of the last admin user.`);
|
|
119
121
|
}
|
|
@@ -131,11 +133,16 @@ class UsersService extends items_1.ItemsService {
|
|
|
131
133
|
async createMany(data, opts) {
|
|
132
134
|
const emails = data.map((payload) => payload.email).filter((email) => email);
|
|
133
135
|
const passwords = data.map((payload) => payload.password).filter((password) => password);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
try {
|
|
137
|
+
if (emails.length) {
|
|
138
|
+
await this.checkUniqueEmails(emails);
|
|
139
|
+
}
|
|
140
|
+
if (passwords.length) {
|
|
141
|
+
await this.checkPasswordPolicy(passwords);
|
|
142
|
+
}
|
|
136
143
|
}
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
catch (err) {
|
|
145
|
+
(opts || (opts = {})).preMutationException = err;
|
|
139
146
|
}
|
|
140
147
|
return await super.createMany(data, opts);
|
|
141
148
|
}
|
|
@@ -174,45 +181,49 @@ class UsersService extends items_1.ItemsService {
|
|
|
174
181
|
* Update many users by primary key
|
|
175
182
|
*/
|
|
176
183
|
async updateMany(keys, data, opts) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
try {
|
|
185
|
+
if (data.role) {
|
|
186
|
+
// data.role will be an object with id with GraphQL mutations
|
|
187
|
+
const roleId = data.role?.id ?? data.role;
|
|
188
|
+
const newRole = await this.knex.select('admin_access').from('directus_roles').where('id', roleId).first();
|
|
189
|
+
if (!newRole?.admin_access) {
|
|
190
|
+
await this.checkRemainingAdminExistence(keys);
|
|
191
|
+
}
|
|
184
192
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
await this.checkRemainingActiveAdmin(keys);
|
|
188
|
-
}
|
|
189
|
-
if (data.email) {
|
|
190
|
-
if (keys.length > 1) {
|
|
191
|
-
throw new record_not_unique_1.RecordNotUniqueException('email', {
|
|
192
|
-
collection: 'directus_users',
|
|
193
|
-
field: 'email',
|
|
194
|
-
invalid: data.email,
|
|
195
|
-
});
|
|
193
|
+
if (data.status !== undefined && data.status !== 'active') {
|
|
194
|
+
await this.checkRemainingActiveAdmin(keys);
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (this.accountability && this.accountability.admin !== true) {
|
|
207
|
-
throw new exceptions_2.InvalidPayloadException(`You can't change the "provider" value manually.`);
|
|
196
|
+
if (data.email) {
|
|
197
|
+
if (keys.length > 1) {
|
|
198
|
+
throw new record_not_unique_1.RecordNotUniqueException('email', {
|
|
199
|
+
collection: 'directus_users',
|
|
200
|
+
field: 'email',
|
|
201
|
+
invalid: data.email,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
await this.checkUniqueEmails([data.email], keys[0]);
|
|
208
205
|
}
|
|
209
|
-
data.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
throw new exceptions_2.InvalidPayloadException(`You can't change the "
|
|
206
|
+
if (data.password) {
|
|
207
|
+
await this.checkPasswordPolicy([data.password]);
|
|
208
|
+
}
|
|
209
|
+
if (data.tfa_secret !== undefined) {
|
|
210
|
+
throw new exceptions_2.InvalidPayloadException(`You can't change the "tfa_secret" value manually.`);
|
|
211
|
+
}
|
|
212
|
+
if (data.provider !== undefined) {
|
|
213
|
+
if (this.accountability && this.accountability.admin !== true) {
|
|
214
|
+
throw new exceptions_2.InvalidPayloadException(`You can't change the "provider" value manually.`);
|
|
215
|
+
}
|
|
216
|
+
data.auth_data = null;
|
|
217
|
+
}
|
|
218
|
+
if (data.external_identifier !== undefined) {
|
|
219
|
+
if (this.accountability && this.accountability.admin !== true) {
|
|
220
|
+
throw new exceptions_2.InvalidPayloadException(`You can't change the "external_identifier" value manually.`);
|
|
221
|
+
}
|
|
222
|
+
data.auth_data = null;
|
|
214
223
|
}
|
|
215
|
-
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
(opts || (opts = {})).preMutationException = err;
|
|
216
227
|
}
|
|
217
228
|
return await super.updateMany(keys, data, opts);
|
|
218
229
|
}
|
|
@@ -227,7 +238,12 @@ class UsersService extends items_1.ItemsService {
|
|
|
227
238
|
* Delete multiple users by primary key
|
|
228
239
|
*/
|
|
229
240
|
async deleteMany(keys, opts) {
|
|
230
|
-
|
|
241
|
+
try {
|
|
242
|
+
await this.checkRemainingAdminExistence(keys);
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
(opts || (opts = {})).preMutationException = err;
|
|
246
|
+
}
|
|
231
247
|
await this.knex('directus_notifications').update({ sender: null }).whereIn('sender', keys);
|
|
232
248
|
await super.deleteMany(keys, opts);
|
|
233
249
|
return keys;
|
|
@@ -248,8 +264,14 @@ class UsersService extends items_1.ItemsService {
|
|
|
248
264
|
return await this.deleteMany(keys, opts);
|
|
249
265
|
}
|
|
250
266
|
async inviteUser(email, role, url, subject) {
|
|
251
|
-
|
|
252
|
-
|
|
267
|
+
const opts = {};
|
|
268
|
+
try {
|
|
269
|
+
if (url && (0, is_url_allowed_1.default)(url, env_1.default.USER_INVITE_URL_ALLOW_LIST) === false) {
|
|
270
|
+
throw new exceptions_2.InvalidPayloadException(`Url "${url}" can't be used to invite users.`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
opts.preMutationException = err;
|
|
253
275
|
}
|
|
254
276
|
const emails = (0, utils_1.toArray)(email);
|
|
255
277
|
const mailService = new mail_1.MailService({
|
|
@@ -259,11 +281,11 @@ class UsersService extends items_1.ItemsService {
|
|
|
259
281
|
for (const email of emails) {
|
|
260
282
|
const payload = { email, scope: 'invite' };
|
|
261
283
|
const token = jsonwebtoken_1.default.sign(payload, env_1.default.SECRET, { expiresIn: '7d', issuer: 'directus' });
|
|
262
|
-
const subjectLine = subject
|
|
284
|
+
const subjectLine = subject ?? "You've been invited";
|
|
263
285
|
const inviteURL = url ? new url_1.Url(url) : new url_1.Url(env_1.default.PUBLIC_URL).addPath('admin', 'accept-invite');
|
|
264
286
|
inviteURL.setQuery('token', token);
|
|
265
287
|
// Create user first to verify uniqueness
|
|
266
|
-
await this.createOne({ email, role, status: 'invited' });
|
|
288
|
+
await this.createOne({ email, role, status: 'invited' }, opts);
|
|
267
289
|
await mailService.send({
|
|
268
290
|
to: email,
|
|
269
291
|
subject: subjectLine,
|
|
@@ -282,7 +304,7 @@ class UsersService extends items_1.ItemsService {
|
|
|
282
304
|
if (scope !== 'invite')
|
|
283
305
|
throw new exceptions_2.ForbiddenException();
|
|
284
306
|
const user = await this.knex.select('id', 'status').from('directus_users').where({ email }).first();
|
|
285
|
-
if (
|
|
307
|
+
if (user?.status !== 'invited') {
|
|
286
308
|
throw new exceptions_2.InvalidPayloadException(`Email address ${email} hasn't been invited.`);
|
|
287
309
|
}
|
|
288
310
|
// Allow unauthenticated update
|
|
@@ -293,9 +315,6 @@ class UsersService extends items_1.ItemsService {
|
|
|
293
315
|
await service.updateOne(user.id, { password, status: 'active' });
|
|
294
316
|
}
|
|
295
317
|
async requestPasswordReset(email, url, subject) {
|
|
296
|
-
if (url && (0, is_url_allowed_1.default)(url, env_1.default.PASSWORD_RESET_URL_ALLOW_LIST) === false) {
|
|
297
|
-
throw new exceptions_2.InvalidPayloadException(`Url "${url}" can't be used to reset passwords.`);
|
|
298
|
-
}
|
|
299
318
|
const STALL_TIME = 500;
|
|
300
319
|
const timeStart = perf_hooks_1.performance.now();
|
|
301
320
|
const user = await this.knex
|
|
@@ -303,16 +322,19 @@ class UsersService extends items_1.ItemsService {
|
|
|
303
322
|
.from('directus_users')
|
|
304
323
|
.whereRaw('LOWER(??) = ?', ['email', email.toLowerCase()])
|
|
305
324
|
.first();
|
|
306
|
-
if (
|
|
325
|
+
if (user?.status !== 'active') {
|
|
307
326
|
await (0, stall_1.stall)(STALL_TIME, timeStart);
|
|
308
327
|
throw new exceptions_2.ForbiddenException();
|
|
309
328
|
}
|
|
329
|
+
if (url && (0, is_url_allowed_1.default)(url, env_1.default.PASSWORD_RESET_URL_ALLOW_LIST) === false) {
|
|
330
|
+
throw new exceptions_2.InvalidPayloadException(`Url "${url}" can't be used to reset passwords.`);
|
|
331
|
+
}
|
|
310
332
|
const mailService = new mail_1.MailService({
|
|
311
333
|
schema: this.schema,
|
|
312
334
|
knex: this.knex,
|
|
313
335
|
accountability: this.accountability,
|
|
314
336
|
});
|
|
315
|
-
const payload = { email, scope: 'password-reset', hash: (0,
|
|
337
|
+
const payload = { email, scope: 'password-reset', hash: (0, utils_1.getSimpleHash)('' + user.password) };
|
|
316
338
|
const token = jsonwebtoken_1.default.sign(payload, env_1.default.SECRET, { expiresIn: '1d', issuer: 'directus' });
|
|
317
339
|
const acceptURL = url
|
|
318
340
|
? new url_1.Url(url).setQuery('token', token).toString()
|
|
@@ -332,13 +354,18 @@ class UsersService extends items_1.ItemsService {
|
|
|
332
354
|
await (0, stall_1.stall)(STALL_TIME, timeStart);
|
|
333
355
|
}
|
|
334
356
|
async resetPassword(token, password) {
|
|
335
|
-
var _a;
|
|
336
357
|
const { email, scope, hash } = jsonwebtoken_1.default.verify(token, env_1.default.SECRET, { issuer: 'directus' });
|
|
337
358
|
if (scope !== 'password-reset' || !hash)
|
|
338
359
|
throw new exceptions_2.ForbiddenException();
|
|
339
|
-
|
|
360
|
+
const opts = {};
|
|
361
|
+
try {
|
|
362
|
+
await this.checkPasswordPolicy([password]);
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
opts.preMutationException = err;
|
|
366
|
+
}
|
|
340
367
|
const user = await this.knex.select('id', 'status', 'password').from('directus_users').where({ email }).first();
|
|
341
|
-
if (
|
|
368
|
+
if (user?.status !== 'active' || hash !== (0, utils_1.getSimpleHash)('' + user.password)) {
|
|
342
369
|
throw new exceptions_2.ForbiddenException();
|
|
343
370
|
}
|
|
344
371
|
// Allow unauthenticated update
|
|
@@ -346,11 +373,11 @@ class UsersService extends items_1.ItemsService {
|
|
|
346
373
|
knex: this.knex,
|
|
347
374
|
schema: this.schema,
|
|
348
375
|
accountability: {
|
|
349
|
-
...(
|
|
376
|
+
...(this.accountability ?? { role: null }),
|
|
350
377
|
admin: true, // We need to skip permissions checks for the update call below
|
|
351
378
|
},
|
|
352
379
|
});
|
|
353
|
-
await service.updateOne(user.id, { password, status: 'active' });
|
|
380
|
+
await service.updateOne(user.id, { password, status: 'active' }, opts);
|
|
354
381
|
}
|
|
355
382
|
}
|
|
356
383
|
exports.UsersService = UsersService;
|
package/dist/services/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { AbstractServiceOptions, PrimaryKey } from '../types';
|
|
4
4
|
export declare class UtilsService {
|
|
5
5
|
knex: Knex;
|
|
6
6
|
accountability: Accountability | null;
|
package/dist/services/utils.js
CHANGED
|
@@ -6,30 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UtilsService = void 0;
|
|
7
7
|
const database_1 = __importDefault(require("../database"));
|
|
8
8
|
const collections_1 = require("../database/system-data/collections");
|
|
9
|
-
const exceptions_1 = require("../exceptions");
|
|
10
9
|
const emitter_1 = __importDefault(require("../emitter"));
|
|
10
|
+
const exceptions_1 = require("../exceptions");
|
|
11
11
|
class UtilsService {
|
|
12
|
+
knex;
|
|
13
|
+
accountability;
|
|
14
|
+
schema;
|
|
12
15
|
constructor(options) {
|
|
13
16
|
this.knex = options.knex || (0, database_1.default)();
|
|
14
17
|
this.accountability = options.accountability || null;
|
|
15
18
|
this.schema = options.schema;
|
|
16
19
|
}
|
|
17
20
|
async sort(collection, { item, to }) {
|
|
18
|
-
var _a, _b, _c, _d;
|
|
19
21
|
const sortFieldResponse = (await this.knex.select('sort_field').from('directus_collections').where({ collection }).first()) ||
|
|
20
22
|
collections_1.systemCollectionRows;
|
|
21
|
-
const sortField = sortFieldResponse
|
|
23
|
+
const sortField = sortFieldResponse?.sort_field;
|
|
22
24
|
if (!sortField) {
|
|
23
25
|
throw new exceptions_1.InvalidPayloadException(`Collection "${collection}" doesn't have a sort field.`);
|
|
24
26
|
}
|
|
25
|
-
if (
|
|
26
|
-
const permissions =
|
|
27
|
+
if (this.accountability?.admin !== true) {
|
|
28
|
+
const permissions = this.accountability?.permissions?.find((permission) => {
|
|
27
29
|
return permission.collection === collection && permission.action === 'update';
|
|
28
30
|
});
|
|
29
31
|
if (!permissions) {
|
|
30
32
|
throw new exceptions_1.ForbiddenException();
|
|
31
33
|
}
|
|
32
|
-
const allowedFields =
|
|
34
|
+
const allowedFields = permissions.fields ?? [];
|
|
33
35
|
if (allowedFields[0] !== '*' && allowedFields.includes(sortField) === false) {
|
|
34
36
|
throw new exceptions_1.ForbiddenException();
|
|
35
37
|
}
|
|
@@ -37,7 +39,7 @@ class UtilsService {
|
|
|
37
39
|
const primaryKeyField = this.schema.collections[collection].primary;
|
|
38
40
|
// Make sure all rows have a sort value
|
|
39
41
|
const countResponse = await this.knex.count('* as count').from(collection).whereNull(sortField).first();
|
|
40
|
-
if (
|
|
42
|
+
if (countResponse?.count && +countResponse.count !== 0) {
|
|
41
43
|
const lastSortValueResponse = await this.knex.max(sortField).from(collection).first();
|
|
42
44
|
const rowsWithoutSortValue = await this.knex
|
|
43
45
|
.select(primaryKeyField, sortField)
|
|
@@ -59,7 +61,7 @@ class UtilsService {
|
|
|
59
61
|
.groupBy(sortField)
|
|
60
62
|
.from(collection)
|
|
61
63
|
.havingRaw('count(??) > 1', [sortField]);
|
|
62
|
-
if (
|
|
64
|
+
if (duplicates?.length > 0) {
|
|
63
65
|
const ids = await this.knex.select(primaryKeyField).from(collection).orderBy(sortField);
|
|
64
66
|
// This might not scale that well, but I don't really know how to accurately set all rows
|
|
65
67
|
// to a sequential value that works cross-DB vendor otherwise
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractServiceOptions, Item, PrimaryKey, Webhook, MutationOptions } from '../types';
|
|
2
|
-
import { ItemsService } from './items';
|
|
3
1
|
import { Messenger } from '../messenger';
|
|
2
|
+
import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey, Webhook } from '../types';
|
|
3
|
+
import { ItemsService } from './items';
|
|
4
4
|
export declare class WebhooksService extends ItemsService<Webhook> {
|
|
5
5
|
messenger: Messenger;
|
|
6
6
|
constructor(options: AbstractServiceOptions);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebhooksService = void 0;
|
|
4
|
-
const items_1 = require("./items");
|
|
5
4
|
const messenger_1 = require("../messenger");
|
|
5
|
+
const items_1 = require("./items");
|
|
6
6
|
class WebhooksService extends items_1.ItemsService {
|
|
7
|
+
messenger;
|
|
7
8
|
constructor(options) {
|
|
8
9
|
super('directus_webhooks', options);
|
|
9
10
|
this.messenger = (0, messenger_1.getMessenger)();
|
package/dist/types/assets.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ResizeOptions, Sharp } from 'sharp';
|
|
1
|
+
import type { ResizeOptions, Sharp } from 'sharp';
|
|
2
2
|
export declare const TransformationMethods: readonly ["toFormat", "jpeg", "png", "tiff", "webp", "resize", "extend", "extract", "trim", "rotate", "flip", "flop", "sharpen", "median", "blur", "flatten", "gamma", "negate", "normalise", "normalize", "clahe", "convolve", "threshold", "linear", "recomb", "modulate", "tint", "greyscale", "grayscale", "toColorspace", "toColourspace", "removeAlpha", "ensureAlpha", "extractChannel", "bandbool"];
|
|
3
|
-
type AllowedSharpMethods = Pick<Sharp, typeof TransformationMethods[number]>;
|
|
3
|
+
type AllowedSharpMethods = Pick<Sharp, (typeof TransformationMethods)[number]>;
|
|
4
4
|
export type TransformationMap = {
|
|
5
5
|
[M in keyof AllowedSharpMethods]: readonly [M, ...Parameters<AllowedSharpMethods[M]>];
|
|
6
6
|
};
|
package/dist/types/ast.d.ts
CHANGED
package/dist/types/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Field } from '@directus/shared/types';
|
|
2
|
+
import type { Table } from 'knex-schema-inspector/dist/types/table';
|
|
3
3
|
export type CollectionMeta = {
|
|
4
4
|
collection: string;
|
|
5
5
|
note: string | null;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type Driver = 'mysql' | 'pg' | 'cockroachdb' | 'sqlite3' | 'oracledb' | 'mssql';
|
|
2
|
+
export declare const DatabaseClients: readonly ["mysql", "postgres", "cockroachdb", "sqlite", "oracle", "mssql", "redshift"];
|
|
3
|
+
export type DatabaseClient = (typeof DatabaseClients)[number];
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ActionHandler, FilterHandler, InitHandler } from '@directus/shared/types';
|
|
2
|
-
import { ScheduledTask } from 'node-cron';
|
|
1
|
+
import type { ActionHandler, FilterHandler, InitHandler } from '@directus/shared/types';
|
|
2
|
+
import type { ScheduledTask } from 'node-cron';
|
|
3
3
|
export type EventHandler = {
|
|
4
4
|
type: 'filter';
|
|
5
5
|
name: string;
|
package/dist/types/graphql.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./assets"), exports);
|
|
|
18
18
|
__exportStar(require("./ast"), exports);
|
|
19
19
|
__exportStar(require("./auth"), exports);
|
|
20
20
|
__exportStar(require("./collection"), exports);
|
|
21
|
+
__exportStar(require("./database"), exports);
|
|
21
22
|
__exportStar(require("./events"), exports);
|
|
22
23
|
__exportStar(require("./files"), exports);
|
|
23
24
|
__exportStar(require("./graphql"), exports);
|
package/dist/types/items.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* I know this looks a little silly, but it allows us to explicitly differentiate between when we're
|
|
3
3
|
* expecting an item vs any other generic object.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { BaseException } from '@directus/shared/exceptions';
|
|
6
|
+
import type { EventContext } from '@directus/shared/types';
|
|
6
7
|
export type Item = Record<string, any>;
|
|
7
8
|
export type PrimaryKey = string | number;
|
|
8
9
|
export type Alterations = {
|
|
@@ -30,12 +31,16 @@ export type MutationOptions = {
|
|
|
30
31
|
/**
|
|
31
32
|
* Allow disabling the emitting of hooks. Useful if a custom hook is fired (like files.upload)
|
|
32
33
|
*/
|
|
33
|
-
emitEvents?: boolean;
|
|
34
|
+
emitEvents?: boolean | undefined;
|
|
34
35
|
/**
|
|
35
36
|
* To bypass the emitting of action events if emitEvents is enabled
|
|
36
37
|
* Can be used to queue up the nested events from item service's create, update and delete
|
|
37
38
|
*/
|
|
38
39
|
bypassEmitAction?: (params: ActionEventParams) => void;
|
|
40
|
+
/**
|
|
41
|
+
* The validation error to throw right before the mutation takes place
|
|
42
|
+
*/
|
|
43
|
+
preMutationException?: BaseException;
|
|
39
44
|
};
|
|
40
45
|
export type ActionEventParams = {
|
|
41
46
|
event: string | string[];
|
package/dist/types/services.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Item, PrimaryKey } from './items';
|
|
1
|
+
import type { Accountability, Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { Item, PrimaryKey } from './items';
|
|
4
4
|
export type AbstractServiceOptions = {
|
|
5
5
|
knex?: Knex;
|
|
6
|
-
accountability?: Accountability | null;
|
|
6
|
+
accountability?: Accountability | null | undefined;
|
|
7
7
|
schema: SchemaOverview;
|
|
8
8
|
};
|
|
9
9
|
export interface AbstractService {
|
|
10
10
|
knex: Knex;
|
|
11
|
-
accountability: Accountability | null;
|
|
11
|
+
accountability: Accountability | null | undefined;
|
|
12
12
|
createOne(data: Partial<Item>): Promise<PrimaryKey>;
|
|
13
13
|
createMany(data: Partial<Item>[]): Promise<PrimaryKey[]>;
|
|
14
14
|
readOne(key: PrimaryKey, query?: Query): Promise<Item>;
|
package/dist/types/snapshot.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Field, FieldMeta, Relation, RelationMeta } from '@directus/shared/types';
|
|
2
|
+
import type { Diff } from 'deep-diff';
|
|
3
|
+
import type { Collection } from './collection';
|
|
4
|
+
import type { DatabaseClient } from './database';
|
|
4
5
|
export type Snapshot = {
|
|
5
6
|
version: number;
|
|
6
7
|
directus: string;
|
|
8
|
+
vendor?: DatabaseClient;
|
|
7
9
|
collections: Collection[];
|
|
8
10
|
fields: SnapshotField[];
|
|
9
11
|
relations: SnapshotRelation[];
|
|
@@ -14,6 +16,9 @@ export type SnapshotField = Field & {
|
|
|
14
16
|
export type SnapshotRelation = Relation & {
|
|
15
17
|
meta: Omit<RelationMeta, 'id'>;
|
|
16
18
|
};
|
|
19
|
+
export type SnapshotWithHash = Snapshot & {
|
|
20
|
+
hash: string;
|
|
21
|
+
};
|
|
17
22
|
export type SnapshotDiff = {
|
|
18
23
|
collections: {
|
|
19
24
|
collection: string;
|
|
@@ -31,3 +36,20 @@ export type SnapshotDiff = {
|
|
|
31
36
|
diff: Diff<SnapshotRelation | undefined>[];
|
|
32
37
|
}[];
|
|
33
38
|
};
|
|
39
|
+
export type SnapshotDiffWithHash = {
|
|
40
|
+
hash: string;
|
|
41
|
+
diff: SnapshotDiff;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Indicates the kind of change based on comparisons by deep-diff package
|
|
45
|
+
*/
|
|
46
|
+
export declare const DiffKind: {
|
|
47
|
+
/** indicates a newly added property/element */
|
|
48
|
+
readonly NEW: "N";
|
|
49
|
+
/** indicates a property/element was deleted */
|
|
50
|
+
readonly DELETE: "D";
|
|
51
|
+
/** indicates a property/element was edited */
|
|
52
|
+
readonly EDIT: "E";
|
|
53
|
+
/** indicates a change occurred within an array */
|
|
54
|
+
readonly ARRAY: "A";
|
|
55
|
+
};
|
package/dist/types/snapshot.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiffKind = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Indicates the kind of change based on comparisons by deep-diff package
|
|
6
|
+
*/
|
|
7
|
+
exports.DiffKind = {
|
|
8
|
+
/** indicates a newly added property/element */
|
|
9
|
+
NEW: 'N',
|
|
10
|
+
/** indicates a property/element was deleted */
|
|
11
|
+
DELETE: 'D',
|
|
12
|
+
/** indicates a property/element was edited */
|
|
13
|
+
EDIT: 'E',
|
|
14
|
+
/** indicates a change occurred within an array */
|
|
15
|
+
ARRAY: 'A',
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import { Diff } from 'deep-diff';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
4
|
+
import { Snapshot, SnapshotDiff, SnapshotField } from '../types';
|
|
5
|
+
export declare function applyDiff(currentSnapshot: Snapshot, snapshotDiff: SnapshotDiff, options?: {
|
|
6
|
+
database?: Knex;
|
|
7
|
+
schema?: SchemaOverview;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function isNestedMetaUpdate(diff: Diff<SnapshotField | undefined>): boolean;
|