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
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addPathToValidationError = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
function addPathToValidationError(validationError) {
|
|
6
|
-
|
|
7
|
-
const token = (_c = (_b = (_a = validationError.nodes) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.loc) === null || _c === void 0 ? void 0 : _c.startToken;
|
|
6
|
+
const token = validationError.nodes?.[0]?.loc?.startToken;
|
|
8
7
|
if (!token)
|
|
9
8
|
return validationError;
|
|
10
9
|
let prev = token;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Accountability } from '@directus/shared/types';
|
|
2
|
+
import type { GraphQLError, GraphQLFormattedError } from 'graphql';
|
|
3
3
|
declare const processError: (accountability: Accountability | null, error: Readonly<GraphQLError>) => GraphQLFormattedError;
|
|
4
4
|
export default processError;
|
|
@@ -3,24 +3,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const exceptions_1 = require("@directus/shared/exceptions");
|
|
6
7
|
const logger_1 = __importDefault(require("../../../logger"));
|
|
7
8
|
const processError = (accountability, error) => {
|
|
8
9
|
logger_1.default.error(error);
|
|
9
|
-
|
|
10
|
+
const { originalError } = error;
|
|
11
|
+
if (originalError instanceof exceptions_1.BaseException) {
|
|
10
12
|
return {
|
|
11
|
-
|
|
13
|
+
message: originalError.message,
|
|
12
14
|
extensions: {
|
|
13
|
-
code:
|
|
15
|
+
code: originalError.code,
|
|
16
|
+
...originalError.extensions,
|
|
14
17
|
},
|
|
15
18
|
};
|
|
16
19
|
}
|
|
17
20
|
else {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (accountability?.admin === true) {
|
|
22
|
+
const graphqlFormattedError = {
|
|
23
|
+
message: error.message,
|
|
24
|
+
extensions: {
|
|
25
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
if (error.locations) {
|
|
29
|
+
graphqlFormattedError.locations = error.locations;
|
|
30
|
+
}
|
|
31
|
+
if (error.path) {
|
|
32
|
+
graphqlFormattedError.path = error.path;
|
|
33
|
+
}
|
|
34
|
+
return graphqlFormattedError;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return {
|
|
38
|
+
message: 'An unexpected error occurred.',
|
|
39
|
+
extensions: {
|
|
40
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
24
44
|
}
|
|
25
45
|
};
|
|
26
46
|
exports.default = processError;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Accountability, Query, SchemaOverview } from '@directus/shared/types';
|
|
3
|
-
import { Knex } from 'knex';
|
|
4
|
-
import { AbstractServiceOptions, File } from '../types';
|
|
2
|
+
import type { Accountability, Query, SchemaOverview } from '@directus/shared/types';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
5
4
|
import type { Readable } from 'node:stream';
|
|
5
|
+
import type { AbstractServiceOptions, File } from '../types';
|
|
6
|
+
type ExportFormat = 'csv' | 'json' | 'xml' | 'yaml';
|
|
6
7
|
export declare class ImportService {
|
|
7
8
|
knex: Knex;
|
|
8
9
|
accountability: Accountability | null;
|
|
@@ -22,14 +23,15 @@ export declare class ExportService {
|
|
|
22
23
|
* until all the data is retrieved. Uploads the result as a new file using the regular
|
|
23
24
|
* FilesService upload method.
|
|
24
25
|
*/
|
|
25
|
-
exportToFile(collection: string, query: Partial<Query>, format:
|
|
26
|
+
exportToFile(collection: string, query: Partial<Query>, format: ExportFormat, options?: {
|
|
26
27
|
file?: Partial<File>;
|
|
27
28
|
}): Promise<void>;
|
|
28
29
|
/**
|
|
29
30
|
* Transform a given input object / array to the given type
|
|
30
31
|
*/
|
|
31
|
-
transform(input: Record<string, any>[], format:
|
|
32
|
+
transform(input: Record<string, any>[], format: ExportFormat, options?: {
|
|
32
33
|
includeHeader?: boolean;
|
|
33
34
|
includeFooter?: boolean;
|
|
34
35
|
}): string;
|
|
35
36
|
}
|
|
37
|
+
export {};
|
|
@@ -9,6 +9,7 @@ const async_1 = require("async");
|
|
|
9
9
|
const csv_parser_1 = __importDefault(require("csv-parser"));
|
|
10
10
|
const destroy_1 = __importDefault(require("destroy"));
|
|
11
11
|
const fs_extra_1 = require("fs-extra");
|
|
12
|
+
const js_yaml_1 = require("js-yaml");
|
|
12
13
|
const js2xmlparser_1 = require("js2xmlparser");
|
|
13
14
|
const json2csv_1 = require("json2csv");
|
|
14
15
|
const lodash_1 = require("lodash");
|
|
@@ -16,6 +17,7 @@ const StreamArray_1 = __importDefault(require("stream-json/streamers/StreamArray
|
|
|
16
17
|
const strip_bom_stream_1 = __importDefault(require("strip-bom-stream"));
|
|
17
18
|
const tmp_promise_1 = require("tmp-promise");
|
|
18
19
|
const database_1 = __importDefault(require("../database"));
|
|
20
|
+
const emitter_1 = __importDefault(require("../emitter"));
|
|
19
21
|
const env_1 = __importDefault(require("../env"));
|
|
20
22
|
const exceptions_1 = require("../exceptions");
|
|
21
23
|
const logger_1 = __importDefault(require("../logger"));
|
|
@@ -24,18 +26,20 @@ const files_1 = require("./files");
|
|
|
24
26
|
const items_1 = require("./items");
|
|
25
27
|
const notifications_1 = require("./notifications");
|
|
26
28
|
class ImportService {
|
|
29
|
+
knex;
|
|
30
|
+
accountability;
|
|
31
|
+
schema;
|
|
27
32
|
constructor(options) {
|
|
28
33
|
this.knex = options.knex || (0, database_1.default)();
|
|
29
34
|
this.accountability = options.accountability || null;
|
|
30
35
|
this.schema = options.schema;
|
|
31
36
|
}
|
|
32
37
|
async import(collection, mimetype, stream) {
|
|
33
|
-
|
|
34
|
-
if (((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.admin) !== true && collection.startsWith('directus_'))
|
|
38
|
+
if (this.accountability?.admin !== true && collection.startsWith('directus_'))
|
|
35
39
|
throw new exceptions_1.ForbiddenException();
|
|
36
|
-
const createPermissions =
|
|
37
|
-
const updatePermissions =
|
|
38
|
-
if (
|
|
40
|
+
const createPermissions = this.accountability?.permissions?.find((permission) => permission.collection === collection && permission.action === 'create');
|
|
41
|
+
const updatePermissions = this.accountability?.permissions?.find((permission) => permission.collection === collection && permission.action === 'update');
|
|
42
|
+
if (this.accountability?.admin !== true && (!createPermissions || !updatePermissions)) {
|
|
39
43
|
throw new exceptions_1.ForbiddenException();
|
|
40
44
|
}
|
|
41
45
|
switch (mimetype) {
|
|
@@ -50,6 +54,7 @@ class ImportService {
|
|
|
50
54
|
}
|
|
51
55
|
importJSON(collection, stream) {
|
|
52
56
|
const extractJSON = StreamArray_1.default.withParser();
|
|
57
|
+
const nestedActionEvents = [];
|
|
53
58
|
return this.knex.transaction((trx) => {
|
|
54
59
|
const service = new items_1.ItemsService(collection, {
|
|
55
60
|
knex: trx,
|
|
@@ -57,7 +62,7 @@ class ImportService {
|
|
|
57
62
|
accountability: this.accountability,
|
|
58
63
|
});
|
|
59
64
|
const saveQueue = (0, async_1.queue)(async (value) => {
|
|
60
|
-
return await service.upsertOne(value);
|
|
65
|
+
return await service.upsertOne(value, { bypassEmitAction: (params) => nestedActionEvents.push(params) });
|
|
61
66
|
});
|
|
62
67
|
return new Promise((resolve, reject) => {
|
|
63
68
|
stream.pipe(extractJSON);
|
|
@@ -74,6 +79,9 @@ class ImportService {
|
|
|
74
79
|
});
|
|
75
80
|
extractJSON.on('end', () => {
|
|
76
81
|
saveQueue.drain(() => {
|
|
82
|
+
for (const nestedActionEvent of nestedActionEvents) {
|
|
83
|
+
emitter_1.default.emitAction(nestedActionEvent.event, nestedActionEvent.meta, nestedActionEvent.context);
|
|
84
|
+
}
|
|
77
85
|
return resolve();
|
|
78
86
|
});
|
|
79
87
|
});
|
|
@@ -81,6 +89,7 @@ class ImportService {
|
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
importCSV(collection, stream) {
|
|
92
|
+
const nestedActionEvents = [];
|
|
84
93
|
return this.knex.transaction((trx) => {
|
|
85
94
|
const service = new items_1.ItemsService(collection, {
|
|
86
95
|
knex: trx,
|
|
@@ -88,7 +97,7 @@ class ImportService {
|
|
|
88
97
|
accountability: this.accountability,
|
|
89
98
|
});
|
|
90
99
|
const saveQueue = (0, async_1.queue)(async (value) => {
|
|
91
|
-
return await service.upsertOne(value);
|
|
100
|
+
return await service.upsertOne(value, { bypassEmitAction: (action) => nestedActionEvents.push(action) });
|
|
92
101
|
});
|
|
93
102
|
return new Promise((resolve, reject) => {
|
|
94
103
|
stream
|
|
@@ -122,6 +131,9 @@ class ImportService {
|
|
|
122
131
|
})
|
|
123
132
|
.on('end', () => {
|
|
124
133
|
saveQueue.drain(() => {
|
|
134
|
+
for (const nestedActionEvent of nestedActionEvents) {
|
|
135
|
+
emitter_1.default.emitAction(nestedActionEvent.event, nestedActionEvent.meta, nestedActionEvent.context);
|
|
136
|
+
}
|
|
125
137
|
return resolve();
|
|
126
138
|
});
|
|
127
139
|
});
|
|
@@ -134,6 +146,9 @@ class ImportService {
|
|
|
134
146
|
}
|
|
135
147
|
exports.ImportService = ImportService;
|
|
136
148
|
class ExportService {
|
|
149
|
+
knex;
|
|
150
|
+
accountability;
|
|
151
|
+
schema;
|
|
137
152
|
constructor(options) {
|
|
138
153
|
this.knex = options.knex || (0, database_1.default)();
|
|
139
154
|
this.accountability = options.accountability || null;
|
|
@@ -145,17 +160,16 @@ class ExportService {
|
|
|
145
160
|
* FilesService upload method.
|
|
146
161
|
*/
|
|
147
162
|
async exportToFile(collection, query, format, options) {
|
|
148
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
149
163
|
try {
|
|
150
164
|
const mimeTypes = {
|
|
151
|
-
xml: 'text/xml',
|
|
152
165
|
csv: 'text/csv',
|
|
153
166
|
json: 'application/json',
|
|
167
|
+
xml: 'text/xml',
|
|
168
|
+
yaml: 'text/yaml',
|
|
154
169
|
};
|
|
155
170
|
const database = (0, database_1.default)();
|
|
156
171
|
const { path, cleanup } = await (0, tmp_promise_1.file)();
|
|
157
172
|
await database.transaction(async (trx) => {
|
|
158
|
-
var _a;
|
|
159
173
|
const service = new items_1.ItemsService(collection, {
|
|
160
174
|
accountability: this.accountability,
|
|
161
175
|
schema: this.schema,
|
|
@@ -168,9 +182,9 @@ class ExportService {
|
|
|
168
182
|
count: ['*'],
|
|
169
183
|
},
|
|
170
184
|
})
|
|
171
|
-
.then((result) =>
|
|
185
|
+
.then((result) => Number(result?.[0]?.count ?? 0));
|
|
172
186
|
const count = query.limit ? Math.min(totalCount, query.limit) : totalCount;
|
|
173
|
-
const requestedLimit =
|
|
187
|
+
const requestedLimit = query.limit ?? -1;
|
|
174
188
|
const batchesRequired = Math.ceil(count / env_1.default.EXPORT_BATCH_SIZE);
|
|
175
189
|
let readCount = 0;
|
|
176
190
|
for (let batch = 0; batch < batchesRequired; batch++) {
|
|
@@ -200,14 +214,14 @@ class ExportService {
|
|
|
200
214
|
const title = `export-${collection}-${(0, get_date_formatted_1.getDateFormatted)()}`;
|
|
201
215
|
const filename = `${title}.${format}`;
|
|
202
216
|
const fileWithDefaults = {
|
|
203
|
-
...(
|
|
204
|
-
title:
|
|
205
|
-
filename_download:
|
|
206
|
-
storage:
|
|
217
|
+
...(options?.file ?? {}),
|
|
218
|
+
title: options?.file?.title ?? title,
|
|
219
|
+
filename_download: options?.file?.filename_download ?? filename,
|
|
220
|
+
storage: options?.file?.storage ?? storage,
|
|
207
221
|
type: mimeTypes[format],
|
|
208
222
|
};
|
|
209
223
|
const savedFile = await filesService.uploadOne((0, fs_extra_1.createReadStream)(path), fileWithDefaults);
|
|
210
|
-
if (
|
|
224
|
+
if (this.accountability?.user) {
|
|
211
225
|
const notificationsService = new notifications_1.NotificationsService({
|
|
212
226
|
accountability: this.accountability,
|
|
213
227
|
schema: this.schema,
|
|
@@ -224,7 +238,7 @@ class ExportService {
|
|
|
224
238
|
}
|
|
225
239
|
catch (err) {
|
|
226
240
|
logger_1.default.error(err, `Couldn't export ${collection}: ${err.message}`);
|
|
227
|
-
if (
|
|
241
|
+
if (this.accountability?.user) {
|
|
228
242
|
const notificationsService = new notifications_1.NotificationsService({
|
|
229
243
|
accountability: this.accountability,
|
|
230
244
|
schema: this.schema,
|
|
@@ -244,9 +258,9 @@ class ExportService {
|
|
|
244
258
|
transform(input, format, options) {
|
|
245
259
|
if (format === 'json') {
|
|
246
260
|
let string = JSON.stringify(input || null, null, '\t');
|
|
247
|
-
if (
|
|
261
|
+
if (options?.includeHeader === false)
|
|
248
262
|
string = string.split('\n').slice(1).join('\n');
|
|
249
|
-
if (
|
|
263
|
+
if (options?.includeFooter === false) {
|
|
250
264
|
const lines = string.split('\n');
|
|
251
265
|
string = lines.slice(0, lines.length - 1).join('\n');
|
|
252
266
|
string += ',\n';
|
|
@@ -255,9 +269,9 @@ class ExportService {
|
|
|
255
269
|
}
|
|
256
270
|
if (format === 'xml') {
|
|
257
271
|
let string = (0, js2xmlparser_1.parse)('data', input);
|
|
258
|
-
if (
|
|
272
|
+
if (options?.includeHeader === false)
|
|
259
273
|
string = string.split('\n').slice(2).join('\n');
|
|
260
|
-
if (
|
|
274
|
+
if (options?.includeFooter === false) {
|
|
261
275
|
const lines = string.split('\n');
|
|
262
276
|
string = lines.slice(0, lines.length - 1).join('\n');
|
|
263
277
|
string += '\n';
|
|
@@ -269,14 +283,17 @@ class ExportService {
|
|
|
269
283
|
return '';
|
|
270
284
|
const parser = new json2csv_1.Parser({
|
|
271
285
|
transforms: [json2csv_1.transforms.flatten({ separator: '.' })],
|
|
272
|
-
header:
|
|
286
|
+
header: options?.includeHeader !== false,
|
|
273
287
|
});
|
|
274
288
|
let string = parser.parse(input);
|
|
275
|
-
if (
|
|
289
|
+
if (options?.includeHeader === false) {
|
|
276
290
|
string = '\n' + string;
|
|
277
291
|
}
|
|
278
292
|
return string;
|
|
279
293
|
}
|
|
294
|
+
if (format === 'yaml') {
|
|
295
|
+
return (0, js_yaml_1.dump)(input);
|
|
296
|
+
}
|
|
280
297
|
throw new exceptions_1.ServiceUnavailableException(`Illegal export type used: "${format}"`, { service: 'export' });
|
|
281
298
|
}
|
|
282
299
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED
|
@@ -39,6 +39,7 @@ __exportStar(require("./presets"), exports);
|
|
|
39
39
|
__exportStar(require("./relations"), exports);
|
|
40
40
|
__exportStar(require("./revisions"), exports);
|
|
41
41
|
__exportStar(require("./roles"), exports);
|
|
42
|
+
__exportStar(require("./schema"), exports);
|
|
42
43
|
__exportStar(require("./server"), exports);
|
|
43
44
|
__exportStar(require("./settings"), exports);
|
|
44
45
|
__exportStar(require("./specifications"), exports);
|
package/dist/services/items.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Accountability, PermissionsAction, Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import Keyv from 'keyv';
|
|
3
|
-
import { Knex } from 'knex';
|
|
4
|
-
import { AbstractService, AbstractServiceOptions, Item as AnyItem, MutationOptions, PrimaryKey } from '../types';
|
|
2
|
+
import type Keyv from 'keyv';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
4
|
+
import type { AbstractService, AbstractServiceOptions, Item as AnyItem, MutationOptions, PrimaryKey } from '../types';
|
|
5
5
|
export type QueryOptions = {
|
|
6
6
|
stripNonRequested?: boolean;
|
|
7
7
|
permissionsAction?: PermissionsAction;
|