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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getColumnPath = void 0;
|
|
4
|
-
const get_relation_info_1 = require("./get-relation-info");
|
|
5
4
|
const exceptions_1 = require("../exceptions");
|
|
5
|
+
const get_relation_info_1 = require("./get-relation-info");
|
|
6
6
|
/**
|
|
7
7
|
* Converts a Directus field list path to the correct SQL names based on the constructed alias map.
|
|
8
8
|
* For example: ['author', 'role', 'name'] -> 'ljnsv.name'
|
|
@@ -12,7 +12,6 @@ const exceptions_1 = require("../exceptions");
|
|
|
12
12
|
function getColumnPath({ path, collection, aliasMap, relations, schema }) {
|
|
13
13
|
return followRelation(path);
|
|
14
14
|
function followRelation(pathParts, parentCollection = collection, parentFields, addNestedPkField) {
|
|
15
|
-
var _a, _b, _c, _d;
|
|
16
15
|
/**
|
|
17
16
|
* For A2M fields, the path can contain an optional collection scope <field>:<scope>
|
|
18
17
|
*/
|
|
@@ -21,7 +20,7 @@ function getColumnPath({ path, collection, aliasMap, relations, schema }) {
|
|
|
21
20
|
if (!relation) {
|
|
22
21
|
throw new exceptions_1.InvalidQueryException(`"${parentCollection}.${pathRoot}" is not a relational field`);
|
|
23
22
|
}
|
|
24
|
-
const alias = parentFields ?
|
|
23
|
+
const alias = parentFields ? aliasMap[`${parentFields}.${pathParts[0]}`]?.alias : aliasMap[pathParts[0]]?.alias;
|
|
25
24
|
const remainingParts = pathParts.slice(1);
|
|
26
25
|
let parent;
|
|
27
26
|
if (relationType === 'a2o') {
|
|
@@ -38,7 +37,7 @@ function getColumnPath({ path, collection, aliasMap, relations, schema }) {
|
|
|
38
37
|
parent = relation.collection;
|
|
39
38
|
}
|
|
40
39
|
// Top level alias field
|
|
41
|
-
if (schema && !((
|
|
40
|
+
if (schema && !((remainingParts[0] ?? parent).includes('(') && (remainingParts[0] ?? parent).includes(')'))) {
|
|
42
41
|
if (remainingParts.length === 0) {
|
|
43
42
|
remainingParts.push(schema.collections[parent].primary);
|
|
44
43
|
addNestedPkField = schema.collections[parent].primary;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { Knex } from 'knex';
|
|
1
|
+
import type { Query, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
3
|
type GetColumnOptions = {
|
|
4
|
-
query?: Query;
|
|
5
|
-
originalCollectionName?: string;
|
|
4
|
+
query?: Query | undefined;
|
|
5
|
+
originalCollectionName?: string | undefined;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Return column prefixed by table. If column includes functions (like `year(date_created)`), the
|
package/dist/utils/get-column.js
CHANGED
|
@@ -19,22 +19,21 @@ const apply_function_to_column_name_1 = require("./apply-function-to-column-name
|
|
|
19
19
|
* @returns Knex raw instance
|
|
20
20
|
*/
|
|
21
21
|
function getColumn(knex, table, column, alias = (0, apply_function_to_column_name_1.applyFunctionToColumnName)(column), schema, options) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
23
22
|
const fn = (0, helpers_1.getFunctions)(knex, schema);
|
|
24
23
|
if (column.includes('(') && column.includes(')')) {
|
|
25
24
|
const functionName = column.split('(')[0];
|
|
26
25
|
const columnName = column.match(constants_1.REGEX_BETWEEN_PARENS)[1];
|
|
27
26
|
if (functionName in fn) {
|
|
28
|
-
const collectionName =
|
|
29
|
-
const type =
|
|
27
|
+
const collectionName = options?.originalCollectionName || table;
|
|
28
|
+
const type = schema?.collections[collectionName]?.fields?.[columnName]?.type ?? 'unknown';
|
|
30
29
|
const allowedFunctions = (0, utils_1.getFunctionsForType)(type);
|
|
31
30
|
if (allowedFunctions.includes(functionName) === false) {
|
|
32
31
|
throw new exceptions_1.InvalidQueryException(`Invalid function specified "${functionName}"`);
|
|
33
32
|
}
|
|
34
33
|
const result = fn[functionName](table, columnName, {
|
|
35
34
|
type,
|
|
36
|
-
query: options
|
|
37
|
-
originalCollectionName: options
|
|
35
|
+
query: options?.query,
|
|
36
|
+
originalCollectionName: options?.originalCollectionName,
|
|
38
37
|
});
|
|
39
38
|
if (alias) {
|
|
40
39
|
return knex.raw(result + ' AS ??', [alias]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SchemaOverview } from '@directus/schema/types/overview';
|
|
2
|
-
import { Column } from 'knex-schema-inspector/dist/types/column';
|
|
1
|
+
import type { SchemaOverview } from '@directus/schema/types/overview';
|
|
2
|
+
import type { Column } from 'knex-schema-inspector/dist/types/column';
|
|
3
3
|
export default function getDefaultValue(column: SchemaOverview[string]['columns'][string] | Column): string | boolean | number | Record<string, any> | any[] | null;
|
|
@@ -8,9 +8,8 @@ const env_1 = __importDefault(require("../env"));
|
|
|
8
8
|
const logger_1 = __importDefault(require("../logger"));
|
|
9
9
|
const get_local_type_1 = __importDefault(require("./get-local-type"));
|
|
10
10
|
function getDefaultValue(column) {
|
|
11
|
-
var _a;
|
|
12
11
|
const type = (0, get_local_type_1.default)(column);
|
|
13
|
-
const defaultValue =
|
|
12
|
+
const defaultValue = column.default_value ?? null;
|
|
14
13
|
if (defaultValue === null)
|
|
15
14
|
return null;
|
|
16
15
|
if (defaultValue === '0000-00-00 00:00:00')
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Request } from 'express';
|
|
1
|
+
import type { Request } from 'express';
|
|
2
2
|
export declare function getGraphqlQueryAndVariables(req: Request): Pick<any, "query" | "variables">;
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGraphqlQueryAndVariables = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
function getGraphqlQueryAndVariables(req) {
|
|
6
|
-
|
|
7
|
-
const isGet = ((_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'get';
|
|
6
|
+
const isGet = req.method?.toLowerCase() === 'get';
|
|
8
7
|
return (0, lodash_1.pick)(isGet ? req.query : req.body, ['query', 'variables']);
|
|
9
8
|
}
|
|
10
9
|
exports.getGraphqlQueryAndVariables = getGraphqlQueryAndVariables;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Type } from '@directus/shared/types';
|
|
2
|
+
import { GraphQLList, GraphQLScalarType, GraphQLType } from 'graphql';
|
|
3
3
|
export declare function getGraphQLType(localType: Type | 'alias' | 'unknown', special: string[]): GraphQLScalarType | GraphQLList<GraphQLType>;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGraphQLType = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const graphql_compose_1 = require("graphql-compose");
|
|
6
|
+
const bigint_1 = require("../services/graphql/types/bigint");
|
|
6
7
|
const date_1 = require("../services/graphql/types/date");
|
|
7
8
|
const geojson_1 = require("../services/graphql/types/geojson");
|
|
8
9
|
const hash_1 = require("../services/graphql/types/hash");
|
|
9
|
-
const bigint_1 = require("../services/graphql/types/bigint");
|
|
10
10
|
function getGraphQLType(localType, special) {
|
|
11
11
|
if (special.includes('conceal')) {
|
|
12
12
|
return hash_1.GraphQLHash;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Request } from 'express';
|
|
1
|
+
import type { Request } from 'express';
|
|
2
2
|
export declare function getIPFromReq(req: Request): string;
|
|
@@ -100,7 +100,7 @@ function getLocalType(column, field) {
|
|
|
100
100
|
return 'alias';
|
|
101
101
|
const dataType = column.data_type.toLowerCase();
|
|
102
102
|
const type = localTypeMap[dataType.split('(')[0]];
|
|
103
|
-
const special = field
|
|
103
|
+
const special = field?.special;
|
|
104
104
|
if (special) {
|
|
105
105
|
if (special.includes('cast-json'))
|
|
106
106
|
return 'json';
|
|
@@ -114,7 +114,7 @@ function getLocalType(column, field) {
|
|
|
114
114
|
return 'timestamp';
|
|
115
115
|
if (special.includes('cast-datetime'))
|
|
116
116
|
return 'dateTime';
|
|
117
|
-
if (type
|
|
117
|
+
if (type?.startsWith('geometry')) {
|
|
118
118
|
return special[0] || 'geometry';
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -126,6 +126,6 @@ function getLocalType(column, field) {
|
|
|
126
126
|
if (column.data_type === 'nvarchar' && column.max_length === -1) {
|
|
127
127
|
return 'text';
|
|
128
128
|
}
|
|
129
|
-
return type
|
|
129
|
+
return type ?? 'unknown';
|
|
130
130
|
}
|
|
131
131
|
exports.default = getLocalType;
|
|
@@ -0,0 +1,14 @@
|
|
|
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.getMilliseconds = void 0;
|
|
7
|
+
const ms_1 = __importDefault(require("ms"));
|
|
8
|
+
function getMilliseconds(value, fallback = undefined) {
|
|
9
|
+
if ((typeof value !== 'string' && typeof value !== 'number') || value === '') {
|
|
10
|
+
return fallback;
|
|
11
|
+
}
|
|
12
|
+
return (0, ms_1.default)(String(value)) ?? fallback;
|
|
13
|
+
}
|
|
14
|
+
exports.getMilliseconds = getMilliseconds;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Accountability, Permission, SchemaOverview } from '@directus/shared/types';
|
|
1
|
+
import type { Accountability, Permission, SchemaOverview } from '@directus/shared/types';
|
|
2
2
|
export declare function getPermissions(accountability: Accountability, schema: SchemaOverview): Promise<Permission[]>;
|
|
@@ -11,11 +11,11 @@ const cache_1 = require("../cache");
|
|
|
11
11
|
const database_1 = __importDefault(require("../database"));
|
|
12
12
|
const app_access_permissions_1 = require("../database/system-data/app-access-permissions");
|
|
13
13
|
const env_1 = __importDefault(require("../env"));
|
|
14
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
14
15
|
const roles_1 = require("../services/roles");
|
|
15
16
|
const users_1 = require("../services/users");
|
|
16
17
|
const merge_permissions_1 = require("../utils/merge-permissions");
|
|
17
18
|
const merge_permissions_for_share_1 = require("./merge-permissions-for-share");
|
|
18
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
19
19
|
async function getPermissions(accountability, schema) {
|
|
20
20
|
const database = (0, database_1.default)();
|
|
21
21
|
const { cache } = (0, cache_1.getCache)();
|
|
@@ -9,7 +9,6 @@ function checkImplicitRelation(field) {
|
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
function getRelationInfo(relations, collection, field) {
|
|
12
|
-
var _a;
|
|
13
12
|
if (field.startsWith('$FOLLOW') && field.length > 500) {
|
|
14
13
|
throw new Error(`Implicit $FOLLOW statement is too big to parse. Got: "${field.substring(500)}..."`);
|
|
15
14
|
}
|
|
@@ -40,11 +39,10 @@ function getRelationInfo(relations, collection, field) {
|
|
|
40
39
|
return { relation, relationType: 'o2a' };
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
const relation =
|
|
44
|
-
var _a;
|
|
42
|
+
const relation = relations.find((relation) => {
|
|
45
43
|
return ((relation.collection === collection && relation.field === field) ||
|
|
46
|
-
(relation.related_collection === collection &&
|
|
47
|
-
})
|
|
44
|
+
(relation.related_collection === collection && relation.meta?.one_field === field));
|
|
45
|
+
}) ?? null;
|
|
48
46
|
const relationType = relation ? (0, get_relation_type_1.getRelationType)({ relation, collection, field }) : null;
|
|
49
47
|
return { relation, relationType };
|
|
50
48
|
}
|
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRelationType = void 0;
|
|
4
4
|
function getRelationType(getRelationOptions) {
|
|
5
|
-
var _a, _b, _c;
|
|
6
5
|
const { relation, collection, field } = getRelationOptions;
|
|
7
6
|
if (!relation)
|
|
8
7
|
return null;
|
|
9
8
|
if (relation.collection === collection &&
|
|
10
9
|
relation.field === field &&
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
relation.meta?.one_collection_field &&
|
|
11
|
+
relation.meta?.one_allowed_collections) {
|
|
13
12
|
return 'a2o';
|
|
14
13
|
}
|
|
15
14
|
if (relation.collection === collection && relation.field === field) {
|
|
16
15
|
return 'm2o';
|
|
17
16
|
}
|
|
18
|
-
if (relation.related_collection === collection &&
|
|
17
|
+
if (relation.related_collection === collection && relation.meta?.one_field === field) {
|
|
19
18
|
return 'o2m';
|
|
20
19
|
}
|
|
21
20
|
return null;
|
package/dist/utils/get-schema.js
CHANGED
|
@@ -18,13 +18,13 @@ const services_1 = require("../services");
|
|
|
18
18
|
const get_default_value_1 = __importDefault(require("./get-default-value"));
|
|
19
19
|
const get_local_type_1 = __importDefault(require("./get-local-type"));
|
|
20
20
|
async function getSchema(options) {
|
|
21
|
-
const database =
|
|
21
|
+
const database = options?.database || (0, database_1.default)();
|
|
22
22
|
const schemaInspector = (0, schema_1.default)(database);
|
|
23
23
|
let result;
|
|
24
|
-
if (!
|
|
24
|
+
if (!options?.bypassCache && env_1.default.CACHE_SCHEMA !== false) {
|
|
25
25
|
let cachedSchema;
|
|
26
26
|
try {
|
|
27
|
-
cachedSchema =
|
|
27
|
+
cachedSchema = await (0, cache_1.getSchemaCache)();
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
30
30
|
logger_1.default.warn(err, `[schema-cache] Couldn't retrieve cache. ${err}`);
|
|
@@ -35,7 +35,7 @@ async function getSchema(options) {
|
|
|
35
35
|
else {
|
|
36
36
|
result = await getDatabaseSchema(database, schemaInspector);
|
|
37
37
|
try {
|
|
38
|
-
await (0, cache_1.
|
|
38
|
+
await (0, cache_1.setSchemaCache)(result);
|
|
39
39
|
}
|
|
40
40
|
catch (err) {
|
|
41
41
|
logger_1.default.warn(err, `[schema-cache] Couldn't save cache. ${err}`);
|
|
@@ -49,7 +49,6 @@ async function getSchema(options) {
|
|
|
49
49
|
}
|
|
50
50
|
exports.getSchema = getSchema;
|
|
51
51
|
async function getDatabaseSchema(database, schemaInspector) {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f;
|
|
53
52
|
const result = {
|
|
54
53
|
collections: {},
|
|
55
54
|
relations: [],
|
|
@@ -78,17 +77,16 @@ async function getDatabaseSchema(database, schemaInspector) {
|
|
|
78
77
|
result.collections[collection] = {
|
|
79
78
|
collection,
|
|
80
79
|
primary: info.primary,
|
|
81
|
-
singleton:
|
|
82
|
-
note:
|
|
83
|
-
sortField:
|
|
80
|
+
singleton: collectionMeta?.singleton === true || collectionMeta?.singleton === 'true' || collectionMeta?.singleton === 1,
|
|
81
|
+
note: collectionMeta?.note || null,
|
|
82
|
+
sortField: collectionMeta?.sort_field || null,
|
|
84
83
|
accountability: collectionMeta ? collectionMeta.accountability : 'all',
|
|
85
84
|
fields: (0, lodash_1.mapValues)(schemaOverview[collection].columns, (column) => {
|
|
86
|
-
var _a, _b, _c;
|
|
87
85
|
return {
|
|
88
86
|
field: column.column_name,
|
|
89
|
-
defaultValue: (
|
|
90
|
-
nullable:
|
|
91
|
-
generated:
|
|
87
|
+
defaultValue: (0, get_default_value_1.default)(column) ?? null,
|
|
88
|
+
nullable: column.is_nullable ?? true,
|
|
89
|
+
generated: column.is_generated ?? false,
|
|
92
90
|
type: (0, get_local_type_1.default)(column),
|
|
93
91
|
dbType: column.data_type,
|
|
94
92
|
precision: column.numeric_precision || null,
|
|
@@ -116,22 +114,22 @@ async function getDatabaseSchema(database, schemaInspector) {
|
|
|
116
114
|
if (constants_1.ALIAS_TYPES.some((type) => special.includes(type)) === false && !existing)
|
|
117
115
|
continue;
|
|
118
116
|
const type = (existing && (0, get_local_type_1.default)(column, { special })) || 'alias';
|
|
119
|
-
let validation =
|
|
117
|
+
let validation = field.validation ?? null;
|
|
120
118
|
if (validation && typeof validation === 'string')
|
|
121
119
|
validation = (0, utils_1.parseJSON)(validation);
|
|
122
120
|
result.collections[field.collection].fields[field.field] = {
|
|
123
121
|
field: field.field,
|
|
124
|
-
defaultValue:
|
|
125
|
-
nullable:
|
|
126
|
-
generated:
|
|
122
|
+
defaultValue: existing?.defaultValue ?? null,
|
|
123
|
+
nullable: existing?.nullable ?? true,
|
|
124
|
+
generated: existing?.generated ?? false,
|
|
127
125
|
type: type,
|
|
128
|
-
dbType:
|
|
129
|
-
precision:
|
|
130
|
-
scale:
|
|
126
|
+
dbType: existing?.dbType || null,
|
|
127
|
+
precision: existing?.precision || null,
|
|
128
|
+
scale: existing?.scale || null,
|
|
131
129
|
special: special,
|
|
132
130
|
note: field.note,
|
|
133
|
-
alias:
|
|
134
|
-
validation:
|
|
131
|
+
alias: existing?.alias ?? true,
|
|
132
|
+
validation: validation ?? null,
|
|
135
133
|
};
|
|
136
134
|
}
|
|
137
135
|
const relationsService = new services_1.RelationsService({ knex: database, schema: result });
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSnapshotDiff = void 0;
|
|
4
4
|
const deep_diff_1 = require("deep-diff");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const sanitize_schema_1 = require("./sanitize-schema");
|
|
6
8
|
function getSnapshotDiff(current, after) {
|
|
7
9
|
const diffedSnapshot = {
|
|
8
10
|
collections: (0, lodash_1.orderBy)([
|
|
@@ -10,7 +12,7 @@ function getSnapshotDiff(current, after) {
|
|
|
10
12
|
const afterCollection = after.collections.find((afterCollection) => afterCollection.collection === currentCollection.collection);
|
|
11
13
|
return {
|
|
12
14
|
collection: currentCollection.collection,
|
|
13
|
-
diff: (0, deep_diff_1.diff)(currentCollection, afterCollection),
|
|
15
|
+
diff: (0, deep_diff_1.diff)((0, sanitize_schema_1.sanitizeCollection)(currentCollection), (0, sanitize_schema_1.sanitizeCollection)(afterCollection)),
|
|
14
16
|
};
|
|
15
17
|
}),
|
|
16
18
|
...after.collections
|
|
@@ -20,16 +22,17 @@ function getSnapshotDiff(current, after) {
|
|
|
20
22
|
})
|
|
21
23
|
.map((afterCollection) => ({
|
|
22
24
|
collection: afterCollection.collection,
|
|
23
|
-
diff: (0, deep_diff_1.diff)(undefined, afterCollection),
|
|
25
|
+
diff: (0, deep_diff_1.diff)(undefined, (0, sanitize_schema_1.sanitizeCollection)(afterCollection)),
|
|
24
26
|
})),
|
|
25
27
|
].filter((obj) => Array.isArray(obj.diff)), 'collection'),
|
|
26
28
|
fields: (0, lodash_1.orderBy)([
|
|
27
29
|
...current.fields.map((currentField) => {
|
|
28
30
|
const afterField = after.fields.find((afterField) => afterField.collection === currentField.collection && afterField.field === currentField.field);
|
|
31
|
+
const isAutoIncrementPrimaryKey = !!currentField.schema?.is_primary_key && !!currentField.schema?.has_auto_increment;
|
|
29
32
|
return {
|
|
30
33
|
collection: currentField.collection,
|
|
31
34
|
field: currentField.field,
|
|
32
|
-
diff: (0, deep_diff_1.diff)(currentField, afterField),
|
|
35
|
+
diff: (0, deep_diff_1.diff)((0, sanitize_schema_1.sanitizeField)(currentField, isAutoIncrementPrimaryKey), (0, sanitize_schema_1.sanitizeField)(afterField, isAutoIncrementPrimaryKey)),
|
|
33
36
|
};
|
|
34
37
|
}),
|
|
35
38
|
...after.fields
|
|
@@ -40,7 +43,7 @@ function getSnapshotDiff(current, after) {
|
|
|
40
43
|
.map((afterField) => ({
|
|
41
44
|
collection: afterField.collection,
|
|
42
45
|
field: afterField.field,
|
|
43
|
-
diff: (0, deep_diff_1.diff)(undefined, afterField),
|
|
46
|
+
diff: (0, deep_diff_1.diff)(undefined, (0, sanitize_schema_1.sanitizeField)(afterField)),
|
|
44
47
|
})),
|
|
45
48
|
].filter((obj) => Array.isArray(obj.diff)), ['collection']),
|
|
46
49
|
relations: (0, lodash_1.orderBy)([
|
|
@@ -50,7 +53,7 @@ function getSnapshotDiff(current, after) {
|
|
|
50
53
|
collection: currentRelation.collection,
|
|
51
54
|
field: currentRelation.field,
|
|
52
55
|
related_collection: currentRelation.related_collection,
|
|
53
|
-
diff: (0, deep_diff_1.diff)(currentRelation, afterRelation),
|
|
56
|
+
diff: (0, deep_diff_1.diff)((0, sanitize_schema_1.sanitizeRelation)(currentRelation), (0, sanitize_schema_1.sanitizeRelation)(afterRelation)),
|
|
54
57
|
};
|
|
55
58
|
}),
|
|
56
59
|
...after.relations
|
|
@@ -62,7 +65,7 @@ function getSnapshotDiff(current, after) {
|
|
|
62
65
|
collection: afterRelation.collection,
|
|
63
66
|
field: afterRelation.field,
|
|
64
67
|
related_collection: afterRelation.related_collection,
|
|
65
|
-
diff: (0, deep_diff_1.diff)(undefined, afterRelation),
|
|
68
|
+
diff: (0, deep_diff_1.diff)(undefined, (0, sanitize_schema_1.sanitizeRelation)(afterRelation)),
|
|
66
69
|
})),
|
|
67
70
|
].filter((obj) => Array.isArray(obj.diff)), ['collection']),
|
|
68
71
|
};
|
|
@@ -70,7 +73,7 @@ function getSnapshotDiff(current, after) {
|
|
|
70
73
|
* When you delete a collection, we don't have to individually drop all the fields/relations as well
|
|
71
74
|
*/
|
|
72
75
|
const deletedCollections = diffedSnapshot.collections
|
|
73
|
-
.filter((collection) =>
|
|
76
|
+
.filter((collection) => collection.diff?.[0].kind === types_1.DiffKind.DELETE)
|
|
74
77
|
.map(({ collection }) => collection);
|
|
75
78
|
diffedSnapshot.fields = diffedSnapshot.fields.filter((field) => deletedCollections.includes(field.collection) === false);
|
|
76
79
|
diffedSnapshot.relations = diffedSnapshot.relations.filter((relation) => deletedCollections.includes(relation.collection) === false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Knex } from 'knex';
|
|
3
|
-
import {
|
|
1
|
+
import type { SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { Snapshot } from '../types';
|
|
4
4
|
export declare function getSnapshot(options?: {
|
|
5
5
|
database?: Knex;
|
|
6
6
|
schema?: SchemaOverview;
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.getSnapshot = void 0;
|
|
7
|
-
const database_1 = __importDefault(require("../database"));
|
|
8
|
-
const get_schema_1 = require("./get-schema");
|
|
9
|
-
const services_1 = require("../services");
|
|
10
|
-
const package_json_1 = require("../../package.json");
|
|
11
27
|
const lodash_1 = require("lodash");
|
|
28
|
+
const package_json_1 = require("../../package.json");
|
|
29
|
+
const database_1 = __importStar(require("../database"));
|
|
30
|
+
const services_1 = require("../services");
|
|
31
|
+
const get_schema_1 = require("./get-schema");
|
|
32
|
+
const sanitize_schema_1 = require("./sanitize-schema");
|
|
12
33
|
async function getSnapshot(options) {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const schema =
|
|
34
|
+
const database = options?.database ?? (0, database_1.default)();
|
|
35
|
+
const vendor = (0, database_1.getDatabaseClient)(database);
|
|
36
|
+
const schema = options?.schema ?? (await (0, get_schema_1.getSchema)({ database, bypassCache: true }));
|
|
16
37
|
const collectionsService = new services_1.CollectionsService({ knex: database, schema });
|
|
17
38
|
const fieldsService = new services_1.FieldsService({ knex: database, schema });
|
|
18
39
|
const relationsService = new services_1.RelationsService({ knex: database, schema });
|
|
@@ -30,15 +51,15 @@ async function getSnapshot(options) {
|
|
|
30
51
|
return {
|
|
31
52
|
version: 1,
|
|
32
53
|
directus: package_json_1.version,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
vendor,
|
|
55
|
+
collections: collectionsSorted.map((collection) => (0, sanitize_schema_1.sanitizeCollection)(collection)),
|
|
56
|
+
fields: fieldsSorted.map((field) => (0, sanitize_schema_1.sanitizeField)(field)),
|
|
57
|
+
relations: relationsSorted.map((relation) => (0, sanitize_schema_1.sanitizeRelation)(relation)),
|
|
36
58
|
};
|
|
37
59
|
}
|
|
38
60
|
exports.getSnapshot = getSnapshot;
|
|
39
61
|
function excludeSystem(item) {
|
|
40
|
-
|
|
41
|
-
if (((_a = item === null || item === void 0 ? void 0 : item.meta) === null || _a === void 0 ? void 0 : _a.system) === true)
|
|
62
|
+
if (item?.meta?.system === true)
|
|
42
63
|
return false;
|
|
43
64
|
return true;
|
|
44
65
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getVersionedHash(item: Record<string, any>): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.getVersionedHash = void 0;
|
|
7
|
+
const object_hash_1 = __importDefault(require("object-hash"));
|
|
8
|
+
const package_json_1 = require("../../package.json");
|
|
9
|
+
function getVersionedHash(item) {
|
|
10
|
+
return (0, object_hash_1.default)({ item, version: package_json_1.version });
|
|
11
|
+
}
|
|
12
|
+
exports.getVersionedHash = getVersionedHash;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,7 +11,7 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
|
11
11
|
function isDirectusJWT(string) {
|
|
12
12
|
try {
|
|
13
13
|
const payload = jsonwebtoken_1.default.decode(string, { json: true });
|
|
14
|
-
if (
|
|
14
|
+
if (payload?.iss !== 'directus')
|
|
15
15
|
return false;
|
|
16
16
|
return true;
|
|
17
17
|
}
|
package/dist/utils/job-queue.js
CHANGED
package/dist/utils/jwt.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DirectusTokenPayload } from '../types';
|
|
1
|
+
import type { DirectusTokenPayload } from '../types';
|
|
2
2
|
export declare function verifyAccessJWT(token: string, secret: string): DirectusTokenPayload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mapValuesDeep(obj: Record<string, any>, fn: (key: string, value: any) => any): Record<string, any>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapValuesDeep = void 0;
|
|
4
|
+
function mapValuesDeep(obj, fn) {
|
|
5
|
+
return recurse(obj);
|
|
6
|
+
function recurse(obj, prefix = '') {
|
|
7
|
+
if (Array.isArray(obj)) {
|
|
8
|
+
return obj.map((value, index) => {
|
|
9
|
+
if (typeof value === 'object' && value !== null) {
|
|
10
|
+
return recurse(value, prefix + `[${index}]`);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return fn(prefix + `[${index}]`, value);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return Object.fromEntries(Object.entries(obj).map(([key, value]) => {
|
|
19
|
+
if (typeof value === 'object' && value !== null) {
|
|
20
|
+
return [key, recurse(value, prefix + (prefix ? '.' : '') + key)];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return [key, fn(prefix + (prefix ? '.' : '') + key, value)];
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.mapValuesDeep = mapValuesDeep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Permission, Accountability, Filter, SchemaOverview } from '@directus/shared/types';
|
|
1
|
+
import type { Permission, Accountability, Filter, SchemaOverview } from '@directus/shared/types';
|
|
2
2
|
export declare function mergePermissionsForShare(currentPermissions: Permission[], accountability: Accountability, schema: SchemaOverview): Permission[];
|
|
3
3
|
export declare function traverse(schema: SchemaOverview, rootItemPrimaryKeyField: string, rootItemPrimaryKey: string, currentCollection: string, parentCollections?: string[], path?: string[]): Partial<Permission>[];
|
|
4
4
|
export declare function getFilterForPath(type: 'o2m' | 'm2o' | 'a2o', path: string[], rootPrimaryKeyField: string, rootPrimaryKey: string): Filter;
|