directus 9.23.1 → 9.23.4
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 +25 -21
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +57 -46
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +20 -17
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +44 -35
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +50 -41
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +20 -17
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +8 -7
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +66 -18
- package/dist/cli/commands/bootstrap/index.js +7 -6
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +14 -15
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +3 -2
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/cli/utils/drivers.d.ts +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +7 -7
- package/dist/controllers/activity.js +10 -11
- package/dist/controllers/assets.js +31 -25
- package/dist/controllers/auth.js +40 -26
- package/dist/controllers/collections.js +10 -10
- package/dist/controllers/dashboards.js +14 -11
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +20 -20
- package/dist/controllers/files.js +26 -20
- package/dist/controllers/flows.js +16 -13
- package/dist/controllers/folders.js +14 -11
- package/dist/controllers/graphql.js +6 -8
- package/dist/controllers/items.js +22 -19
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +14 -11
- package/dist/controllers/operations.js +14 -11
- package/dist/controllers/panels.js +14 -11
- package/dist/controllers/permissions.js +14 -11
- package/dist/controllers/presets.js +14 -11
- package/dist/controllers/relations.js +10 -10
- package/dist/controllers/revisions.js +3 -3
- package/dist/controllers/roles.js +14 -11
- package/dist/controllers/schema.js +5 -5
- package/dist/controllers/server.js +7 -7
- package/dist/controllers/settings.js +2 -2
- package/dist/controllers/shares.js +21 -18
- package/dist/controllers/users.js +32 -36
- package/dist/controllers/utils.js +10 -15
- package/dist/controllers/webhooks.js +14 -11
- 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 -6
- package/dist/database/helpers/fn/types.js +4 -5
- 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 +1 -1
- 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 +2 -2
- package/dist/database/helpers/schema/dialects/oracle.js +4 -6
- package/dist/database/helpers/schema/types.d.ts +4 -4
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.js +13 -13
- 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/20210805B-change-image-metadata-structure.js +15 -15
- 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/migrations/run.js +1 -1
- package/dist/database/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +21 -30
- 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/collections/index.js +2 -2
- 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 +3 -4
- 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 +11 -3
- 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 +43 -33
- package/dist/flows.js +65 -46
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +35 -19
- package/dist/logger.test.d.ts +1 -0
- package/dist/mailer.js +16 -16
- package/dist/messenger.js +9 -7
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +13 -6
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +16 -16
- 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 +5 -5
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/cors.js +7 -7
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +11 -12
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/extract-token.js +2 -2
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +15 -9
- 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} +5 -5
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +18 -19
- package/dist/middleware/sanitize-query.d.ts +1 -1
- package/dist/middleware/sanitize-query.js +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 +15 -4
- 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 +19 -19
- package/dist/operations/trigger/index.js +2 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +9 -9
- package/dist/request/validate-ip.js +2 -2
- package/dist/server.js +12 -13
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +17 -16
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +35 -37
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +22 -19
- 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 +54 -50
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +50 -50
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +33 -27
- 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 +259 -252
- 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 +11 -4
- package/dist/services/import-export.d.ts +3 -3
- package/dist/services/import-export.js +30 -27
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +42 -36
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +14 -10
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +11 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +10 -9
- 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 +45 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +7 -7
- package/dist/services/schema.d.ts +3 -3
- package/dist/services/schema.js +9 -11
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +88 -32
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +1 -1
- package/dist/services/shares.js +14 -15
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +137 -119
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +2 -6
- package/dist/services/users.js +37 -40
- 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/storage/register-locations.js +1 -1
- package/dist/types/assets.d.ts +1 -1
- 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/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/items.d.ts +3 -3
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/utils/apply-diff.d.ts +3 -3
- package/dist/utils/apply-diff.js +25 -28
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +10 -12
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +5 -6
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/dynamic-import.js +1 -1
- package/dist/utils/filter-items.d.ts +1 -1
- package/dist/utils/generate-hash.js +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-auth-providers.js +1 -1
- package/dist/utils/get-cache-headers.d.ts +1 -1
- package/dist/utils/get-cache-headers.js +6 -7
- 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-collection-from-alias.js +1 -0
- 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 +2 -3
- 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-ip-from-req.js +2 -2
- package/dist/utils/get-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.js +1 -2
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +12 -12
- 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 +20 -22
- package/dist/utils/get-snapshot-diff.js +2 -3
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +6 -8
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/is-url-allowed.js +5 -2
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- 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/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 +27 -27
- package/dist/utils/sanitize-schema.d.ts +2 -2
- 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 +16 -16
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +7 -2
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.js +7 -8
- 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-storage.js +8 -8
- package/dist/webhooks.js +3 -3
- package/package.json +36 -37
- package/dist/utils/with-timeout.d.ts +0 -1
- package/dist/utils/with-timeout.js +0 -16
|
@@ -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;
|
|
@@ -9,8 +9,8 @@ const env_1 = __importDefault(require("../env"));
|
|
|
9
9
|
const logger_1 = __importDefault(require("../logger"));
|
|
10
10
|
function getIPFromReq(req) {
|
|
11
11
|
let ip = req.ip;
|
|
12
|
-
if (env_1.default
|
|
13
|
-
const customIPHeaderValue = req.get(env_1.default
|
|
12
|
+
if (env_1.default['IP_CUSTOM_HEADER']) {
|
|
13
|
+
const customIPHeaderValue = req.get(env_1.default['IP_CUSTOM_HEADER']);
|
|
14
14
|
if (typeof customIPHeaderValue === 'string' && (0, net_1.isIP)(customIPHeaderValue) !== 0) {
|
|
15
15
|
ip = customIPHeaderValue;
|
|
16
16
|
}
|
|
@@ -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;
|
|
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getMilliseconds = void 0;
|
|
7
7
|
const ms_1 = __importDefault(require("ms"));
|
|
8
8
|
function getMilliseconds(value, fallback = undefined) {
|
|
9
|
-
var _a;
|
|
10
9
|
if ((typeof value !== 'string' && typeof value !== 'number') || value === '') {
|
|
11
10
|
return fallback;
|
|
12
11
|
}
|
|
13
|
-
return (
|
|
12
|
+
return (0, ms_1.default)(String(value)) ?? fallback;
|
|
14
13
|
}
|
|
15
14
|
exports.getMilliseconds = getMilliseconds;
|
|
@@ -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,18 +11,18 @@ 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)();
|
|
22
22
|
let permissions = [];
|
|
23
23
|
const { user, role, app, admin, share_scope } = accountability;
|
|
24
24
|
const cacheKey = `permissions-${(0, object_hash_1.default)({ user, role, app, admin, share_scope })}`;
|
|
25
|
-
if (cache && env_1.default
|
|
25
|
+
if (cache && env_1.default['CACHE_PERMISSIONS'] !== false) {
|
|
26
26
|
let cachedPermissions;
|
|
27
27
|
try {
|
|
28
28
|
cachedPermissions = await (0, cache_1.getSystemCache)(cacheKey);
|
|
@@ -31,20 +31,20 @@ async function getPermissions(accountability, schema) {
|
|
|
31
31
|
logger_1.default.warn(err, `[cache] Couldn't read key ${cacheKey}. ${err.message}`);
|
|
32
32
|
}
|
|
33
33
|
if (cachedPermissions) {
|
|
34
|
-
if (!cachedPermissions
|
|
35
|
-
return processPermissions(accountability, cachedPermissions
|
|
34
|
+
if (!cachedPermissions['containDynamicData']) {
|
|
35
|
+
return processPermissions(accountability, cachedPermissions['permissions'], {});
|
|
36
36
|
}
|
|
37
|
-
const cachedFilterContext = await (0, cache_1.getCacheValue)(cache, `filterContext-${(0, object_hash_1.default)({ user, role, permissions: cachedPermissions
|
|
37
|
+
const cachedFilterContext = await (0, cache_1.getCacheValue)(cache, `filterContext-${(0, object_hash_1.default)({ user, role, permissions: cachedPermissions['permissions'] })}`);
|
|
38
38
|
if (cachedFilterContext) {
|
|
39
|
-
return processPermissions(accountability, cachedPermissions
|
|
39
|
+
return processPermissions(accountability, cachedPermissions['permissions'], cachedFilterContext);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
const { permissions: parsedPermissions, requiredPermissionData, containDynamicData, } = parsePermissions(cachedPermissions
|
|
42
|
+
const { permissions: parsedPermissions, requiredPermissionData, containDynamicData, } = parsePermissions(cachedPermissions['permissions']);
|
|
43
43
|
permissions = parsedPermissions;
|
|
44
44
|
const filterContext = containDynamicData
|
|
45
45
|
? await getFilterContext(schema, accountability, requiredPermissionData)
|
|
46
46
|
: {};
|
|
47
|
-
if (containDynamicData && env_1.default
|
|
47
|
+
if (containDynamicData && env_1.default['CACHE_ENABLED'] !== false) {
|
|
48
48
|
await (0, cache_1.setCacheValue)(cache, `filterContext-${(0, object_hash_1.default)({ user, role, permissions })}`, filterContext);
|
|
49
49
|
}
|
|
50
50
|
return processPermissions(accountability, permissions, filterContext);
|
|
@@ -71,9 +71,9 @@ async function getPermissions(accountability, schema) {
|
|
|
71
71
|
const filterContext = containDynamicData
|
|
72
72
|
? await getFilterContext(schema, accountability, requiredPermissionData)
|
|
73
73
|
: {};
|
|
74
|
-
if (cache && env_1.default
|
|
74
|
+
if (cache && env_1.default['CACHE_PERMISSIONS'] !== false) {
|
|
75
75
|
await (0, cache_1.setSystemCache)(cacheKey, { permissions, containDynamicData });
|
|
76
|
-
if (containDynamicData && env_1.default
|
|
76
|
+
if (containDynamicData && env_1.default['CACHE_ENABLED'] !== false) {
|
|
77
77
|
await (0, cache_1.setCacheValue)(cache, `filterContext-${(0, object_hash_1.default)({ user, role, permissions })}`, filterContext);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -137,12 +137,12 @@ async function getFilterContext(schema, accountability, requiredPermissionData)
|
|
|
137
137
|
const rolesService = new roles_1.RolesService({ schema });
|
|
138
138
|
const filterContext = {};
|
|
139
139
|
if (accountability.user && requiredPermissionData.$CURRENT_USER.length > 0) {
|
|
140
|
-
filterContext
|
|
140
|
+
filterContext['$CURRENT_USER'] = await usersService.readOne(accountability.user, {
|
|
141
141
|
fields: requiredPermissionData.$CURRENT_USER,
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
if (accountability.role && requiredPermissionData.$CURRENT_ROLE.length > 0) {
|
|
145
|
-
filterContext
|
|
145
|
+
filterContext['$CURRENT_ROLE'] = await rolesService.readOne(accountability.role, {
|
|
146
146
|
fields: requiredPermissionData.$CURRENT_ROLE,
|
|
147
147
|
});
|
|
148
148
|
}
|
|
@@ -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: [],
|
|
@@ -62,7 +61,7 @@ async function getDatabaseSchema(database, schemaInspector) {
|
|
|
62
61
|
...collections_1.systemCollectionRows,
|
|
63
62
|
];
|
|
64
63
|
for (const [collection, info] of Object.entries(schemaOverview)) {
|
|
65
|
-
if ((0, utils_1.toArray)(env_1.default
|
|
64
|
+
if ((0, utils_1.toArray)(env_1.default['DB_EXCLUDE_TABLES']).includes(collection)) {
|
|
66
65
|
logger_1.default.trace(`Collection "${collection}" is configured to be excluded and will be ignored`);
|
|
67
66
|
continue;
|
|
68
67
|
}
|
|
@@ -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 });
|
|
@@ -27,9 +27,8 @@ function getSnapshotDiff(current, after) {
|
|
|
27
27
|
].filter((obj) => Array.isArray(obj.diff)), 'collection'),
|
|
28
28
|
fields: (0, lodash_1.orderBy)([
|
|
29
29
|
...current.fields.map((currentField) => {
|
|
30
|
-
var _a, _b;
|
|
31
30
|
const afterField = after.fields.find((afterField) => afterField.collection === currentField.collection && afterField.field === currentField.field);
|
|
32
|
-
const isAutoIncrementPrimaryKey = !!
|
|
31
|
+
const isAutoIncrementPrimaryKey = !!currentField.schema?.is_primary_key && !!currentField.schema?.has_auto_increment;
|
|
33
32
|
return {
|
|
34
33
|
collection: currentField.collection,
|
|
35
34
|
field: currentField.field,
|
|
@@ -74,7 +73,7 @@ function getSnapshotDiff(current, after) {
|
|
|
74
73
|
* When you delete a collection, we don't have to individually drop all the fields/relations as well
|
|
75
74
|
*/
|
|
76
75
|
const deletedCollections = diffedSnapshot.collections
|
|
77
|
-
.filter((collection) =>
|
|
76
|
+
.filter((collection) => collection.diff?.[0].kind === types_1.DiffKind.DELETE)
|
|
78
77
|
.map(({ collection }) => collection);
|
|
79
78
|
diffedSnapshot.fields = diffedSnapshot.fields.filter((field) => deletedCollections.includes(field.collection) === false);
|
|
80
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;
|
|
@@ -24,17 +24,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getSnapshot = void 0;
|
|
27
|
+
const lodash_1 = require("lodash");
|
|
28
|
+
const package_json_1 = require("../../package.json");
|
|
27
29
|
const database_1 = __importStar(require("../database"));
|
|
28
|
-
const get_schema_1 = require("./get-schema");
|
|
29
30
|
const services_1 = require("../services");
|
|
30
|
-
const
|
|
31
|
-
const lodash_1 = require("lodash");
|
|
31
|
+
const get_schema_1 = require("./get-schema");
|
|
32
32
|
const sanitize_schema_1 = require("./sanitize-schema");
|
|
33
33
|
async function getSnapshot(options) {
|
|
34
|
-
|
|
35
|
-
const database = (_a = options === null || options === void 0 ? void 0 : options.database) !== null && _a !== void 0 ? _a : (0, database_1.default)();
|
|
34
|
+
const database = options?.database ?? (0, database_1.default)();
|
|
36
35
|
const vendor = (0, database_1.getDatabaseClient)(database);
|
|
37
|
-
const schema =
|
|
36
|
+
const schema = options?.schema ?? (await (0, get_schema_1.getSchema)({ database, bypassCache: true }));
|
|
38
37
|
const collectionsService = new services_1.CollectionsService({ knex: database, schema });
|
|
39
38
|
const fieldsService = new services_1.FieldsService({ knex: database, schema });
|
|
40
39
|
const relationsService = new services_1.RelationsService({ knex: database, schema });
|
|
@@ -60,8 +59,7 @@ async function getSnapshot(options) {
|
|
|
60
59
|
}
|
|
61
60
|
exports.getSnapshot = getSnapshot;
|
|
62
61
|
function excludeSystem(item) {
|
|
63
|
-
|
|
64
|
-
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)
|
|
65
63
|
return false;
|
|
66
64
|
return true;
|
|
67
65
|
}
|
|
@@ -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
|
}
|
|
@@ -13,7 +13,8 @@ function isUrlAllowed(url, allowList) {
|
|
|
13
13
|
const urlAllowList = (0, utils_1.toArray)(allowList);
|
|
14
14
|
if (urlAllowList.includes(url))
|
|
15
15
|
return true;
|
|
16
|
-
const parsedWhitelist = urlAllowList
|
|
16
|
+
const parsedWhitelist = urlAllowList
|
|
17
|
+
.map((allowedURL) => {
|
|
17
18
|
try {
|
|
18
19
|
const { hostname, pathname } = new url_1.URL(allowedURL);
|
|
19
20
|
return hostname + pathname;
|
|
@@ -21,7 +22,9 @@ function isUrlAllowed(url, allowList) {
|
|
|
21
22
|
catch {
|
|
22
23
|
logger_1.default.warn(`Invalid URL used "${url}"`);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
return null;
|
|
26
|
+
})
|
|
27
|
+
.filter((f) => f);
|
|
25
28
|
try {
|
|
26
29
|
const { hostname, pathname } = new url_1.URL(url);
|
|
27
30
|
return parsedWhitelist.includes(hostname + pathname);
|
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;
|
|
@@ -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;
|
|
@@ -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">;
|
|
@@ -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;
|