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
|
@@ -4,22 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GraphQLService = void 0;
|
|
7
|
+
const constants_1 = require("@directus/shared/constants");
|
|
7
8
|
const types_1 = require("@directus/shared/types");
|
|
8
9
|
const utils_1 = require("@directus/shared/utils");
|
|
9
10
|
const argon2_1 = __importDefault(require("argon2"));
|
|
10
11
|
const graphql_1 = require("graphql");
|
|
11
12
|
const graphql_compose_1 = require("graphql-compose");
|
|
12
|
-
const process_error_1 = __importDefault(require("./utils/process-error"));
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
|
-
const ms_1 = __importDefault(require("ms"));
|
|
15
14
|
const cache_1 = require("../../cache");
|
|
16
|
-
const
|
|
15
|
+
const constants_2 = require("../../constants");
|
|
17
16
|
const database_1 = __importDefault(require("../../database"));
|
|
18
17
|
const env_1 = __importDefault(require("../../env"));
|
|
19
18
|
const exceptions_1 = require("../../exceptions");
|
|
20
19
|
const extensions_1 = require("../../extensions");
|
|
21
20
|
const generate_hash_1 = require("../../utils/generate-hash");
|
|
22
21
|
const get_graphql_type_1 = require("../../utils/get-graphql-type");
|
|
22
|
+
const get_milliseconds_1 = require("../../utils/get-milliseconds");
|
|
23
23
|
const reduce_schema_1 = require("../../utils/reduce-schema");
|
|
24
24
|
const sanitize_query_1 = require("../../utils/sanitize-query");
|
|
25
25
|
const validate_query_1 = require("../../utils/validate-query");
|
|
@@ -46,14 +46,14 @@ const tfa_1 = require("../tfa");
|
|
|
46
46
|
const users_1 = require("../users");
|
|
47
47
|
const utils_2 = require("../utils");
|
|
48
48
|
const webhooks_1 = require("../webhooks");
|
|
49
|
+
const bigint_1 = require("./types/bigint");
|
|
49
50
|
const date_1 = require("./types/date");
|
|
50
51
|
const geojson_1 = require("./types/geojson");
|
|
52
|
+
const hash_1 = require("./types/hash");
|
|
51
53
|
const string_or_float_1 = require("./types/string-or-float");
|
|
52
54
|
const void_1 = require("./types/void");
|
|
53
55
|
const add_path_to_validation_error_1 = require("./utils/add-path-to-validation-error");
|
|
54
|
-
const
|
|
55
|
-
const bigint_1 = require("./types/bigint");
|
|
56
|
-
const constants_2 = require("@directus/shared/constants");
|
|
56
|
+
const process_error_1 = __importDefault(require("./utils/process-error"));
|
|
57
57
|
const validationRules = Array.from(graphql_1.specifiedRules);
|
|
58
58
|
if (env_1.default.GRAPHQL_INTROSPECTION === false) {
|
|
59
59
|
validationRules.push(graphql_1.NoSchemaIntrospectionCustomRule);
|
|
@@ -70,9 +70,13 @@ const SYSTEM_DENY_LIST = [
|
|
|
70
70
|
];
|
|
71
71
|
const READ_ONLY = ['directus_activity', 'directus_revisions'];
|
|
72
72
|
class GraphQLService {
|
|
73
|
+
accountability;
|
|
74
|
+
knex;
|
|
75
|
+
schema;
|
|
76
|
+
scope;
|
|
73
77
|
constructor(options) {
|
|
74
|
-
this.accountability =
|
|
75
|
-
this.knex =
|
|
78
|
+
this.accountability = options?.accountability || null;
|
|
79
|
+
this.knex = options?.knex || (0, database_1.default)();
|
|
76
80
|
this.schema = options.schema;
|
|
77
81
|
this.scope = options.scope;
|
|
78
82
|
}
|
|
@@ -80,7 +84,6 @@ class GraphQLService {
|
|
|
80
84
|
* Execute a GraphQL structure
|
|
81
85
|
*/
|
|
82
86
|
async execute({ document, variables, operationName, contextValue, }) {
|
|
83
|
-
var _a;
|
|
84
87
|
const schema = this.getSchema();
|
|
85
88
|
const validationErrors = (0, graphql_1.validate)(schema, document, validationRules).map((validationError) => (0, add_path_to_validation_error_1.addPathToValidationError)(validationError));
|
|
86
89
|
if (validationErrors.length > 0) {
|
|
@@ -99,30 +102,32 @@ class GraphQLService {
|
|
|
99
102
|
catch (err) {
|
|
100
103
|
throw new exceptions_1.InvalidPayloadException('GraphQL execution error.', { graphqlErrors: [err.message] });
|
|
101
104
|
}
|
|
102
|
-
const formattedResult = {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
const formattedResult = {};
|
|
106
|
+
if (result.data)
|
|
107
|
+
formattedResult.data = result.data;
|
|
108
|
+
if (result.errors)
|
|
109
|
+
formattedResult.errors = result.errors.map((error) => (0, process_error_1.default)(this.accountability, error));
|
|
110
|
+
if (result.extensions)
|
|
111
|
+
formattedResult.extensions = result.extensions;
|
|
106
112
|
return formattedResult;
|
|
107
113
|
}
|
|
108
114
|
getSchema(type = 'schema') {
|
|
109
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
110
115
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
111
116
|
const self = this;
|
|
112
117
|
const schemaComposer = new graphql_compose_1.SchemaComposer();
|
|
113
118
|
const schema = {
|
|
114
|
-
read:
|
|
119
|
+
read: this.accountability?.admin === true
|
|
115
120
|
? this.schema
|
|
116
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema,
|
|
117
|
-
create:
|
|
121
|
+
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['read']),
|
|
122
|
+
create: this.accountability?.admin === true
|
|
118
123
|
? this.schema
|
|
119
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema,
|
|
120
|
-
update:
|
|
124
|
+
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['create']),
|
|
125
|
+
update: this.accountability?.admin === true
|
|
121
126
|
? this.schema
|
|
122
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema,
|
|
123
|
-
delete:
|
|
127
|
+
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['update']),
|
|
128
|
+
delete: this.accountability?.admin === true
|
|
124
129
|
? this.schema
|
|
125
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema,
|
|
130
|
+
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['delete']),
|
|
126
131
|
};
|
|
127
132
|
const { ReadCollectionTypes } = getReadableTypes();
|
|
128
133
|
const { CreateCollectionTypes, UpdateCollectionTypes, DeleteCollectionTypes } = getWritableTypes();
|
|
@@ -218,7 +223,6 @@ class GraphQLService {
|
|
|
218
223
|
* as it's fields.
|
|
219
224
|
*/
|
|
220
225
|
function getTypes(action) {
|
|
221
|
-
var _a, _b, _c, _d, _e;
|
|
222
226
|
const CollectionTypes = {};
|
|
223
227
|
const CountFunctions = schemaComposer.createObjectTC({
|
|
224
228
|
name: 'count_functions',
|
|
@@ -283,7 +287,7 @@ class GraphQLService {
|
|
|
283
287
|
// submitted on updates
|
|
284
288
|
if (field.nullable === false &&
|
|
285
289
|
!field.defaultValue &&
|
|
286
|
-
!
|
|
290
|
+
!constants_2.GENERATE_SPECIAL.some((flag) => field.special.includes(flag)) &&
|
|
287
291
|
action !== 'update') {
|
|
288
292
|
type = new graphql_1.GraphQLNonNull(type);
|
|
289
293
|
}
|
|
@@ -348,30 +352,28 @@ class GraphQLService {
|
|
|
348
352
|
if (relation.related_collection) {
|
|
349
353
|
if (SYSTEM_DENY_LIST.includes(relation.related_collection))
|
|
350
354
|
continue;
|
|
351
|
-
|
|
355
|
+
CollectionTypes[relation.collection]?.addFields({
|
|
352
356
|
[relation.field]: {
|
|
353
357
|
type: CollectionTypes[relation.related_collection],
|
|
354
358
|
resolve: (obj, _, __, info) => {
|
|
355
|
-
|
|
356
|
-
return obj[(_b = (_a = info === null || info === void 0 ? void 0 : info.path) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : relation.field];
|
|
359
|
+
return obj[info?.path?.key ?? relation.field];
|
|
357
360
|
},
|
|
358
361
|
},
|
|
359
362
|
});
|
|
360
|
-
if (
|
|
361
|
-
|
|
363
|
+
if (relation.meta?.one_field) {
|
|
364
|
+
CollectionTypes[relation.related_collection]?.addFields({
|
|
362
365
|
[relation.meta.one_field]: {
|
|
363
366
|
type: [CollectionTypes[relation.collection]],
|
|
364
367
|
resolve: (obj, _, __, info) => {
|
|
365
|
-
|
|
366
|
-
return obj[(_b = (_a = info === null || info === void 0 ? void 0 : info.path) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : relation.meta.one_field];
|
|
368
|
+
return obj[info?.path?.key ?? relation.meta.one_field];
|
|
367
369
|
},
|
|
368
370
|
},
|
|
369
371
|
});
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
|
-
else if (
|
|
374
|
+
else if (relation.meta?.one_allowed_collections && action === 'read') {
|
|
373
375
|
// NOTE: There are no union input types in GraphQL, so this only applies to Read actions
|
|
374
|
-
|
|
376
|
+
CollectionTypes[relation.collection]?.addFields({
|
|
375
377
|
[relation.field]: {
|
|
376
378
|
type: new graphql_1.GraphQLUnionType({
|
|
377
379
|
name: `${relation.collection}_${relation.field}_union`,
|
|
@@ -393,8 +395,7 @@ class GraphQLService {
|
|
|
393
395
|
},
|
|
394
396
|
}),
|
|
395
397
|
resolve: (obj, _, __, info) => {
|
|
396
|
-
|
|
397
|
-
return obj[(_b = (_a = info === null || info === void 0 ? void 0 : info.path) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : relation.field];
|
|
398
|
+
return obj[info?.path?.key ?? relation.field];
|
|
398
399
|
},
|
|
399
400
|
},
|
|
400
401
|
});
|
|
@@ -406,7 +407,6 @@ class GraphQLService {
|
|
|
406
407
|
* Create readable types and attach resolvers for each. Also prepares full filter argument structures
|
|
407
408
|
*/
|
|
408
409
|
function getReadableTypes() {
|
|
409
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
410
410
|
const { CollectionTypes: ReadCollectionTypes } = getTypes('read');
|
|
411
411
|
const ReadableCollectionFilterTypes = {};
|
|
412
412
|
const AggregatedFunctions = {};
|
|
@@ -802,28 +802,8 @@ class GraphQLService {
|
|
|
802
802
|
name: `${collection.collection}_aggregated`,
|
|
803
803
|
fields: AggregateMethods[collection.collection],
|
|
804
804
|
});
|
|
805
|
-
|
|
805
|
+
const resolver = {
|
|
806
806
|
name: collection.collection,
|
|
807
|
-
args: collection.singleton
|
|
808
|
-
? undefined
|
|
809
|
-
: {
|
|
810
|
-
filter: ReadableCollectionFilterTypes[collection.collection],
|
|
811
|
-
sort: {
|
|
812
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
813
|
-
},
|
|
814
|
-
limit: {
|
|
815
|
-
type: graphql_1.GraphQLInt,
|
|
816
|
-
},
|
|
817
|
-
offset: {
|
|
818
|
-
type: graphql_1.GraphQLInt,
|
|
819
|
-
},
|
|
820
|
-
page: {
|
|
821
|
-
type: graphql_1.GraphQLInt,
|
|
822
|
-
},
|
|
823
|
-
search: {
|
|
824
|
-
type: graphql_1.GraphQLString,
|
|
825
|
-
},
|
|
826
|
-
},
|
|
827
807
|
type: collection.singleton
|
|
828
808
|
? ReadCollectionTypes[collection.collection]
|
|
829
809
|
: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType()))),
|
|
@@ -832,7 +812,28 @@ class GraphQLService {
|
|
|
832
812
|
context.data = result;
|
|
833
813
|
return result;
|
|
834
814
|
},
|
|
835
|
-
}
|
|
815
|
+
};
|
|
816
|
+
if (collection.singleton === false) {
|
|
817
|
+
resolver.args = {
|
|
818
|
+
filter: ReadableCollectionFilterTypes[collection.collection],
|
|
819
|
+
sort: {
|
|
820
|
+
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
821
|
+
},
|
|
822
|
+
limit: {
|
|
823
|
+
type: graphql_1.GraphQLInt,
|
|
824
|
+
},
|
|
825
|
+
offset: {
|
|
826
|
+
type: graphql_1.GraphQLInt,
|
|
827
|
+
},
|
|
828
|
+
page: {
|
|
829
|
+
type: graphql_1.GraphQLInt,
|
|
830
|
+
},
|
|
831
|
+
search: {
|
|
832
|
+
type: graphql_1.GraphQLString,
|
|
833
|
+
},
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
ReadCollectionTypes[collection.collection].addResolver(resolver);
|
|
836
837
|
ReadCollectionTypes[collection.collection].addResolver({
|
|
837
838
|
name: `${collection.collection}_aggregated`,
|
|
838
839
|
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(AggregatedFunctions[collection.collection].getType()))),
|
|
@@ -842,6 +843,12 @@ class GraphQLService {
|
|
|
842
843
|
limit: {
|
|
843
844
|
type: graphql_1.GraphQLInt,
|
|
844
845
|
},
|
|
846
|
+
offset: {
|
|
847
|
+
type: graphql_1.GraphQLInt,
|
|
848
|
+
},
|
|
849
|
+
page: {
|
|
850
|
+
type: graphql_1.GraphQLInt,
|
|
851
|
+
},
|
|
845
852
|
search: {
|
|
846
853
|
type: graphql_1.GraphQLString,
|
|
847
854
|
},
|
|
@@ -874,10 +881,10 @@ class GraphQLService {
|
|
|
874
881
|
if (relation.related_collection) {
|
|
875
882
|
if (SYSTEM_DENY_LIST.includes(relation.related_collection))
|
|
876
883
|
continue;
|
|
877
|
-
|
|
884
|
+
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
|
878
885
|
[relation.field]: ReadableCollectionFilterTypes[relation.related_collection],
|
|
879
886
|
});
|
|
880
|
-
|
|
887
|
+
ReadCollectionTypes[relation.collection]?.addFieldArgs(relation.field, {
|
|
881
888
|
filter: ReadableCollectionFilterTypes[relation.related_collection],
|
|
882
889
|
sort: {
|
|
883
890
|
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
@@ -895,11 +902,11 @@ class GraphQLService {
|
|
|
895
902
|
type: graphql_1.GraphQLString,
|
|
896
903
|
},
|
|
897
904
|
});
|
|
898
|
-
if (
|
|
899
|
-
|
|
905
|
+
if (relation.meta?.one_field) {
|
|
906
|
+
ReadableCollectionFilterTypes[relation.related_collection]?.addFields({
|
|
900
907
|
[relation.meta.one_field]: ReadableCollectionFilterTypes[relation.collection],
|
|
901
908
|
});
|
|
902
|
-
|
|
909
|
+
ReadCollectionTypes[relation.related_collection]?.addFieldArgs(relation.meta.one_field, {
|
|
903
910
|
filter: ReadableCollectionFilterTypes[relation.collection],
|
|
904
911
|
sort: {
|
|
905
912
|
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
@@ -919,10 +926,10 @@ class GraphQLService {
|
|
|
919
926
|
});
|
|
920
927
|
}
|
|
921
928
|
}
|
|
922
|
-
else if (
|
|
923
|
-
|
|
929
|
+
else if (relation.meta?.one_allowed_collections) {
|
|
930
|
+
ReadableCollectionFilterTypes[relation.collection]?.removeField('item');
|
|
924
931
|
for (const collection of relation.meta.one_allowed_collections) {
|
|
925
|
-
|
|
932
|
+
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
|
926
933
|
[`item__${collection}`]: ReadableCollectionFilterTypes[collection],
|
|
927
934
|
});
|
|
928
935
|
}
|
|
@@ -931,7 +938,6 @@ class GraphQLService {
|
|
|
931
938
|
return { ReadCollectionTypes, ReadableCollectionFilterTypes };
|
|
932
939
|
}
|
|
933
940
|
function getWritableTypes() {
|
|
934
|
-
var _a, _b;
|
|
935
941
|
const { CollectionTypes: CreateCollectionTypes } = getTypes('create');
|
|
936
942
|
const { CollectionTypes: UpdateCollectionTypes } = getTypes('update');
|
|
937
943
|
const DeleteCollectionTypes = {};
|
|
@@ -943,18 +949,21 @@ class GraphQLService {
|
|
|
943
949
|
if (collection.collection in CreateCollectionTypes === false)
|
|
944
950
|
continue;
|
|
945
951
|
const collectionIsReadable = collection.collection in ReadCollectionTypes;
|
|
946
|
-
const creatableFields =
|
|
952
|
+
const creatableFields = CreateCollectionTypes[collection.collection]?.getFields() || {};
|
|
947
953
|
if (Object.keys(creatableFields).length > 0) {
|
|
948
|
-
|
|
954
|
+
const resolverDefinition = {
|
|
949
955
|
name: `create_${collection.collection}_items`,
|
|
950
956
|
type: collectionIsReadable
|
|
951
957
|
? new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType())))
|
|
952
958
|
: graphql_1.GraphQLBoolean,
|
|
953
|
-
args: collectionIsReadable
|
|
954
|
-
? ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs()
|
|
955
|
-
: undefined,
|
|
956
959
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
957
|
-
}
|
|
960
|
+
};
|
|
961
|
+
if (collectionIsReadable) {
|
|
962
|
+
resolverDefinition.args = ReadCollectionTypes[collection.collection]
|
|
963
|
+
.getResolver(collection.collection)
|
|
964
|
+
.getArgs();
|
|
965
|
+
}
|
|
966
|
+
CreateCollectionTypes[collection.collection].addResolver(resolverDefinition);
|
|
958
967
|
CreateCollectionTypes[collection.collection].addResolver({
|
|
959
968
|
name: `create_${collection.collection}_item`,
|
|
960
969
|
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
@@ -984,7 +993,7 @@ class GraphQLService {
|
|
|
984
993
|
if (collection.collection in UpdateCollectionTypes === false)
|
|
985
994
|
continue;
|
|
986
995
|
const collectionIsReadable = collection.collection in ReadCollectionTypes;
|
|
987
|
-
const updatableFields =
|
|
996
|
+
const updatableFields = UpdateCollectionTypes[collection.collection]?.getFields() || {};
|
|
988
997
|
if (Object.keys(updatableFields).length > 0) {
|
|
989
998
|
if (collection.singleton) {
|
|
990
999
|
UpdateCollectionTypes[collection.collection].addResolver({
|
|
@@ -1076,11 +1085,10 @@ class GraphQLService {
|
|
|
1076
1085
|
* Directus' query structure which is then executed by the services.
|
|
1077
1086
|
*/
|
|
1078
1087
|
async resolveQuery(info) {
|
|
1079
|
-
var _a, _b, _c, _d;
|
|
1080
1088
|
let collection = info.fieldName;
|
|
1081
1089
|
if (this.scope === 'system')
|
|
1082
1090
|
collection = `directus_${collection}`;
|
|
1083
|
-
const selections = this.replaceFragmentsInSelections(
|
|
1091
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
1084
1092
|
if (!selections)
|
|
1085
1093
|
return null;
|
|
1086
1094
|
const args = this.parseArgs(info.fieldNodes[0].arguments || [], info.variableValues);
|
|
@@ -1110,18 +1118,18 @@ class GraphQLService {
|
|
|
1110
1118
|
query.limit = 1;
|
|
1111
1119
|
}
|
|
1112
1120
|
// Transform count(a.b.c) into a.b.count(c)
|
|
1113
|
-
if (
|
|
1121
|
+
if (query.fields?.length) {
|
|
1114
1122
|
for (let fieldIndex = 0; fieldIndex < query.fields.length; fieldIndex++) {
|
|
1115
1123
|
query.fields[fieldIndex] = (0, utils_1.parseFilterFunctionPath)(query.fields[fieldIndex]);
|
|
1116
1124
|
}
|
|
1117
1125
|
}
|
|
1118
1126
|
const result = await this.read(collection, query);
|
|
1119
1127
|
if (args.id) {
|
|
1120
|
-
return
|
|
1128
|
+
return result?.[0] || null;
|
|
1121
1129
|
}
|
|
1122
1130
|
if (query.group) {
|
|
1123
1131
|
// for every entry in result add a group field based on query.group;
|
|
1124
|
-
const aggregateKeys = Object.keys(
|
|
1132
|
+
const aggregateKeys = Object.keys(query.aggregate ?? {});
|
|
1125
1133
|
result.map((field) => {
|
|
1126
1134
|
field.group = (0, lodash_1.omit)(field, aggregateKeys);
|
|
1127
1135
|
});
|
|
@@ -1129,12 +1137,11 @@ class GraphQLService {
|
|
|
1129
1137
|
return result;
|
|
1130
1138
|
}
|
|
1131
1139
|
async resolveMutation(args, info) {
|
|
1132
|
-
var _a, _b;
|
|
1133
1140
|
const action = info.fieldName.split('_')[0];
|
|
1134
1141
|
let collection = info.fieldName.substring(action.length + 1);
|
|
1135
1142
|
if (this.scope === 'system')
|
|
1136
1143
|
collection = `directus_${collection}`;
|
|
1137
|
-
const selections = this.replaceFragmentsInSelections(
|
|
1144
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
1138
1145
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
1139
1146
|
const singleton = collection.endsWith('_batch') === false &&
|
|
1140
1147
|
collection.endsWith('_items') === false &&
|
|
@@ -1262,12 +1269,11 @@ class GraphQLService {
|
|
|
1262
1269
|
getQuery(rawQuery, selections, variableValues) {
|
|
1263
1270
|
const query = (0, sanitize_query_1.sanitizeQuery)(rawQuery, this.accountability);
|
|
1264
1271
|
const parseAliases = (selections) => {
|
|
1265
|
-
var _a;
|
|
1266
1272
|
const aliases = {};
|
|
1267
1273
|
for (const selection of selections) {
|
|
1268
1274
|
if (selection.kind !== 'Field')
|
|
1269
1275
|
continue;
|
|
1270
|
-
if (
|
|
1276
|
+
if (selection.alias?.value) {
|
|
1271
1277
|
aliases[selection.alias.value] = selection.name.value;
|
|
1272
1278
|
}
|
|
1273
1279
|
}
|
|
@@ -1323,7 +1329,7 @@ class GraphQLService {
|
|
|
1323
1329
|
}
|
|
1324
1330
|
}
|
|
1325
1331
|
else {
|
|
1326
|
-
children = parseFields(selection.selectionSet.selections, currentAlias
|
|
1332
|
+
children = parseFields(selection.selectionSet.selections, currentAlias ?? current);
|
|
1327
1333
|
}
|
|
1328
1334
|
fields.push(...children);
|
|
1329
1335
|
}
|
|
@@ -1335,7 +1341,7 @@ class GraphQLService {
|
|
|
1335
1341
|
if (!query.deep)
|
|
1336
1342
|
query.deep = {};
|
|
1337
1343
|
const args = this.parseArgs(selection.arguments, variableValues);
|
|
1338
|
-
(0, lodash_1.set)(query.deep, currentAlias
|
|
1344
|
+
(0, lodash_1.set)(query.deep, currentAlias ?? current, (0, lodash_1.merge)({}, (0, lodash_1.get)(query.deep, currentAlias ?? current), (0, lodash_1.mapKeys)((0, sanitize_query_1.sanitizeQuery)(args, this.accountability), (value, key) => `_${key}`)));
|
|
1339
1345
|
}
|
|
1340
1346
|
}
|
|
1341
1347
|
}
|
|
@@ -1343,7 +1349,8 @@ class GraphQLService {
|
|
|
1343
1349
|
};
|
|
1344
1350
|
query.alias = parseAliases(selections);
|
|
1345
1351
|
query.fields = parseFields(selections);
|
|
1346
|
-
|
|
1352
|
+
if (query.filter)
|
|
1353
|
+
query.filter = this.replaceFuncs(query.filter);
|
|
1347
1354
|
query.deep = this.replaceFuncs(query.deep);
|
|
1348
1355
|
(0, validate_query_1.validateQuery)(query);
|
|
1349
1356
|
return query;
|
|
@@ -1352,7 +1359,6 @@ class GraphQLService {
|
|
|
1352
1359
|
* Resolve the aggregation query based on the requested aggregated fields
|
|
1353
1360
|
*/
|
|
1354
1361
|
getAggregateQuery(rawQuery, selections) {
|
|
1355
|
-
var _a, _b;
|
|
1356
1362
|
const query = (0, sanitize_query_1.sanitizeQuery)(rawQuery, this.accountability);
|
|
1357
1363
|
query.aggregate = {};
|
|
1358
1364
|
for (let aggregationGroup of selections) {
|
|
@@ -1364,12 +1370,17 @@ class GraphQLService {
|
|
|
1364
1370
|
continue;
|
|
1365
1371
|
const aggregateProperty = aggregationGroup.name.value;
|
|
1366
1372
|
query.aggregate[aggregateProperty] =
|
|
1367
|
-
|
|
1373
|
+
aggregationGroup.selectionSet?.selections
|
|
1374
|
+
// filter out graphql pointers, like __typename
|
|
1375
|
+
.filter((selectionNode) => !selectionNode?.name.value.startsWith('__'))
|
|
1376
|
+
.map((selectionNode) => {
|
|
1368
1377
|
selectionNode = selectionNode;
|
|
1369
1378
|
return selectionNode.name.value;
|
|
1370
|
-
})
|
|
1379
|
+
}) ?? [];
|
|
1380
|
+
}
|
|
1381
|
+
if (query.filter) {
|
|
1382
|
+
query.filter = this.replaceFuncs(query.filter);
|
|
1371
1383
|
}
|
|
1372
|
-
query.filter = this.replaceFuncs(query.filter);
|
|
1373
1384
|
(0, validate_query_1.validateQuery)(query);
|
|
1374
1385
|
return query;
|
|
1375
1386
|
}
|
|
@@ -1377,19 +1388,17 @@ class GraphQLService {
|
|
|
1377
1388
|
* Replace functions from GraphQL format to Directus-Filter format
|
|
1378
1389
|
*/
|
|
1379
1390
|
replaceFuncs(filter) {
|
|
1380
|
-
if (!filter)
|
|
1381
|
-
return filter;
|
|
1382
1391
|
return replaceFuncDeep(filter);
|
|
1383
1392
|
function replaceFuncDeep(filter) {
|
|
1384
1393
|
return (0, lodash_1.transform)(filter, (result, value, key) => {
|
|
1385
|
-
const isFunctionKey = typeof key === 'string' && key.endsWith('_func') &&
|
|
1394
|
+
const isFunctionKey = typeof key === 'string' && key.endsWith('_func') && constants_1.FUNCTIONS.includes(Object.keys(value)[0]);
|
|
1386
1395
|
if (isFunctionKey) {
|
|
1387
1396
|
const functionName = Object.keys(value)[0];
|
|
1388
1397
|
const fieldName = key.slice(0, -5);
|
|
1389
1398
|
result[`${functionName}(${fieldName})`] = Object.values(value)[0];
|
|
1390
1399
|
}
|
|
1391
1400
|
else {
|
|
1392
|
-
result[key] =
|
|
1401
|
+
result[key] = value?.constructor === Object || value?.constructor === Array ? replaceFuncDeep(value) : value;
|
|
1393
1402
|
}
|
|
1394
1403
|
});
|
|
1395
1404
|
}
|
|
@@ -1469,7 +1478,6 @@ class GraphQLService {
|
|
|
1469
1478
|
return result;
|
|
1470
1479
|
}
|
|
1471
1480
|
injectSystemResolvers(schemaComposer, { CreateCollectionTypes, ReadCollectionTypes, UpdateCollectionTypes, DeleteCollectionTypes, }, schema) {
|
|
1472
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1473
1481
|
const AuthTokens = schemaComposer.createObjectTC({
|
|
1474
1482
|
name: 'auth_tokens',
|
|
1475
1483
|
fields: {
|
|
@@ -1497,7 +1505,7 @@ class GraphQLService {
|
|
|
1497
1505
|
custom_css: { type: graphql_1.GraphQLString },
|
|
1498
1506
|
},
|
|
1499
1507
|
});
|
|
1500
|
-
if (
|
|
1508
|
+
if (this.accountability?.admin === true) {
|
|
1501
1509
|
ServerInfo.addFields({
|
|
1502
1510
|
directus: {
|
|
1503
1511
|
type: new graphql_1.GraphQLObjectType({
|
|
@@ -1584,11 +1592,10 @@ class GraphQLService {
|
|
|
1584
1592
|
}),
|
|
1585
1593
|
},
|
|
1586
1594
|
resolve: async (_, args) => {
|
|
1587
|
-
var _a;
|
|
1588
1595
|
const service = new GraphQLService({
|
|
1589
1596
|
schema: this.schema,
|
|
1590
1597
|
accountability: this.accountability,
|
|
1591
|
-
scope:
|
|
1598
|
+
scope: args.scope ?? 'items',
|
|
1592
1599
|
});
|
|
1593
1600
|
return service.getSchema('sdl');
|
|
1594
1601
|
},
|
|
@@ -1614,7 +1621,7 @@ class GraphQLService {
|
|
|
1614
1621
|
accountability: this.accountability,
|
|
1615
1622
|
schema: this.schema,
|
|
1616
1623
|
});
|
|
1617
|
-
return await service.
|
|
1624
|
+
return await service.health();
|
|
1618
1625
|
},
|
|
1619
1626
|
},
|
|
1620
1627
|
});
|
|
@@ -1640,24 +1647,26 @@ class GraphQLService {
|
|
|
1640
1647
|
otp: graphql_1.GraphQLString,
|
|
1641
1648
|
},
|
|
1642
1649
|
resolve: async (_, args, { req, res }) => {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
ip
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
+
const accountability = { role: null };
|
|
1651
|
+
if (req?.ip)
|
|
1652
|
+
accountability.ip = req.ip;
|
|
1653
|
+
const userAgent = req?.get('user-agent');
|
|
1654
|
+
if (userAgent)
|
|
1655
|
+
accountability.userAgent = userAgent;
|
|
1656
|
+
const origin = req?.get('origin');
|
|
1657
|
+
if (origin)
|
|
1658
|
+
accountability.origin = origin;
|
|
1650
1659
|
const authenticationService = new authentication_1.AuthenticationService({
|
|
1651
1660
|
accountability: accountability,
|
|
1652
1661
|
schema: this.schema,
|
|
1653
1662
|
});
|
|
1654
|
-
const result = await authenticationService.login(
|
|
1663
|
+
const result = await authenticationService.login(constants_2.DEFAULT_AUTH_PROVIDER, args, args?.otp);
|
|
1655
1664
|
if (args.mode === 'cookie') {
|
|
1656
|
-
res
|
|
1665
|
+
res?.cookie(env_1.default.REFRESH_TOKEN_COOKIE_NAME, result.refreshToken, {
|
|
1657
1666
|
httpOnly: true,
|
|
1658
1667
|
domain: env_1.default.REFRESH_TOKEN_COOKIE_DOMAIN,
|
|
1659
|
-
maxAge: (0,
|
|
1660
|
-
secure:
|
|
1668
|
+
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default.REFRESH_TOKEN_TTL),
|
|
1669
|
+
secure: env_1.default.REFRESH_TOKEN_COOKIE_SECURE ?? false,
|
|
1661
1670
|
sameSite: env_1.default.REFRESH_TOKEN_COOKIE_SAME_SITE || 'strict',
|
|
1662
1671
|
});
|
|
1663
1672
|
}
|
|
@@ -1675,28 +1684,30 @@ class GraphQLService {
|
|
|
1675
1684
|
mode: AuthMode,
|
|
1676
1685
|
},
|
|
1677
1686
|
resolve: async (_, args, { req, res }) => {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
ip
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1687
|
+
const accountability = { role: null };
|
|
1688
|
+
if (req?.ip)
|
|
1689
|
+
accountability.ip = req.ip;
|
|
1690
|
+
const userAgent = req?.get('user-agent');
|
|
1691
|
+
if (userAgent)
|
|
1692
|
+
accountability.userAgent = userAgent;
|
|
1693
|
+
const origin = req?.get('origin');
|
|
1694
|
+
if (origin)
|
|
1695
|
+
accountability.origin = origin;
|
|
1685
1696
|
const authenticationService = new authentication_1.AuthenticationService({
|
|
1686
1697
|
accountability: accountability,
|
|
1687
1698
|
schema: this.schema,
|
|
1688
1699
|
});
|
|
1689
|
-
const currentRefreshToken = args.refresh_token ||
|
|
1700
|
+
const currentRefreshToken = args.refresh_token || req?.cookies[env_1.default.REFRESH_TOKEN_COOKIE_NAME];
|
|
1690
1701
|
if (!currentRefreshToken) {
|
|
1691
1702
|
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1692
1703
|
}
|
|
1693
1704
|
const result = await authenticationService.refresh(currentRefreshToken);
|
|
1694
1705
|
if (args.mode === 'cookie') {
|
|
1695
|
-
res
|
|
1706
|
+
res?.cookie(env_1.default.REFRESH_TOKEN_COOKIE_NAME, result.refreshToken, {
|
|
1696
1707
|
httpOnly: true,
|
|
1697
1708
|
domain: env_1.default.REFRESH_TOKEN_COOKIE_DOMAIN,
|
|
1698
|
-
maxAge: (0,
|
|
1699
|
-
secure:
|
|
1709
|
+
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default.REFRESH_TOKEN_TTL),
|
|
1710
|
+
secure: env_1.default.REFRESH_TOKEN_COOKIE_SECURE ?? false,
|
|
1700
1711
|
sameSite: env_1.default.REFRESH_TOKEN_COOKIE_SAME_SITE || 'strict',
|
|
1701
1712
|
});
|
|
1702
1713
|
}
|
|
@@ -1713,17 +1724,20 @@ class GraphQLService {
|
|
|
1713
1724
|
refresh_token: graphql_1.GraphQLString,
|
|
1714
1725
|
},
|
|
1715
1726
|
resolve: async (_, args, { req }) => {
|
|
1716
|
-
const accountability = {
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1727
|
+
const accountability = { role: null };
|
|
1728
|
+
if (req?.ip)
|
|
1729
|
+
accountability.ip = req.ip;
|
|
1730
|
+
const userAgent = req?.get('user-agent');
|
|
1731
|
+
if (userAgent)
|
|
1732
|
+
accountability.userAgent = userAgent;
|
|
1733
|
+
const origin = req?.get('origin');
|
|
1734
|
+
if (origin)
|
|
1735
|
+
accountability.origin = origin;
|
|
1722
1736
|
const authenticationService = new authentication_1.AuthenticationService({
|
|
1723
1737
|
accountability: accountability,
|
|
1724
1738
|
schema: this.schema,
|
|
1725
1739
|
});
|
|
1726
|
-
const currentRefreshToken = args.refresh_token ||
|
|
1740
|
+
const currentRefreshToken = args.refresh_token || req?.cookies[env_1.default.REFRESH_TOKEN_COOKIE_NAME];
|
|
1727
1741
|
if (!currentRefreshToken) {
|
|
1728
1742
|
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1729
1743
|
}
|
|
@@ -1738,12 +1752,15 @@ class GraphQLService {
|
|
|
1738
1752
|
reset_url: graphql_1.GraphQLString,
|
|
1739
1753
|
},
|
|
1740
1754
|
resolve: async (_, args, { req }) => {
|
|
1741
|
-
const accountability = {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1755
|
+
const accountability = { role: null };
|
|
1756
|
+
if (req?.ip)
|
|
1757
|
+
accountability.ip = req.ip;
|
|
1758
|
+
const userAgent = req?.get('user-agent');
|
|
1759
|
+
if (userAgent)
|
|
1760
|
+
accountability.userAgent = userAgent;
|
|
1761
|
+
const origin = req?.get('origin');
|
|
1762
|
+
if (origin)
|
|
1763
|
+
accountability.origin = origin;
|
|
1747
1764
|
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1748
1765
|
try {
|
|
1749
1766
|
await service.requestPasswordReset(args.email, args.reset_url || null);
|
|
@@ -1763,12 +1780,15 @@ class GraphQLService {
|
|
|
1763
1780
|
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1764
1781
|
},
|
|
1765
1782
|
resolve: async (_, args, { req }) => {
|
|
1766
|
-
const accountability = {
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1783
|
+
const accountability = { role: null };
|
|
1784
|
+
if (req?.ip)
|
|
1785
|
+
accountability.ip = req.ip;
|
|
1786
|
+
const userAgent = req?.get('user-agent');
|
|
1787
|
+
if (userAgent)
|
|
1788
|
+
accountability.userAgent = userAgent;
|
|
1789
|
+
const origin = req?.get('origin');
|
|
1790
|
+
if (origin)
|
|
1791
|
+
accountability.origin = origin;
|
|
1772
1792
|
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1773
1793
|
await service.resetPassword(args.token, args.password);
|
|
1774
1794
|
return true;
|
|
@@ -1786,8 +1806,7 @@ class GraphQLService {
|
|
|
1786
1806
|
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1787
1807
|
},
|
|
1788
1808
|
resolve: async (_, args) => {
|
|
1789
|
-
|
|
1790
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
1809
|
+
if (!this.accountability?.user)
|
|
1791
1810
|
return null;
|
|
1792
1811
|
const service = new tfa_1.TFAService({
|
|
1793
1812
|
accountability: this.accountability,
|
|
@@ -1809,8 +1828,7 @@ class GraphQLService {
|
|
|
1809
1828
|
secret: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1810
1829
|
},
|
|
1811
1830
|
resolve: async (_, args) => {
|
|
1812
|
-
|
|
1813
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
1831
|
+
if (!this.accountability?.user)
|
|
1814
1832
|
return null;
|
|
1815
1833
|
const service = new tfa_1.TFAService({
|
|
1816
1834
|
accountability: this.accountability,
|
|
@@ -1826,8 +1844,7 @@ class GraphQLService {
|
|
|
1826
1844
|
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1827
1845
|
},
|
|
1828
1846
|
resolve: async (_, args) => {
|
|
1829
|
-
|
|
1830
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
1847
|
+
if (!this.accountability?.user)
|
|
1831
1848
|
return null;
|
|
1832
1849
|
const service = new tfa_1.TFAService({
|
|
1833
1850
|
accountability: this.accountability,
|
|
@@ -1894,12 +1911,11 @@ class GraphQLService {
|
|
|
1894
1911
|
utils_cache_clear: {
|
|
1895
1912
|
type: void_1.GraphQLVoid,
|
|
1896
1913
|
resolve: async () => {
|
|
1897
|
-
|
|
1898
|
-
if (((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.admin) !== true) {
|
|
1914
|
+
if (this.accountability?.admin !== true) {
|
|
1899
1915
|
throw new exceptions_1.ForbiddenException();
|
|
1900
1916
|
}
|
|
1901
1917
|
const { cache } = (0, cache_1.getCache)();
|
|
1902
|
-
await
|
|
1918
|
+
await cache?.clear();
|
|
1903
1919
|
await (0, cache_1.clearSystemCache)();
|
|
1904
1920
|
return;
|
|
1905
1921
|
},
|
|
@@ -2114,7 +2130,7 @@ class GraphQLService {
|
|
|
2114
2130
|
},
|
|
2115
2131
|
});
|
|
2116
2132
|
}
|
|
2117
|
-
if (
|
|
2133
|
+
if (this.accountability?.admin === true) {
|
|
2118
2134
|
schemaComposer.Mutation.addFields({
|
|
2119
2135
|
create_collections_item: {
|
|
2120
2136
|
type: Collection,
|
|
@@ -2290,18 +2306,17 @@ class GraphQLService {
|
|
|
2290
2306
|
users_me: {
|
|
2291
2307
|
type: ReadCollectionTypes['directus_users'],
|
|
2292
2308
|
resolve: async (_, args, __, info) => {
|
|
2293
|
-
|
|
2294
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
2309
|
+
if (!this.accountability?.user)
|
|
2295
2310
|
return null;
|
|
2296
2311
|
const service = new users_1.UsersService({ schema: this.schema, accountability: this.accountability });
|
|
2297
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2312
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2298
2313
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2299
2314
|
return await service.readOne(this.accountability.user, query);
|
|
2300
2315
|
},
|
|
2301
2316
|
},
|
|
2302
2317
|
});
|
|
2303
2318
|
}
|
|
2304
|
-
if ('directus_users' in schema.update.collections &&
|
|
2319
|
+
if ('directus_users' in schema.update.collections && this.accountability?.user) {
|
|
2305
2320
|
schemaComposer.Mutation.addFields({
|
|
2306
2321
|
update_users_me: {
|
|
2307
2322
|
type: ReadCollectionTypes['directus_users'],
|
|
@@ -2309,8 +2324,7 @@ class GraphQLService {
|
|
|
2309
2324
|
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes['directus_users']),
|
|
2310
2325
|
},
|
|
2311
2326
|
resolve: async (_, args, __, info) => {
|
|
2312
|
-
|
|
2313
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
2327
|
+
if (!this.accountability?.user)
|
|
2314
2328
|
return null;
|
|
2315
2329
|
const service = new users_1.UsersService({
|
|
2316
2330
|
schema: this.schema,
|
|
@@ -2318,7 +2332,7 @@ class GraphQLService {
|
|
|
2318
2332
|
});
|
|
2319
2333
|
await service.updateOne(this.accountability.user, args.data);
|
|
2320
2334
|
if ('directus_users' in ReadCollectionTypes) {
|
|
2321
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2335
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2322
2336
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2323
2337
|
return await service.readOne(this.accountability.user, query);
|
|
2324
2338
|
}
|
|
@@ -2330,14 +2344,13 @@ class GraphQLService {
|
|
|
2330
2344
|
if ('directus_activity' in schema.create.collections) {
|
|
2331
2345
|
schemaComposer.Mutation.addFields({
|
|
2332
2346
|
create_comment: {
|
|
2333
|
-
type:
|
|
2347
|
+
type: ReadCollectionTypes['directus_activity'] ?? graphql_1.GraphQLBoolean,
|
|
2334
2348
|
args: {
|
|
2335
2349
|
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2336
2350
|
item: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2337
2351
|
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2338
2352
|
},
|
|
2339
2353
|
resolve: async (_, args, __, info) => {
|
|
2340
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2341
2354
|
const service = new activity_1.ActivityService({
|
|
2342
2355
|
accountability: this.accountability,
|
|
2343
2356
|
schema: this.schema,
|
|
@@ -2345,13 +2358,13 @@ class GraphQLService {
|
|
|
2345
2358
|
const primaryKey = await service.createOne({
|
|
2346
2359
|
...args,
|
|
2347
2360
|
action: types_1.Action.COMMENT,
|
|
2348
|
-
user:
|
|
2349
|
-
ip:
|
|
2350
|
-
user_agent:
|
|
2351
|
-
origin:
|
|
2361
|
+
user: this.accountability?.user,
|
|
2362
|
+
ip: this.accountability?.ip,
|
|
2363
|
+
user_agent: this.accountability?.userAgent,
|
|
2364
|
+
origin: this.accountability?.origin,
|
|
2352
2365
|
});
|
|
2353
2366
|
if ('directus_activity' in ReadCollectionTypes) {
|
|
2354
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2367
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2355
2368
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2356
2369
|
return await service.readOne(primaryKey, query);
|
|
2357
2370
|
}
|
|
@@ -2363,20 +2376,19 @@ class GraphQLService {
|
|
|
2363
2376
|
if ('directus_activity' in schema.update.collections) {
|
|
2364
2377
|
schemaComposer.Mutation.addFields({
|
|
2365
2378
|
update_comment: {
|
|
2366
|
-
type:
|
|
2379
|
+
type: ReadCollectionTypes['directus_activity'] ?? graphql_1.GraphQLBoolean,
|
|
2367
2380
|
args: {
|
|
2368
2381
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2369
2382
|
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2370
2383
|
},
|
|
2371
2384
|
resolve: async (_, args, __, info) => {
|
|
2372
|
-
var _a, _b;
|
|
2373
2385
|
const service = new activity_1.ActivityService({
|
|
2374
2386
|
accountability: this.accountability,
|
|
2375
2387
|
schema: this.schema,
|
|
2376
2388
|
});
|
|
2377
2389
|
const primaryKey = await service.updateOne(args.id, { comment: args.comment });
|
|
2378
2390
|
if ('directus_activity' in ReadCollectionTypes) {
|
|
2379
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2391
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2380
2392
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2381
2393
|
return await service.readOne(primaryKey, query);
|
|
2382
2394
|
}
|
|
@@ -2406,20 +2418,19 @@ class GraphQLService {
|
|
|
2406
2418
|
if ('directus_files' in schema.create.collections) {
|
|
2407
2419
|
schemaComposer.Mutation.addFields({
|
|
2408
2420
|
import_file: {
|
|
2409
|
-
type:
|
|
2421
|
+
type: ReadCollectionTypes['directus_files'] ?? graphql_1.GraphQLBoolean,
|
|
2410
2422
|
args: {
|
|
2411
2423
|
url: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2412
2424
|
data: (0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes['directus_files']).setTypeName('create_directus_files_input'),
|
|
2413
2425
|
},
|
|
2414
2426
|
resolve: async (_, args, __, info) => {
|
|
2415
|
-
var _a, _b;
|
|
2416
2427
|
const service = new files_1.FilesService({
|
|
2417
2428
|
accountability: this.accountability,
|
|
2418
2429
|
schema: this.schema,
|
|
2419
2430
|
});
|
|
2420
2431
|
const primaryKey = await service.importOne(args.url, args.data);
|
|
2421
2432
|
if ('directus_files' in ReadCollectionTypes) {
|
|
2422
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2433
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2423
2434
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2424
2435
|
return await service.readOne(primaryKey, query);
|
|
2425
2436
|
}
|