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
|
@@ -53,7 +53,6 @@ function mergePermissionsForShare(currentPermissions, accountability, schema) {
|
|
|
53
53
|
}
|
|
54
54
|
exports.mergePermissionsForShare = mergePermissionsForShare;
|
|
55
55
|
function traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, currentCollection, parentCollections = [], path = []) {
|
|
56
|
-
var _a, _b, _c;
|
|
57
56
|
const permissions = [];
|
|
58
57
|
// If there's already a permissions rule for the collection we're currently checking, we'll shortcircuit.
|
|
59
58
|
// This prevents infinite loop in recursive relationships, like articles->related_articles->articles, or
|
|
@@ -82,7 +81,7 @@ function traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, currentCo
|
|
|
82
81
|
});
|
|
83
82
|
permissions.push(...traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, relation.collection, [...parentCollections, currentCollection], [...path, relation.field]));
|
|
84
83
|
}
|
|
85
|
-
if (type === 'a2o' &&
|
|
84
|
+
if (type === 'a2o' && relation.meta?.one_allowed_collections) {
|
|
86
85
|
for (const collection of relation.meta.one_allowed_collections) {
|
|
87
86
|
permissions.push({
|
|
88
87
|
collection,
|
|
@@ -95,8 +94,8 @@ function traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, currentCo
|
|
|
95
94
|
collection: relation.related_collection,
|
|
96
95
|
permissions: getFilterForPath(type, [...path, `$FOLLOW(${relation.collection},${relation.field})`], rootItemPrimaryKeyField, rootItemPrimaryKey),
|
|
97
96
|
});
|
|
98
|
-
if (
|
|
99
|
-
permissions.push(...traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, relation.related_collection, [...parentCollections, currentCollection], [...path,
|
|
97
|
+
if (relation.meta?.one_field) {
|
|
98
|
+
permissions.push(...traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, relation.related_collection, [...parentCollections, currentCollection], [...path, relation.meta?.one_field]));
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
-
import { Permission } from '@directus/shared/types';
|
|
2
|
+
import type { Permission } from '@directus/shared/types';
|
|
3
3
|
export declare function mergePermissions(strategy: 'and' | 'or', ...permissions: Permission[][]): Permission[];
|
|
4
4
|
export declare function mergePermission(strategy: 'and' | 'or', currentPerm: Permission, newPerm: Permission): import("lodash").Omit<{
|
|
5
5
|
permissions: import("@directus/shared/types").Filter | null;
|
|
6
6
|
validation: import("@directus/shared/types").Filter | null;
|
|
7
7
|
fields: string[] | null;
|
|
8
8
|
presets: Record<string, any> | null;
|
|
9
|
-
id?: number
|
|
9
|
+
id?: number;
|
|
10
10
|
role: string | null;
|
|
11
11
|
collection: string;
|
|
12
12
|
action: import("@directus/shared/types").PermissionsAction;
|
|
13
|
-
system?: true
|
|
13
|
+
system?: true;
|
|
14
14
|
}, "id" | "system">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redactHeaderCookie(cookieHeader: string, cookieNames: string[]): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactHeaderCookie = void 0;
|
|
4
|
+
function redactHeaderCookie(cookieHeader, cookieNames) {
|
|
5
|
+
for (const cookieName of cookieNames) {
|
|
6
|
+
const re = new RegExp(`(${cookieName}=)([^;]+)`);
|
|
7
|
+
cookieHeader = cookieHeader.replace(re, `$1--redacted--`);
|
|
8
|
+
}
|
|
9
|
+
return cookieHeader;
|
|
10
|
+
}
|
|
11
|
+
exports.redactHeaderCookie = redactHeaderCookie;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Permission, PermissionsAction, SchemaOverview } from '@directus/shared/types';
|
|
1
|
+
import type { Permission, PermissionsAction, SchemaOverview } from '@directus/shared/types';
|
|
2
2
|
/**
|
|
3
3
|
* Reduces the schema based on the included permissions. The resulting object is the schema structure, but with only
|
|
4
4
|
* the allowed collections/fields/relations included based on the permissions.
|
|
@@ -10,12 +10,13 @@ const lodash_1 = require("lodash");
|
|
|
10
10
|
* @returns Reduced schema
|
|
11
11
|
*/
|
|
12
12
|
function reduceSchema(schema, permissions, actions = ['create', 'read', 'update', 'delete']) {
|
|
13
|
-
var _a, _b, _c;
|
|
14
13
|
const reduced = {
|
|
15
14
|
collections: {},
|
|
16
15
|
relations: [],
|
|
17
16
|
};
|
|
18
|
-
const allowedFieldsInCollection =
|
|
17
|
+
const allowedFieldsInCollection = permissions
|
|
18
|
+
?.filter((permission) => actions.includes(permission.action))
|
|
19
|
+
.reduce((acc, permission) => {
|
|
19
20
|
if (!acc[permission.collection]) {
|
|
20
21
|
acc[permission.collection] = [];
|
|
21
22
|
}
|
|
@@ -23,20 +24,20 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
23
24
|
acc[permission.collection] = (0, lodash_1.uniq)([...acc[permission.collection], ...permission.fields]);
|
|
24
25
|
}
|
|
25
26
|
return acc;
|
|
26
|
-
}, {})
|
|
27
|
+
}, {}) ?? {};
|
|
27
28
|
for (const [collectionName, collection] of Object.entries(schema.collections)) {
|
|
28
|
-
if (!
|
|
29
|
+
if (!permissions?.some((permission) => permission.collection === collectionName && actions.includes(permission.action))) {
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
31
32
|
const fields = {};
|
|
32
33
|
for (const [fieldName, field] of Object.entries(schema.collections[collectionName].fields)) {
|
|
33
|
-
if (!
|
|
34
|
-
!
|
|
34
|
+
if (!allowedFieldsInCollection[collectionName]?.includes('*') &&
|
|
35
|
+
!allowedFieldsInCollection[collectionName]?.includes(fieldName)) {
|
|
35
36
|
continue;
|
|
36
37
|
}
|
|
37
|
-
const o2mRelation = schema.relations.find((relation) =>
|
|
38
|
+
const o2mRelation = schema.relations.find((relation) => relation.related_collection === collectionName && relation.meta?.one_field === fieldName);
|
|
38
39
|
if (o2mRelation &&
|
|
39
|
-
!
|
|
40
|
+
!permissions?.some((permission) => permission.collection === o2mRelation.collection && actions.includes(permission.action))) {
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
43
|
fields[fieldName] = field;
|
|
@@ -47,7 +48,6 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
reduced.relations = schema.relations.filter((relation) => {
|
|
50
|
-
var _a, _b, _c;
|
|
51
51
|
let collectionsAllowed = true;
|
|
52
52
|
let fieldsAllowed = true;
|
|
53
53
|
if (Object.keys(allowedFieldsInCollection).includes(relation.collection) === false) {
|
|
@@ -59,7 +59,7 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
59
59
|
allowedFieldsInCollection[relation.related_collection].length === 0)) {
|
|
60
60
|
collectionsAllowed = false;
|
|
61
61
|
}
|
|
62
|
-
if (
|
|
62
|
+
if (relation.meta?.one_allowed_collections &&
|
|
63
63
|
relation.meta.one_allowed_collections.every((collection) => Object.keys(allowedFieldsInCollection).includes(collection)) === false) {
|
|
64
64
|
collectionsAllowed = false;
|
|
65
65
|
}
|
|
@@ -69,10 +69,10 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
69
69
|
fieldsAllowed = false;
|
|
70
70
|
}
|
|
71
71
|
if (relation.related_collection &&
|
|
72
|
-
|
|
72
|
+
relation.meta?.one_field &&
|
|
73
73
|
(!allowedFieldsInCollection[relation.related_collection] ||
|
|
74
74
|
(allowedFieldsInCollection[relation.related_collection].includes('*') === false &&
|
|
75
|
-
allowedFieldsInCollection[relation.related_collection].includes(
|
|
75
|
+
allowedFieldsInCollection[relation.related_collection].includes(relation.meta?.one_field) === false))) {
|
|
76
76
|
fieldsAllowed = false;
|
|
77
77
|
}
|
|
78
78
|
return collectionsAllowed && fieldsAllowed;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Accountability, Query } from '@directus/shared/types';
|
|
1
|
+
import type { Accountability, Query } from '@directus/shared/types';
|
|
2
2
|
export declare function sanitizeQuery(rawQuery: Record<string, any>, accountability?: Accountability | null): Query;
|
|
@@ -59,7 +59,7 @@ function sanitizeQuery(rawQuery, accountability) {
|
|
|
59
59
|
exports.sanitizeQuery = sanitizeQuery;
|
|
60
60
|
function sanitizeFields(rawFields) {
|
|
61
61
|
if (!rawFields)
|
|
62
|
-
return;
|
|
62
|
+
return null;
|
|
63
63
|
let fields = [];
|
|
64
64
|
if (typeof rawFields === 'string')
|
|
65
65
|
fields = rawFields.split(',');
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Field, Relation } from '@directus/shared/types';
|
|
2
|
+
import type { Collection } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Pick certain database vendor specific collection properties that should be compared when performing diff
|
|
5
|
+
*
|
|
6
|
+
* @param collection collection to sanitize
|
|
7
|
+
* @returns sanitized collection
|
|
8
|
+
*
|
|
9
|
+
* @see {@link https://github.com/knex/knex-schema-inspector/blob/master/lib/types/table.ts}
|
|
10
|
+
*/
|
|
11
|
+
export declare function sanitizeCollection(collection: Collection | undefined): Partial<Collection> | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Pick certain database vendor specific field properties that should be compared when performing diff
|
|
14
|
+
*
|
|
15
|
+
* @param field field to sanitize
|
|
16
|
+
* @param sanitizeAllSchema Whether or not the whole field schema should be sanitized. Mainly used to prevent modifying autoincrement fields
|
|
17
|
+
* @returns sanitized field
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://github.com/knex/knex-schema-inspector/blob/master/lib/types/column.ts}
|
|
20
|
+
*/
|
|
21
|
+
export declare function sanitizeField(field: Field | undefined, sanitizeAllSchema?: boolean): Partial<Field> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Pick certain database vendor specific relation properties that should be compared when performing diff
|
|
24
|
+
*
|
|
25
|
+
* @param relation relation to sanitize
|
|
26
|
+
* @returns sanitized relation
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://github.com/knex/knex-schema-inspector/blob/master/lib/types/foreign-key.ts}
|
|
29
|
+
*/
|
|
30
|
+
export declare function sanitizeRelation(relation: Relation | undefined): Partial<Relation> | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeRelation = exports.sanitizeField = exports.sanitizeCollection = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
/**
|
|
6
|
+
* Pick certain database vendor specific collection properties that should be compared when performing diff
|
|
7
|
+
*
|
|
8
|
+
* @param collection collection to sanitize
|
|
9
|
+
* @returns sanitized collection
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://github.com/knex/knex-schema-inspector/blob/master/lib/types/table.ts}
|
|
12
|
+
*/
|
|
13
|
+
function sanitizeCollection(collection) {
|
|
14
|
+
if (!collection)
|
|
15
|
+
return collection;
|
|
16
|
+
return (0, lodash_1.pick)(collection, ['collection', 'fields', 'meta', 'schema.name']);
|
|
17
|
+
}
|
|
18
|
+
exports.sanitizeCollection = sanitizeCollection;
|
|
19
|
+
/**
|
|
20
|
+
* Pick certain database vendor specific field properties that should be compared when performing diff
|
|
21
|
+
*
|
|
22
|
+
* @param field field to sanitize
|
|
23
|
+
* @param sanitizeAllSchema Whether or not the whole field schema should be sanitized. Mainly used to prevent modifying autoincrement fields
|
|
24
|
+
* @returns sanitized field
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://github.com/knex/knex-schema-inspector/blob/master/lib/types/column.ts}
|
|
27
|
+
*/
|
|
28
|
+
function sanitizeField(field, sanitizeAllSchema = false) {
|
|
29
|
+
if (!field)
|
|
30
|
+
return field;
|
|
31
|
+
const defaultPaths = ['collection', 'field', 'type', 'meta', 'name', 'children'];
|
|
32
|
+
const pickedPaths = sanitizeAllSchema
|
|
33
|
+
? defaultPaths
|
|
34
|
+
: [
|
|
35
|
+
...defaultPaths,
|
|
36
|
+
'schema.name',
|
|
37
|
+
'schema.table',
|
|
38
|
+
'schema.data_type',
|
|
39
|
+
'schema.default_value',
|
|
40
|
+
'schema.max_length',
|
|
41
|
+
'schema.numeric_precision',
|
|
42
|
+
'schema.numeric_scale',
|
|
43
|
+
'schema.is_nullable',
|
|
44
|
+
'schema.is_unique',
|
|
45
|
+
'schema.is_primary_key',
|
|
46
|
+
'schema.is_generated',
|
|
47
|
+
'schema.generation_expression',
|
|
48
|
+
'schema.has_auto_increment',
|
|
49
|
+
'schema.foreign_key_table',
|
|
50
|
+
'schema.foreign_key_column',
|
|
51
|
+
];
|
|
52
|
+
return (0, lodash_1.pick)(field, pickedPaths);
|
|
53
|
+
}
|
|
54
|
+
exports.sanitizeField = sanitizeField;
|
|
55
|
+
/**
|
|
56
|
+
* Pick certain database vendor specific relation properties that should be compared when performing diff
|
|
57
|
+
*
|
|
58
|
+
* @param relation relation to sanitize
|
|
59
|
+
* @returns sanitized relation
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://github.com/knex/knex-schema-inspector/blob/master/lib/types/foreign-key.ts}
|
|
62
|
+
*/
|
|
63
|
+
function sanitizeRelation(relation) {
|
|
64
|
+
if (!relation)
|
|
65
|
+
return relation;
|
|
66
|
+
return (0, lodash_1.pick)(relation, [
|
|
67
|
+
'collection',
|
|
68
|
+
'field',
|
|
69
|
+
'related_collection',
|
|
70
|
+
'meta',
|
|
71
|
+
'schema.table',
|
|
72
|
+
'schema.column',
|
|
73
|
+
'schema.foreign_key_table',
|
|
74
|
+
'schema.foreign_key_column',
|
|
75
|
+
'schema.constraint_name',
|
|
76
|
+
'schema.on_update',
|
|
77
|
+
'schema.on_delete',
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
exports.sanitizeRelation = sanitizeRelation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldSkipCache = void 0;
|
|
4
|
+
const env_1 = require("../env");
|
|
5
|
+
const url_1 = require("./url");
|
|
6
|
+
/**
|
|
7
|
+
* Whether to skip caching for the current request
|
|
8
|
+
*
|
|
9
|
+
* @param req Express request object
|
|
10
|
+
*/
|
|
11
|
+
function shouldSkipCache(req) {
|
|
12
|
+
const env = (0, env_1.getEnv)();
|
|
13
|
+
// Always skip cache for requests coming from the data studio based on Referer header
|
|
14
|
+
const adminUrl = new url_1.Url(env.PUBLIC_URL).addPath('admin').toString();
|
|
15
|
+
if (req.get('Referer')?.startsWith(adminUrl))
|
|
16
|
+
return true;
|
|
17
|
+
if (env.CACHE_SKIP_ALLOWED && req.get('cache-control')?.includes('no-store'))
|
|
18
|
+
return true;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
exports.shouldSkipCache = shouldSkipCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/track.js
CHANGED
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.track = void 0;
|
|
7
|
-
const ms_1 = __importDefault(require("ms"));
|
|
8
7
|
const node_machine_id_1 = require("node-machine-id");
|
|
9
8
|
const os_1 = __importDefault(require("os"));
|
|
10
9
|
// @ts-ignore
|
|
10
|
+
const utils_1 = require("@directus/shared/utils");
|
|
11
11
|
const package_json_1 = require("../../package.json");
|
|
12
12
|
const env_1 = __importDefault(require("../env"));
|
|
13
13
|
const logger_1 = __importDefault(require("../logger"));
|
|
14
|
-
const
|
|
14
|
+
const get_milliseconds_1 = require("./get-milliseconds");
|
|
15
15
|
async function track(event) {
|
|
16
16
|
const axios = (await import('axios')).default;
|
|
17
17
|
if (env_1.default.TELEMETRY !== false) {
|
|
@@ -48,7 +48,7 @@ async function getEnvInfo(event) {
|
|
|
48
48
|
},
|
|
49
49
|
cache: {
|
|
50
50
|
enabled: env_1.default.CACHE_ENABLED,
|
|
51
|
-
ttl: (0,
|
|
51
|
+
ttl: (0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_TTL),
|
|
52
52
|
store: env_1.default.CACHE_STORE,
|
|
53
53
|
},
|
|
54
54
|
storage: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { File, Transformation, TransformationParams, TransformationPreset } from '../types';
|
|
1
|
+
import type { File, Transformation, TransformationParams, TransformationPreset } from '../types';
|
|
2
2
|
export declare function resolvePreset(input: TransformationParams | TransformationPreset, file: File): Transformation[];
|
|
3
3
|
/**
|
|
4
4
|
* Try to extract a file format from an array of `Transformation`'s.
|
|
@@ -4,9 +4,8 @@ exports.maybeExtractFormat = exports.resolvePreset = void 0;
|
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
// Extract transforms from a preset
|
|
6
6
|
function resolvePreset(input, file) {
|
|
7
|
-
var _a;
|
|
8
7
|
// Do the format conversion last
|
|
9
|
-
return [extractResize(input), ...(
|
|
8
|
+
return [extractResize(input), ...(input.transforms ?? []), extractToFormat(input, file)].filter((transform) => transform !== undefined);
|
|
10
9
|
}
|
|
11
10
|
exports.resolvePreset = resolvePreset;
|
|
12
11
|
function extractOptions(keys, numberKeys = [], booleanKeys = []) {
|
|
@@ -49,9 +48,8 @@ function extractResize(input) {
|
|
|
49
48
|
* Try to extract a file format from an array of `Transformation`'s.
|
|
50
49
|
*/
|
|
51
50
|
function maybeExtractFormat(transforms) {
|
|
52
|
-
var _a;
|
|
53
51
|
const toFormats = transforms.filter((t) => t[0] === 'toFormat');
|
|
54
52
|
const lastToFormat = toFormats[toFormats.length - 1];
|
|
55
|
-
return lastToFormat ?
|
|
53
|
+
return lastToFormat ? lastToFormat[1]?.toString() : undefined;
|
|
56
54
|
}
|
|
57
55
|
exports.maybeExtractFormat = maybeExtractFormat;
|
package/dist/utils/url.js
CHANGED
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Url = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
class Url {
|
|
6
|
+
protocol;
|
|
7
|
+
host;
|
|
8
|
+
port;
|
|
9
|
+
path;
|
|
10
|
+
query;
|
|
11
|
+
hash;
|
|
6
12
|
constructor(url) {
|
|
7
13
|
const parsedUrl = new url_1.URL(url, 'http://localhost');
|
|
8
14
|
const isProtocolRelative = /^\/\//.test(url);
|
|
@@ -44,17 +50,12 @@ class Url {
|
|
|
44
50
|
return this;
|
|
45
51
|
}
|
|
46
52
|
toString({ rootRelative } = { rootRelative: false }) {
|
|
47
|
-
var _a;
|
|
48
53
|
const protocol = this.protocol !== null ? `${this.protocol}:` : '';
|
|
49
|
-
const host =
|
|
54
|
+
const host = this.host ?? '';
|
|
50
55
|
const port = this.port !== null ? `:${this.port}` : '';
|
|
51
56
|
const origin = `${this.host !== null ? `${protocol}//` : ''}${host}${port}`;
|
|
52
|
-
const path = `/${this.path.join('/')}
|
|
53
|
-
const query = Object.keys(this.query).length !== 0
|
|
54
|
-
? `?${Object.entries(this.query)
|
|
55
|
-
.map(([k, v]) => `${k}=${v}`)
|
|
56
|
-
.join('&')}`
|
|
57
|
-
: '';
|
|
57
|
+
const path = this.path.length ? `/${this.path.join('/')}` : '';
|
|
58
|
+
const query = Object.keys(this.query).length !== 0 ? `?${new URLSearchParams(this.query).toString()}` : '';
|
|
58
59
|
const hash = this.hash !== null ? `#${this.hash}` : '';
|
|
59
60
|
return `${!rootRelative ? origin : ''}${path}${query}${hash}`;
|
|
60
61
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { User } from '@directus/shared/types';
|
|
1
|
+
import type { User } from '@directus/shared/types';
|
|
2
2
|
export declare function userName(user: Partial<User>): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SnapshotDiffWithHash, SnapshotWithHash } from '../types/snapshot';
|
|
2
|
+
/**
|
|
3
|
+
* Validates the diff against the current schema snapshot.
|
|
4
|
+
*
|
|
5
|
+
* @returns True if the diff can be applied (valid & not empty).
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateApplyDiff(applyDiff: SnapshotDiffWithHash, currentSnapshotWithHash: SnapshotWithHash): boolean;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateApplyDiff = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const index_1 = require("../index");
|
|
9
|
+
const snapshot_1 = require("../types/snapshot");
|
|
10
|
+
const deepDiffSchema = joi_1.default.object({
|
|
11
|
+
kind: joi_1.default.string()
|
|
12
|
+
.valid(...Object.values(snapshot_1.DiffKind))
|
|
13
|
+
.required(),
|
|
14
|
+
path: joi_1.default.array().items(joi_1.default.string()),
|
|
15
|
+
lhs: joi_1.default.object().when('kind', { is: [snapshot_1.DiffKind.DELETE, snapshot_1.DiffKind.EDIT], then: joi_1.default.required() }),
|
|
16
|
+
rhs: joi_1.default.object().when('kind', { is: [snapshot_1.DiffKind.NEW, snapshot_1.DiffKind.EDIT], then: joi_1.default.required() }),
|
|
17
|
+
index: joi_1.default.number().when('kind', { is: snapshot_1.DiffKind.ARRAY, then: joi_1.default.required() }),
|
|
18
|
+
item: joi_1.default.link('/').when('kind', { is: snapshot_1.DiffKind.ARRAY, then: joi_1.default.required() }),
|
|
19
|
+
});
|
|
20
|
+
const applyJoiSchema = joi_1.default.object({
|
|
21
|
+
hash: joi_1.default.string().required(),
|
|
22
|
+
diff: joi_1.default.object({
|
|
23
|
+
collections: joi_1.default.array()
|
|
24
|
+
.items(joi_1.default.object({
|
|
25
|
+
collection: joi_1.default.string().required(),
|
|
26
|
+
diff: joi_1.default.array().items(deepDiffSchema).required(),
|
|
27
|
+
}))
|
|
28
|
+
.required(),
|
|
29
|
+
fields: joi_1.default.array()
|
|
30
|
+
.items(joi_1.default.object({
|
|
31
|
+
collection: joi_1.default.string().required(),
|
|
32
|
+
field: joi_1.default.string().required(),
|
|
33
|
+
diff: joi_1.default.array().items(deepDiffSchema).required(),
|
|
34
|
+
}))
|
|
35
|
+
.required(),
|
|
36
|
+
relations: joi_1.default.array()
|
|
37
|
+
.items(joi_1.default.object({
|
|
38
|
+
collection: joi_1.default.string().required(),
|
|
39
|
+
field: joi_1.default.string().required(),
|
|
40
|
+
related_collection: joi_1.default.string().allow(null),
|
|
41
|
+
diff: joi_1.default.array().items(deepDiffSchema).required(),
|
|
42
|
+
}))
|
|
43
|
+
.required(),
|
|
44
|
+
}).required(),
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Validates the diff against the current schema snapshot.
|
|
48
|
+
*
|
|
49
|
+
* @returns True if the diff can be applied (valid & not empty).
|
|
50
|
+
*/
|
|
51
|
+
function validateApplyDiff(applyDiff, currentSnapshotWithHash) {
|
|
52
|
+
const { error } = applyJoiSchema.validate(applyDiff);
|
|
53
|
+
if (error)
|
|
54
|
+
throw new index_1.InvalidPayloadException(error.message);
|
|
55
|
+
// No changes to apply
|
|
56
|
+
if (applyDiff.diff.collections.length === 0 &&
|
|
57
|
+
applyDiff.diff.fields.length === 0 &&
|
|
58
|
+
applyDiff.diff.relations.length === 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
// Diff can be applied due to matching hash
|
|
62
|
+
if (applyDiff.hash === currentSnapshotWithHash.hash)
|
|
63
|
+
return true;
|
|
64
|
+
for (const diffCollection of applyDiff.diff.collections) {
|
|
65
|
+
const collection = diffCollection.collection;
|
|
66
|
+
if (diffCollection.diff[0]?.kind === snapshot_1.DiffKind.NEW) {
|
|
67
|
+
const existingCollection = currentSnapshotWithHash.collections.find((c) => c.collection === diffCollection.collection);
|
|
68
|
+
if (existingCollection) {
|
|
69
|
+
throw new index_1.InvalidPayloadException(`Provided diff is trying to create collection "${collection}" but it already exists. Please generate a new diff and try again.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (diffCollection.diff[0]?.kind === snapshot_1.DiffKind.DELETE) {
|
|
73
|
+
const existingCollection = currentSnapshotWithHash.collections.find((c) => c.collection === diffCollection.collection);
|
|
74
|
+
if (!existingCollection) {
|
|
75
|
+
throw new index_1.InvalidPayloadException(`Provided diff is trying to delete collection "${collection}" but it does not exist. Please generate a new diff and try again.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const diffField of applyDiff.diff.fields) {
|
|
80
|
+
const field = `${diffField.collection}.${diffField.field}`;
|
|
81
|
+
if (diffField.diff[0]?.kind === snapshot_1.DiffKind.NEW) {
|
|
82
|
+
const existingField = currentSnapshotWithHash.fields.find((f) => f.collection === diffField.collection && f.field === diffField.field);
|
|
83
|
+
if (existingField) {
|
|
84
|
+
throw new index_1.InvalidPayloadException(`Provided diff is trying to create field "${field}" but it already exists. Please generate a new diff and try again.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (diffField.diff[0]?.kind === snapshot_1.DiffKind.DELETE) {
|
|
88
|
+
const existingField = currentSnapshotWithHash.fields.find((f) => f.collection === diffField.collection && f.field === diffField.field);
|
|
89
|
+
if (!existingField) {
|
|
90
|
+
throw new index_1.InvalidPayloadException(`Provided diff is trying to delete field "${field}" but it does not exist. Please generate a new diff and try again.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const diffRelation of applyDiff.diff.relations) {
|
|
95
|
+
let relation = `${diffRelation.collection}.${diffRelation.field}`;
|
|
96
|
+
if (diffRelation.related_collection)
|
|
97
|
+
relation += `-> ${diffRelation.related_collection}`;
|
|
98
|
+
if (diffRelation.diff[0]?.kind === snapshot_1.DiffKind.NEW) {
|
|
99
|
+
const existingRelation = currentSnapshotWithHash.relations.find((r) => r.collection === diffRelation.collection && r.field === diffRelation.field);
|
|
100
|
+
if (existingRelation) {
|
|
101
|
+
throw new index_1.InvalidPayloadException(`Provided diff is trying to create relation "${relation}" but it already exists. Please generate a new diff and try again.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (diffRelation.diff[0]?.kind === snapshot_1.DiffKind.DELETE) {
|
|
105
|
+
const existingRelation = currentSnapshotWithHash.relations.find((r) => r.collection === diffRelation.collection && r.field === diffRelation.field);
|
|
106
|
+
if (!existingRelation) {
|
|
107
|
+
throw new index_1.InvalidPayloadException(`Provided diff is trying to delete relation "${relation}" but it does not exist. Please generate a new diff and try again.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
throw new index_1.InvalidPayloadException(`Provided hash does not match the current instance's schema hash, indicating the schema has changed after this diff was generated. Please generate a new diff and try again.`);
|
|
112
|
+
}
|
|
113
|
+
exports.validateApplyDiff = validateApplyDiff;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateKeys = void 0;
|
|
7
|
-
const exceptions_1 = require("../exceptions");
|
|
8
7
|
const uuid_validate_1 = __importDefault(require("uuid-validate"));
|
|
8
|
+
const exceptions_1 = require("../exceptions");
|
|
9
9
|
/**
|
|
10
10
|
* Validate keys based on its type
|
|
11
11
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Query } from '@directus/shared/types';
|
|
1
|
+
import type { Query } from '@directus/shared/types';
|
|
2
2
|
export declare function validateQuery(query: Query): Query;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.validateQuery = void 0;
|
|
7
7
|
const joi_1 = __importDefault(require("joi"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
|
-
const exceptions_1 = require("../exceptions");
|
|
10
9
|
const wellknown_1 = require("wellknown");
|
|
11
|
-
const calculate_field_depth_1 = require("./calculate-field-depth");
|
|
12
10
|
const env_1 = __importDefault(require("../env"));
|
|
11
|
+
const exceptions_1 = require("../exceptions");
|
|
12
|
+
const calculate_field_depth_1 = require("./calculate-field-depth");
|
|
13
13
|
const querySchema = joi_1.default.object({
|
|
14
14
|
fields: joi_1.default.array().items(joi_1.default.string()),
|
|
15
15
|
group: joi_1.default.array().items(joi_1.default.string()),
|
|
@@ -20,7 +20,7 @@ const querySchema = joi_1.default.object({
|
|
|
20
20
|
page: joi_1.default.number().integer().min(0),
|
|
21
21
|
meta: joi_1.default.array().items(joi_1.default.string().valid('total_count', 'filter_count')),
|
|
22
22
|
search: joi_1.default.string(),
|
|
23
|
-
export: joi_1.default.string().valid('
|
|
23
|
+
export: joi_1.default.string().valid('csv', 'json', 'xml', 'yaml'),
|
|
24
24
|
aggregate: joi_1.default.object(),
|
|
25
25
|
deep: joi_1.default.object(),
|
|
26
26
|
alias: joi_1.default.object(),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|