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
|
@@ -4,6 +4,7 @@ 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"));
|
|
@@ -11,13 +12,14 @@ const graphql_1 = require("graphql");
|
|
|
11
12
|
const graphql_compose_1 = require("graphql-compose");
|
|
12
13
|
const lodash_1 = require("lodash");
|
|
13
14
|
const cache_1 = require("../../cache");
|
|
14
|
-
const
|
|
15
|
+
const constants_2 = require("../../constants");
|
|
15
16
|
const database_1 = __importDefault(require("../../database"));
|
|
16
17
|
const env_1 = __importDefault(require("../../env"));
|
|
17
18
|
const exceptions_1 = require("../../exceptions");
|
|
18
19
|
const extensions_1 = require("../../extensions");
|
|
19
20
|
const generate_hash_1 = require("../../utils/generate-hash");
|
|
20
21
|
const get_graphql_type_1 = require("../../utils/get-graphql-type");
|
|
22
|
+
const get_milliseconds_1 = require("../../utils/get-milliseconds");
|
|
21
23
|
const reduce_schema_1 = require("../../utils/reduce-schema");
|
|
22
24
|
const sanitize_query_1 = require("../../utils/sanitize-query");
|
|
23
25
|
const validate_query_1 = require("../../utils/validate-query");
|
|
@@ -44,18 +46,16 @@ const tfa_1 = require("../tfa");
|
|
|
44
46
|
const users_1 = require("../users");
|
|
45
47
|
const utils_2 = require("../utils");
|
|
46
48
|
const webhooks_1 = require("../webhooks");
|
|
47
|
-
const
|
|
49
|
+
const bigint_1 = require("./types/bigint");
|
|
48
50
|
const date_1 = require("./types/date");
|
|
49
51
|
const geojson_1 = require("./types/geojson");
|
|
52
|
+
const hash_1 = require("./types/hash");
|
|
50
53
|
const string_or_float_1 = require("./types/string-or-float");
|
|
51
54
|
const void_1 = require("./types/void");
|
|
52
|
-
const constants_2 = require("@directus/shared/constants");
|
|
53
|
-
const get_milliseconds_1 = require("../../utils/get-milliseconds");
|
|
54
|
-
const bigint_1 = require("./types/bigint");
|
|
55
|
-
const hash_1 = require("./types/hash");
|
|
56
55
|
const add_path_to_validation_error_1 = require("./utils/add-path-to-validation-error");
|
|
56
|
+
const process_error_1 = __importDefault(require("./utils/process-error"));
|
|
57
57
|
const validationRules = Array.from(graphql_1.specifiedRules);
|
|
58
|
-
if (env_1.default
|
|
58
|
+
if (env_1.default['GRAPHQL_INTROSPECTION'] === false) {
|
|
59
59
|
validationRules.push(graphql_1.NoSchemaIntrospectionCustomRule);
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -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();
|
|
@@ -204,8 +209,8 @@ class GraphQLService {
|
|
|
204
209
|
.filter((collection) => READ_ONLY.includes(collection.collection) === false)
|
|
205
210
|
.reduce((acc, collection) => {
|
|
206
211
|
const collectionName = this.scope === 'items' ? collection.collection : collection.collection.substring(9);
|
|
207
|
-
acc[`delete_${collectionName}_items`] = DeleteCollectionTypes
|
|
208
|
-
acc[`delete_${collectionName}_item`] = DeleteCollectionTypes
|
|
212
|
+
acc[`delete_${collectionName}_items`] = DeleteCollectionTypes['many'].getResolver(`delete_${collection.collection}_items`);
|
|
213
|
+
acc[`delete_${collectionName}_item`] = DeleteCollectionTypes['one'].getResolver(`delete_${collection.collection}_item`);
|
|
209
214
|
return acc;
|
|
210
215
|
}, {}));
|
|
211
216
|
}
|
|
@@ -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`,
|
|
@@ -384,7 +386,7 @@ class GraphQLService {
|
|
|
384
386
|
currentPath = currentPath.prev;
|
|
385
387
|
}
|
|
386
388
|
path = path.reverse().slice(0, -1);
|
|
387
|
-
let parent = context
|
|
389
|
+
let parent = context['data'];
|
|
388
390
|
for (const pathPart of path) {
|
|
389
391
|
parent = parent[pathPart];
|
|
390
392
|
}
|
|
@@ -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,37 +802,38 @@ 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()))),
|
|
830
810
|
resolve: async ({ info, context }) => {
|
|
831
811
|
const result = await self.resolveQuery(info);
|
|
832
|
-
context
|
|
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()))),
|
|
@@ -857,7 +858,7 @@ class GraphQLService {
|
|
|
857
858
|
},
|
|
858
859
|
resolve: async ({ info, context }) => {
|
|
859
860
|
const result = await self.resolveQuery(info);
|
|
860
|
-
context
|
|
861
|
+
context['data'] = result;
|
|
861
862
|
return result;
|
|
862
863
|
},
|
|
863
864
|
});
|
|
@@ -870,7 +871,7 @@ class GraphQLService {
|
|
|
870
871
|
},
|
|
871
872
|
resolve: async ({ info, context }) => {
|
|
872
873
|
const result = await self.resolveQuery(info);
|
|
873
|
-
context
|
|
874
|
+
context['data'] = result;
|
|
874
875
|
return result;
|
|
875
876
|
},
|
|
876
877
|
});
|
|
@@ -880,10 +881,10 @@ class GraphQLService {
|
|
|
880
881
|
if (relation.related_collection) {
|
|
881
882
|
if (SYSTEM_DENY_LIST.includes(relation.related_collection))
|
|
882
883
|
continue;
|
|
883
|
-
|
|
884
|
+
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
|
884
885
|
[relation.field]: ReadableCollectionFilterTypes[relation.related_collection],
|
|
885
886
|
});
|
|
886
|
-
|
|
887
|
+
ReadCollectionTypes[relation.collection]?.addFieldArgs(relation.field, {
|
|
887
888
|
filter: ReadableCollectionFilterTypes[relation.related_collection],
|
|
888
889
|
sort: {
|
|
889
890
|
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
@@ -901,11 +902,11 @@ class GraphQLService {
|
|
|
901
902
|
type: graphql_1.GraphQLString,
|
|
902
903
|
},
|
|
903
904
|
});
|
|
904
|
-
if (
|
|
905
|
-
|
|
905
|
+
if (relation.meta?.one_field) {
|
|
906
|
+
ReadableCollectionFilterTypes[relation.related_collection]?.addFields({
|
|
906
907
|
[relation.meta.one_field]: ReadableCollectionFilterTypes[relation.collection],
|
|
907
908
|
});
|
|
908
|
-
|
|
909
|
+
ReadCollectionTypes[relation.related_collection]?.addFieldArgs(relation.meta.one_field, {
|
|
909
910
|
filter: ReadableCollectionFilterTypes[relation.collection],
|
|
910
911
|
sort: {
|
|
911
912
|
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
@@ -925,10 +926,10 @@ class GraphQLService {
|
|
|
925
926
|
});
|
|
926
927
|
}
|
|
927
928
|
}
|
|
928
|
-
else if (
|
|
929
|
-
|
|
929
|
+
else if (relation.meta?.one_allowed_collections) {
|
|
930
|
+
ReadableCollectionFilterTypes[relation.collection]?.removeField('item');
|
|
930
931
|
for (const collection of relation.meta.one_allowed_collections) {
|
|
931
|
-
|
|
932
|
+
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
|
932
933
|
[`item__${collection}`]: ReadableCollectionFilterTypes[collection],
|
|
933
934
|
});
|
|
934
935
|
}
|
|
@@ -937,7 +938,6 @@ class GraphQLService {
|
|
|
937
938
|
return { ReadCollectionTypes, ReadableCollectionFilterTypes };
|
|
938
939
|
}
|
|
939
940
|
function getWritableTypes() {
|
|
940
|
-
var _a, _b;
|
|
941
941
|
const { CollectionTypes: CreateCollectionTypes } = getTypes('create');
|
|
942
942
|
const { CollectionTypes: UpdateCollectionTypes } = getTypes('update');
|
|
943
943
|
const DeleteCollectionTypes = {};
|
|
@@ -949,18 +949,21 @@ class GraphQLService {
|
|
|
949
949
|
if (collection.collection in CreateCollectionTypes === false)
|
|
950
950
|
continue;
|
|
951
951
|
const collectionIsReadable = collection.collection in ReadCollectionTypes;
|
|
952
|
-
const creatableFields =
|
|
952
|
+
const creatableFields = CreateCollectionTypes[collection.collection]?.getFields() || {};
|
|
953
953
|
if (Object.keys(creatableFields).length > 0) {
|
|
954
|
-
|
|
954
|
+
const resolverDefinition = {
|
|
955
955
|
name: `create_${collection.collection}_items`,
|
|
956
956
|
type: collectionIsReadable
|
|
957
957
|
? new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType())))
|
|
958
958
|
: graphql_1.GraphQLBoolean,
|
|
959
|
-
args: collectionIsReadable
|
|
960
|
-
? ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs()
|
|
961
|
-
: undefined,
|
|
962
959
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
963
|
-
}
|
|
960
|
+
};
|
|
961
|
+
if (collectionIsReadable) {
|
|
962
|
+
resolverDefinition.args = ReadCollectionTypes[collection.collection]
|
|
963
|
+
.getResolver(collection.collection)
|
|
964
|
+
.getArgs();
|
|
965
|
+
}
|
|
966
|
+
CreateCollectionTypes[collection.collection].addResolver(resolverDefinition);
|
|
964
967
|
CreateCollectionTypes[collection.collection].addResolver({
|
|
965
968
|
name: `create_${collection.collection}_item`,
|
|
966
969
|
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
@@ -990,7 +993,7 @@ class GraphQLService {
|
|
|
990
993
|
if (collection.collection in UpdateCollectionTypes === false)
|
|
991
994
|
continue;
|
|
992
995
|
const collectionIsReadable = collection.collection in ReadCollectionTypes;
|
|
993
|
-
const updatableFields =
|
|
996
|
+
const updatableFields = UpdateCollectionTypes[collection.collection]?.getFields() || {};
|
|
994
997
|
if (Object.keys(updatableFields).length > 0) {
|
|
995
998
|
if (collection.singleton) {
|
|
996
999
|
UpdateCollectionTypes[collection.collection].addResolver({
|
|
@@ -1044,30 +1047,30 @@ class GraphQLService {
|
|
|
1044
1047
|
}
|
|
1045
1048
|
}
|
|
1046
1049
|
}
|
|
1047
|
-
DeleteCollectionTypes
|
|
1050
|
+
DeleteCollectionTypes['many'] = schemaComposer.createObjectTC({
|
|
1048
1051
|
name: `delete_many`,
|
|
1049
1052
|
fields: {
|
|
1050
1053
|
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1051
1054
|
},
|
|
1052
1055
|
});
|
|
1053
|
-
DeleteCollectionTypes
|
|
1056
|
+
DeleteCollectionTypes['one'] = schemaComposer.createObjectTC({
|
|
1054
1057
|
name: `delete_one`,
|
|
1055
1058
|
fields: {
|
|
1056
1059
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1057
1060
|
},
|
|
1058
1061
|
});
|
|
1059
1062
|
for (const collection of Object.values(schema.delete.collections)) {
|
|
1060
|
-
DeleteCollectionTypes
|
|
1063
|
+
DeleteCollectionTypes['many'].addResolver({
|
|
1061
1064
|
name: `delete_${collection.collection}_items`,
|
|
1062
|
-
type: DeleteCollectionTypes
|
|
1065
|
+
type: DeleteCollectionTypes['many'],
|
|
1063
1066
|
args: {
|
|
1064
1067
|
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1065
1068
|
},
|
|
1066
1069
|
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1067
1070
|
});
|
|
1068
|
-
DeleteCollectionTypes
|
|
1071
|
+
DeleteCollectionTypes['one'].addResolver({
|
|
1069
1072
|
name: `delete_${collection.collection}_item`,
|
|
1070
|
-
type: DeleteCollectionTypes
|
|
1073
|
+
type: DeleteCollectionTypes['one'],
|
|
1071
1074
|
args: {
|
|
1072
1075
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1073
1076
|
},
|
|
@@ -1082,11 +1085,10 @@ class GraphQLService {
|
|
|
1082
1085
|
* Directus' query structure which is then executed by the services.
|
|
1083
1086
|
*/
|
|
1084
1087
|
async resolveQuery(info) {
|
|
1085
|
-
var _a, _b, _c, _d;
|
|
1086
1088
|
let collection = info.fieldName;
|
|
1087
1089
|
if (this.scope === 'system')
|
|
1088
1090
|
collection = `directus_${collection}`;
|
|
1089
|
-
const selections = this.replaceFragmentsInSelections(
|
|
1091
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
1090
1092
|
if (!selections)
|
|
1091
1093
|
return null;
|
|
1092
1094
|
const args = this.parseArgs(info.fieldNodes[0].arguments || [], info.variableValues);
|
|
@@ -1102,13 +1104,13 @@ class GraphQLService {
|
|
|
1102
1104
|
collection = collection.slice(0, -6);
|
|
1103
1105
|
}
|
|
1104
1106
|
}
|
|
1105
|
-
if (args
|
|
1107
|
+
if (args['id']) {
|
|
1106
1108
|
query.filter = {
|
|
1107
1109
|
_and: [
|
|
1108
1110
|
query.filter || {},
|
|
1109
1111
|
{
|
|
1110
1112
|
[this.schema.collections[collection].primary]: {
|
|
1111
|
-
_eq: args
|
|
1113
|
+
_eq: args['id'],
|
|
1112
1114
|
},
|
|
1113
1115
|
},
|
|
1114
1116
|
],
|
|
@@ -1116,31 +1118,30 @@ class GraphQLService {
|
|
|
1116
1118
|
query.limit = 1;
|
|
1117
1119
|
}
|
|
1118
1120
|
// Transform count(a.b.c) into a.b.count(c)
|
|
1119
|
-
if (
|
|
1121
|
+
if (query.fields?.length) {
|
|
1120
1122
|
for (let fieldIndex = 0; fieldIndex < query.fields.length; fieldIndex++) {
|
|
1121
1123
|
query.fields[fieldIndex] = (0, utils_1.parseFilterFunctionPath)(query.fields[fieldIndex]);
|
|
1122
1124
|
}
|
|
1123
1125
|
}
|
|
1124
1126
|
const result = await this.read(collection, query);
|
|
1125
|
-
if (args
|
|
1126
|
-
return
|
|
1127
|
+
if (args['id']) {
|
|
1128
|
+
return result?.[0] || null;
|
|
1127
1129
|
}
|
|
1128
1130
|
if (query.group) {
|
|
1129
1131
|
// for every entry in result add a group field based on query.group;
|
|
1130
|
-
const aggregateKeys = Object.keys(
|
|
1131
|
-
result
|
|
1132
|
-
field
|
|
1132
|
+
const aggregateKeys = Object.keys(query.aggregate ?? {});
|
|
1133
|
+
result['map']((field) => {
|
|
1134
|
+
field['group'] = (0, lodash_1.omit)(field, aggregateKeys);
|
|
1133
1135
|
});
|
|
1134
1136
|
}
|
|
1135
1137
|
return result;
|
|
1136
1138
|
}
|
|
1137
1139
|
async resolveMutation(args, info) {
|
|
1138
|
-
var _a, _b;
|
|
1139
1140
|
const action = info.fieldName.split('_')[0];
|
|
1140
1141
|
let collection = info.fieldName.substring(action.length + 1);
|
|
1141
1142
|
if (this.scope === 'system')
|
|
1142
1143
|
collection = `directus_${collection}`;
|
|
1143
|
-
const selections = this.replaceFragmentsInSelections(
|
|
1144
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
1144
1145
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
1145
1146
|
const singleton = collection.endsWith('_batch') === false &&
|
|
1146
1147
|
collection.endsWith('_items') === false &&
|
|
@@ -1155,44 +1156,46 @@ class GraphQLService {
|
|
|
1155
1156
|
if (collection.endsWith('_item'))
|
|
1156
1157
|
collection = collection.slice(0, -5);
|
|
1157
1158
|
if (singleton && action === 'update') {
|
|
1158
|
-
return await this.upsertSingleton(collection, args
|
|
1159
|
+
return await this.upsertSingleton(collection, args['data'], query);
|
|
1159
1160
|
}
|
|
1160
1161
|
const service = this.getService(collection);
|
|
1161
1162
|
const hasQuery = (query.fields || []).length > 0;
|
|
1162
1163
|
try {
|
|
1163
1164
|
if (single) {
|
|
1164
1165
|
if (action === 'create') {
|
|
1165
|
-
const key = await service.createOne(args
|
|
1166
|
+
const key = await service.createOne(args['data']);
|
|
1166
1167
|
return hasQuery ? await service.readOne(key, query) : true;
|
|
1167
1168
|
}
|
|
1168
1169
|
if (action === 'update') {
|
|
1169
|
-
const key = await service.updateOne(args
|
|
1170
|
+
const key = await service.updateOne(args['id'], args['data']);
|
|
1170
1171
|
return hasQuery ? await service.readOne(key, query) : true;
|
|
1171
1172
|
}
|
|
1172
1173
|
if (action === 'delete') {
|
|
1173
|
-
await service.deleteOne(args
|
|
1174
|
-
return { id: args
|
|
1174
|
+
await service.deleteOne(args['id']);
|
|
1175
|
+
return { id: args['id'] };
|
|
1175
1176
|
}
|
|
1177
|
+
return undefined;
|
|
1176
1178
|
}
|
|
1177
1179
|
else {
|
|
1178
1180
|
if (action === 'create') {
|
|
1179
|
-
const keys = await service.createMany(args
|
|
1181
|
+
const keys = await service.createMany(args['data']);
|
|
1180
1182
|
return hasQuery ? await service.readMany(keys, query) : true;
|
|
1181
1183
|
}
|
|
1182
1184
|
if (action === 'update') {
|
|
1183
1185
|
const keys = [];
|
|
1184
1186
|
if (batchUpdate) {
|
|
1185
|
-
keys.push(...(await service.updateBatch(args
|
|
1187
|
+
keys.push(...(await service.updateBatch(args['data'])));
|
|
1186
1188
|
}
|
|
1187
1189
|
else {
|
|
1188
|
-
keys.push(...(await service.updateMany(args
|
|
1190
|
+
keys.push(...(await service.updateMany(args['ids'], args['data'])));
|
|
1189
1191
|
}
|
|
1190
1192
|
return hasQuery ? await service.readMany(keys, query) : true;
|
|
1191
1193
|
}
|
|
1192
1194
|
if (action === 'delete') {
|
|
1193
|
-
const keys = await service.deleteMany(args
|
|
1195
|
+
const keys = await service.deleteMany(args['ids']);
|
|
1194
1196
|
return { ids: keys };
|
|
1195
1197
|
}
|
|
1198
|
+
return undefined;
|
|
1196
1199
|
}
|
|
1197
1200
|
}
|
|
1198
1201
|
catch (err) {
|
|
@@ -1234,7 +1237,7 @@ class GraphQLService {
|
|
|
1234
1237
|
* of arguments
|
|
1235
1238
|
*/
|
|
1236
1239
|
parseArgs(args, variableValues) {
|
|
1237
|
-
if (!args || args
|
|
1240
|
+
if (!args || args['length'] === 0)
|
|
1238
1241
|
return {};
|
|
1239
1242
|
const parse = (node) => {
|
|
1240
1243
|
switch (node.kind) {
|
|
@@ -1258,7 +1261,7 @@ class GraphQLService {
|
|
|
1258
1261
|
return 'value' in node ? node.value : null;
|
|
1259
1262
|
}
|
|
1260
1263
|
};
|
|
1261
|
-
const argsObject = Object.fromEntries(args
|
|
1264
|
+
const argsObject = Object.fromEntries(args['map']((arg) => [arg.name.value, parse(arg.value)]));
|
|
1262
1265
|
return argsObject;
|
|
1263
1266
|
}
|
|
1264
1267
|
/**
|
|
@@ -1268,12 +1271,11 @@ class GraphQLService {
|
|
|
1268
1271
|
getQuery(rawQuery, selections, variableValues) {
|
|
1269
1272
|
const query = (0, sanitize_query_1.sanitizeQuery)(rawQuery, this.accountability);
|
|
1270
1273
|
const parseAliases = (selections) => {
|
|
1271
|
-
var _a;
|
|
1272
1274
|
const aliases = {};
|
|
1273
1275
|
for (const selection of selections) {
|
|
1274
1276
|
if (selection.kind !== 'Field')
|
|
1275
1277
|
continue;
|
|
1276
|
-
if (
|
|
1278
|
+
if (selection.alias?.value) {
|
|
1277
1279
|
aliases[selection.alias.value] = selection.name.value;
|
|
1278
1280
|
}
|
|
1279
1281
|
}
|
|
@@ -1329,7 +1331,7 @@ class GraphQLService {
|
|
|
1329
1331
|
}
|
|
1330
1332
|
}
|
|
1331
1333
|
else {
|
|
1332
|
-
children = parseFields(selection.selectionSet.selections, currentAlias
|
|
1334
|
+
children = parseFields(selection.selectionSet.selections, currentAlias ?? current);
|
|
1333
1335
|
}
|
|
1334
1336
|
fields.push(...children);
|
|
1335
1337
|
}
|
|
@@ -1341,7 +1343,7 @@ class GraphQLService {
|
|
|
1341
1343
|
if (!query.deep)
|
|
1342
1344
|
query.deep = {};
|
|
1343
1345
|
const args = this.parseArgs(selection.arguments, variableValues);
|
|
1344
|
-
(0, lodash_1.set)(query.deep, currentAlias
|
|
1346
|
+
(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}`)));
|
|
1345
1347
|
}
|
|
1346
1348
|
}
|
|
1347
1349
|
}
|
|
@@ -1349,7 +1351,8 @@ class GraphQLService {
|
|
|
1349
1351
|
};
|
|
1350
1352
|
query.alias = parseAliases(selections);
|
|
1351
1353
|
query.fields = parseFields(selections);
|
|
1352
|
-
|
|
1354
|
+
if (query.filter)
|
|
1355
|
+
query.filter = this.replaceFuncs(query.filter);
|
|
1353
1356
|
query.deep = this.replaceFuncs(query.deep);
|
|
1354
1357
|
(0, validate_query_1.validateQuery)(query);
|
|
1355
1358
|
return query;
|
|
@@ -1358,7 +1361,6 @@ class GraphQLService {
|
|
|
1358
1361
|
* Resolve the aggregation query based on the requested aggregated fields
|
|
1359
1362
|
*/
|
|
1360
1363
|
getAggregateQuery(rawQuery, selections) {
|
|
1361
|
-
var _a, _b;
|
|
1362
1364
|
const query = (0, sanitize_query_1.sanitizeQuery)(rawQuery, this.accountability);
|
|
1363
1365
|
query.aggregate = {};
|
|
1364
1366
|
for (let aggregationGroup of selections) {
|
|
@@ -1370,12 +1372,17 @@ class GraphQLService {
|
|
|
1370
1372
|
continue;
|
|
1371
1373
|
const aggregateProperty = aggregationGroup.name.value;
|
|
1372
1374
|
query.aggregate[aggregateProperty] =
|
|
1373
|
-
|
|
1375
|
+
aggregationGroup.selectionSet?.selections
|
|
1376
|
+
// filter out graphql pointers, like __typename
|
|
1377
|
+
.filter((selectionNode) => !selectionNode?.name.value.startsWith('__'))
|
|
1378
|
+
.map((selectionNode) => {
|
|
1374
1379
|
selectionNode = selectionNode;
|
|
1375
1380
|
return selectionNode.name.value;
|
|
1376
|
-
})
|
|
1381
|
+
}) ?? [];
|
|
1382
|
+
}
|
|
1383
|
+
if (query.filter) {
|
|
1384
|
+
query.filter = this.replaceFuncs(query.filter);
|
|
1377
1385
|
}
|
|
1378
|
-
query.filter = this.replaceFuncs(query.filter);
|
|
1379
1386
|
(0, validate_query_1.validateQuery)(query);
|
|
1380
1387
|
return query;
|
|
1381
1388
|
}
|
|
@@ -1383,19 +1390,17 @@ class GraphQLService {
|
|
|
1383
1390
|
* Replace functions from GraphQL format to Directus-Filter format
|
|
1384
1391
|
*/
|
|
1385
1392
|
replaceFuncs(filter) {
|
|
1386
|
-
if (!filter)
|
|
1387
|
-
return filter;
|
|
1388
1393
|
return replaceFuncDeep(filter);
|
|
1389
1394
|
function replaceFuncDeep(filter) {
|
|
1390
1395
|
return (0, lodash_1.transform)(filter, (result, value, key) => {
|
|
1391
|
-
const isFunctionKey = typeof key === 'string' && key.endsWith('_func') &&
|
|
1396
|
+
const isFunctionKey = typeof key === 'string' && key.endsWith('_func') && constants_1.FUNCTIONS.includes(Object.keys(value)[0]);
|
|
1392
1397
|
if (isFunctionKey) {
|
|
1393
1398
|
const functionName = Object.keys(value)[0];
|
|
1394
1399
|
const fieldName = key.slice(0, -5);
|
|
1395
1400
|
result[`${functionName}(${fieldName})`] = Object.values(value)[0];
|
|
1396
1401
|
}
|
|
1397
1402
|
else {
|
|
1398
|
-
result[key] =
|
|
1403
|
+
result[key] = value?.constructor === Object || value?.constructor === Array ? replaceFuncDeep(value) : value;
|
|
1399
1404
|
}
|
|
1400
1405
|
});
|
|
1401
1406
|
}
|
|
@@ -1405,10 +1410,10 @@ class GraphQLService {
|
|
|
1405
1410
|
*/
|
|
1406
1411
|
formatError(error) {
|
|
1407
1412
|
if (Array.isArray(error)) {
|
|
1408
|
-
error[0].extensions
|
|
1413
|
+
error[0].extensions['code'] = error[0].code;
|
|
1409
1414
|
return new graphql_1.GraphQLError(error[0].message, undefined, undefined, undefined, undefined, error[0]);
|
|
1410
1415
|
}
|
|
1411
|
-
error.extensions
|
|
1416
|
+
error.extensions['code'] = error.code;
|
|
1412
1417
|
return new graphql_1.GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
|
|
1413
1418
|
}
|
|
1414
1419
|
/**
|
|
@@ -1475,12 +1480,11 @@ class GraphQLService {
|
|
|
1475
1480
|
return result;
|
|
1476
1481
|
}
|
|
1477
1482
|
injectSystemResolvers(schemaComposer, { CreateCollectionTypes, ReadCollectionTypes, UpdateCollectionTypes, DeleteCollectionTypes, }, schema) {
|
|
1478
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1479
1483
|
const AuthTokens = schemaComposer.createObjectTC({
|
|
1480
1484
|
name: 'auth_tokens',
|
|
1481
1485
|
fields: {
|
|
1482
1486
|
access_token: graphql_1.GraphQLString,
|
|
1483
|
-
expires:
|
|
1487
|
+
expires: bigint_1.GraphQLBigInt,
|
|
1484
1488
|
refresh_token: graphql_1.GraphQLString,
|
|
1485
1489
|
},
|
|
1486
1490
|
});
|
|
@@ -1503,7 +1507,7 @@ class GraphQLService {
|
|
|
1503
1507
|
custom_css: { type: graphql_1.GraphQLString },
|
|
1504
1508
|
},
|
|
1505
1509
|
});
|
|
1506
|
-
if (
|
|
1510
|
+
if (this.accountability?.admin === true) {
|
|
1507
1511
|
ServerInfo.addFields({
|
|
1508
1512
|
directus: {
|
|
1509
1513
|
type: new graphql_1.GraphQLObjectType({
|
|
@@ -1590,11 +1594,10 @@ class GraphQLService {
|
|
|
1590
1594
|
}),
|
|
1591
1595
|
},
|
|
1592
1596
|
resolve: async (_, args) => {
|
|
1593
|
-
var _a;
|
|
1594
1597
|
const service = new GraphQLService({
|
|
1595
1598
|
schema: this.schema,
|
|
1596
1599
|
accountability: this.accountability,
|
|
1597
|
-
scope:
|
|
1600
|
+
scope: args['scope'] ?? 'items',
|
|
1598
1601
|
});
|
|
1599
1602
|
return service.getSchema('sdl');
|
|
1600
1603
|
},
|
|
@@ -1646,31 +1649,33 @@ class GraphQLService {
|
|
|
1646
1649
|
otp: graphql_1.GraphQLString,
|
|
1647
1650
|
},
|
|
1648
1651
|
resolve: async (_, args, { req, res }) => {
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
ip
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1652
|
+
const accountability = { role: null };
|
|
1653
|
+
if (req?.ip)
|
|
1654
|
+
accountability.ip = req.ip;
|
|
1655
|
+
const userAgent = req?.get('user-agent');
|
|
1656
|
+
if (userAgent)
|
|
1657
|
+
accountability.userAgent = userAgent;
|
|
1658
|
+
const origin = req?.get('origin');
|
|
1659
|
+
if (origin)
|
|
1660
|
+
accountability.origin = origin;
|
|
1656
1661
|
const authenticationService = new authentication_1.AuthenticationService({
|
|
1657
1662
|
accountability: accountability,
|
|
1658
1663
|
schema: this.schema,
|
|
1659
1664
|
});
|
|
1660
|
-
const result = await authenticationService.login(
|
|
1661
|
-
if (args
|
|
1662
|
-
res
|
|
1665
|
+
const result = await authenticationService.login(constants_2.DEFAULT_AUTH_PROVIDER, args, args?.otp);
|
|
1666
|
+
if (args['mode'] === 'cookie') {
|
|
1667
|
+
res?.cookie(env_1.default['REFRESH_TOKEN_COOKIE_NAME'], result['refreshToken'], {
|
|
1663
1668
|
httpOnly: true,
|
|
1664
|
-
domain: env_1.default
|
|
1665
|
-
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
1666
|
-
secure:
|
|
1667
|
-
sameSite: env_1.default
|
|
1669
|
+
domain: env_1.default['REFRESH_TOKEN_COOKIE_DOMAIN'],
|
|
1670
|
+
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL']),
|
|
1671
|
+
secure: env_1.default['REFRESH_TOKEN_COOKIE_SECURE'] ?? false,
|
|
1672
|
+
sameSite: env_1.default['REFRESH_TOKEN_COOKIE_SAME_SITE'] || 'strict',
|
|
1668
1673
|
});
|
|
1669
1674
|
}
|
|
1670
1675
|
return {
|
|
1671
|
-
access_token: result
|
|
1672
|
-
expires: result
|
|
1673
|
-
refresh_token: result
|
|
1676
|
+
access_token: result['accessToken'],
|
|
1677
|
+
expires: result['expires'],
|
|
1678
|
+
refresh_token: result['refreshToken'],
|
|
1674
1679
|
};
|
|
1675
1680
|
},
|
|
1676
1681
|
},
|
|
@@ -1681,35 +1686,37 @@ class GraphQLService {
|
|
|
1681
1686
|
mode: AuthMode,
|
|
1682
1687
|
},
|
|
1683
1688
|
resolve: async (_, args, { req, res }) => {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
ip
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1689
|
+
const accountability = { role: null };
|
|
1690
|
+
if (req?.ip)
|
|
1691
|
+
accountability.ip = req.ip;
|
|
1692
|
+
const userAgent = req?.get('user-agent');
|
|
1693
|
+
if (userAgent)
|
|
1694
|
+
accountability.userAgent = userAgent;
|
|
1695
|
+
const origin = req?.get('origin');
|
|
1696
|
+
if (origin)
|
|
1697
|
+
accountability.origin = origin;
|
|
1691
1698
|
const authenticationService = new authentication_1.AuthenticationService({
|
|
1692
1699
|
accountability: accountability,
|
|
1693
1700
|
schema: this.schema,
|
|
1694
1701
|
});
|
|
1695
|
-
const currentRefreshToken = args
|
|
1702
|
+
const currentRefreshToken = args['refresh_token'] || req?.cookies[env_1.default['REFRESH_TOKEN_COOKIE_NAME']];
|
|
1696
1703
|
if (!currentRefreshToken) {
|
|
1697
1704
|
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1698
1705
|
}
|
|
1699
1706
|
const result = await authenticationService.refresh(currentRefreshToken);
|
|
1700
|
-
if (args
|
|
1701
|
-
res
|
|
1707
|
+
if (args['mode'] === 'cookie') {
|
|
1708
|
+
res?.cookie(env_1.default['REFRESH_TOKEN_COOKIE_NAME'], result['refreshToken'], {
|
|
1702
1709
|
httpOnly: true,
|
|
1703
|
-
domain: env_1.default
|
|
1704
|
-
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
1705
|
-
secure:
|
|
1706
|
-
sameSite: env_1.default
|
|
1710
|
+
domain: env_1.default['REFRESH_TOKEN_COOKIE_DOMAIN'],
|
|
1711
|
+
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL']),
|
|
1712
|
+
secure: env_1.default['REFRESH_TOKEN_COOKIE_SECURE'] ?? false,
|
|
1713
|
+
sameSite: env_1.default['REFRESH_TOKEN_COOKIE_SAME_SITE'] || 'strict',
|
|
1707
1714
|
});
|
|
1708
1715
|
}
|
|
1709
1716
|
return {
|
|
1710
|
-
access_token: result
|
|
1711
|
-
expires: result
|
|
1712
|
-
refresh_token: result
|
|
1717
|
+
access_token: result['accessToken'],
|
|
1718
|
+
expires: result['expires'],
|
|
1719
|
+
refresh_token: result['refreshToken'],
|
|
1713
1720
|
};
|
|
1714
1721
|
},
|
|
1715
1722
|
},
|
|
@@ -1719,17 +1726,20 @@ class GraphQLService {
|
|
|
1719
1726
|
refresh_token: graphql_1.GraphQLString,
|
|
1720
1727
|
},
|
|
1721
1728
|
resolve: async (_, args, { req }) => {
|
|
1722
|
-
const accountability = {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1729
|
+
const accountability = { role: null };
|
|
1730
|
+
if (req?.ip)
|
|
1731
|
+
accountability.ip = req.ip;
|
|
1732
|
+
const userAgent = req?.get('user-agent');
|
|
1733
|
+
if (userAgent)
|
|
1734
|
+
accountability.userAgent = userAgent;
|
|
1735
|
+
const origin = req?.get('origin');
|
|
1736
|
+
if (origin)
|
|
1737
|
+
accountability.origin = origin;
|
|
1728
1738
|
const authenticationService = new authentication_1.AuthenticationService({
|
|
1729
1739
|
accountability: accountability,
|
|
1730
1740
|
schema: this.schema,
|
|
1731
1741
|
});
|
|
1732
|
-
const currentRefreshToken = args
|
|
1742
|
+
const currentRefreshToken = args['refresh_token'] || req?.cookies[env_1.default['REFRESH_TOKEN_COOKIE_NAME']];
|
|
1733
1743
|
if (!currentRefreshToken) {
|
|
1734
1744
|
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1735
1745
|
}
|
|
@@ -1744,15 +1754,18 @@ class GraphQLService {
|
|
|
1744
1754
|
reset_url: graphql_1.GraphQLString,
|
|
1745
1755
|
},
|
|
1746
1756
|
resolve: async (_, args, { req }) => {
|
|
1747
|
-
const accountability = {
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1757
|
+
const accountability = { role: null };
|
|
1758
|
+
if (req?.ip)
|
|
1759
|
+
accountability.ip = req.ip;
|
|
1760
|
+
const userAgent = req?.get('user-agent');
|
|
1761
|
+
if (userAgent)
|
|
1762
|
+
accountability.userAgent = userAgent;
|
|
1763
|
+
const origin = req?.get('origin');
|
|
1764
|
+
if (origin)
|
|
1765
|
+
accountability.origin = origin;
|
|
1753
1766
|
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1754
1767
|
try {
|
|
1755
|
-
await service.requestPasswordReset(args
|
|
1768
|
+
await service.requestPasswordReset(args['email'], args['reset_url'] || null);
|
|
1756
1769
|
}
|
|
1757
1770
|
catch (err) {
|
|
1758
1771
|
if (err instanceof exceptions_1.InvalidPayloadException) {
|
|
@@ -1769,14 +1782,17 @@ class GraphQLService {
|
|
|
1769
1782
|
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1770
1783
|
},
|
|
1771
1784
|
resolve: async (_, args, { req }) => {
|
|
1772
|
-
const accountability = {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1785
|
+
const accountability = { role: null };
|
|
1786
|
+
if (req?.ip)
|
|
1787
|
+
accountability.ip = req.ip;
|
|
1788
|
+
const userAgent = req?.get('user-agent');
|
|
1789
|
+
if (userAgent)
|
|
1790
|
+
accountability.userAgent = userAgent;
|
|
1791
|
+
const origin = req?.get('origin');
|
|
1792
|
+
if (origin)
|
|
1793
|
+
accountability.origin = origin;
|
|
1778
1794
|
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1779
|
-
await service.resetPassword(args
|
|
1795
|
+
await service.resetPassword(args['token'], args['password']);
|
|
1780
1796
|
return true;
|
|
1781
1797
|
},
|
|
1782
1798
|
},
|
|
@@ -1792,8 +1808,7 @@ class GraphQLService {
|
|
|
1792
1808
|
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1793
1809
|
},
|
|
1794
1810
|
resolve: async (_, args) => {
|
|
1795
|
-
|
|
1796
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
1811
|
+
if (!this.accountability?.user)
|
|
1797
1812
|
return null;
|
|
1798
1813
|
const service = new tfa_1.TFAService({
|
|
1799
1814
|
accountability: this.accountability,
|
|
@@ -1803,7 +1818,7 @@ class GraphQLService {
|
|
|
1803
1818
|
accountability: this.accountability,
|
|
1804
1819
|
schema: this.schema,
|
|
1805
1820
|
});
|
|
1806
|
-
await authService.verifyPassword(this.accountability.user, args
|
|
1821
|
+
await authService.verifyPassword(this.accountability.user, args['password']);
|
|
1807
1822
|
const { url, secret } = await service.generateTFA(this.accountability.user);
|
|
1808
1823
|
return { secret, otpauth_url: url };
|
|
1809
1824
|
},
|
|
@@ -1815,14 +1830,13 @@ class GraphQLService {
|
|
|
1815
1830
|
secret: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1816
1831
|
},
|
|
1817
1832
|
resolve: async (_, args) => {
|
|
1818
|
-
|
|
1819
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
1833
|
+
if (!this.accountability?.user)
|
|
1820
1834
|
return null;
|
|
1821
1835
|
const service = new tfa_1.TFAService({
|
|
1822
1836
|
accountability: this.accountability,
|
|
1823
1837
|
schema: this.schema,
|
|
1824
1838
|
});
|
|
1825
|
-
await service.enableTFA(this.accountability.user, args
|
|
1839
|
+
await service.enableTFA(this.accountability.user, args['otp'], args['secret']);
|
|
1826
1840
|
return true;
|
|
1827
1841
|
},
|
|
1828
1842
|
},
|
|
@@ -1832,14 +1846,13 @@ class GraphQLService {
|
|
|
1832
1846
|
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1833
1847
|
},
|
|
1834
1848
|
resolve: async (_, args) => {
|
|
1835
|
-
|
|
1836
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
1849
|
+
if (!this.accountability?.user)
|
|
1837
1850
|
return null;
|
|
1838
1851
|
const service = new tfa_1.TFAService({
|
|
1839
1852
|
accountability: this.accountability,
|
|
1840
1853
|
schema: this.schema,
|
|
1841
1854
|
});
|
|
1842
|
-
const otpValid = await service.verifyOTP(this.accountability.user, args
|
|
1855
|
+
const otpValid = await service.verifyOTP(this.accountability.user, args['otp']);
|
|
1843
1856
|
if (otpValid === false) {
|
|
1844
1857
|
throw new exceptions_1.InvalidPayloadException(`"otp" is invalid`);
|
|
1845
1858
|
}
|
|
@@ -1853,7 +1866,7 @@ class GraphQLService {
|
|
|
1853
1866
|
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1854
1867
|
},
|
|
1855
1868
|
resolve: async (_, args) => {
|
|
1856
|
-
return await (0, generate_hash_1.generateHash)(args
|
|
1869
|
+
return await (0, generate_hash_1.generateHash)(args['string']);
|
|
1857
1870
|
},
|
|
1858
1871
|
},
|
|
1859
1872
|
utils_hash_verify: {
|
|
@@ -1863,7 +1876,7 @@ class GraphQLService {
|
|
|
1863
1876
|
hash: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1864
1877
|
},
|
|
1865
1878
|
resolve: async (_, args) => {
|
|
1866
|
-
return await argon2_1.default.verify(args
|
|
1879
|
+
return await argon2_1.default.verify(args['hash'], args['string']);
|
|
1867
1880
|
},
|
|
1868
1881
|
},
|
|
1869
1882
|
utils_sort: {
|
|
@@ -1879,7 +1892,7 @@ class GraphQLService {
|
|
|
1879
1892
|
schema: this.schema,
|
|
1880
1893
|
});
|
|
1881
1894
|
const { item, to } = args;
|
|
1882
|
-
await service.sort(args
|
|
1895
|
+
await service.sort(args['collection'], { item, to });
|
|
1883
1896
|
return true;
|
|
1884
1897
|
},
|
|
1885
1898
|
},
|
|
@@ -1893,19 +1906,18 @@ class GraphQLService {
|
|
|
1893
1906
|
accountability: this.accountability,
|
|
1894
1907
|
schema: this.schema,
|
|
1895
1908
|
});
|
|
1896
|
-
await service.revert(args
|
|
1909
|
+
await service.revert(args['revision']);
|
|
1897
1910
|
return true;
|
|
1898
1911
|
},
|
|
1899
1912
|
},
|
|
1900
1913
|
utils_cache_clear: {
|
|
1901
1914
|
type: void_1.GraphQLVoid,
|
|
1902
1915
|
resolve: async () => {
|
|
1903
|
-
|
|
1904
|
-
if (((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.admin) !== true) {
|
|
1916
|
+
if (this.accountability?.admin !== true) {
|
|
1905
1917
|
throw new exceptions_1.ForbiddenException();
|
|
1906
1918
|
}
|
|
1907
1919
|
const { cache } = (0, cache_1.getCache)();
|
|
1908
|
-
await
|
|
1920
|
+
await cache?.clear();
|
|
1909
1921
|
await (0, cache_1.clearSystemCache)();
|
|
1910
1922
|
return;
|
|
1911
1923
|
},
|
|
@@ -1921,7 +1933,7 @@ class GraphQLService {
|
|
|
1921
1933
|
accountability: this.accountability,
|
|
1922
1934
|
schema: this.schema,
|
|
1923
1935
|
});
|
|
1924
|
-
await service.acceptInvite(args
|
|
1936
|
+
await service.acceptInvite(args['token'], args['password']);
|
|
1925
1937
|
return true;
|
|
1926
1938
|
},
|
|
1927
1939
|
},
|
|
@@ -1970,7 +1982,7 @@ class GraphQLService {
|
|
|
1970
1982
|
accountability: this.accountability,
|
|
1971
1983
|
schema: this.schema,
|
|
1972
1984
|
});
|
|
1973
|
-
return await collectionsService.readOne(args
|
|
1985
|
+
return await collectionsService.readOne(args['name']);
|
|
1974
1986
|
},
|
|
1975
1987
|
},
|
|
1976
1988
|
});
|
|
@@ -2033,7 +2045,7 @@ class GraphQLService {
|
|
|
2033
2045
|
accountability: this.accountability,
|
|
2034
2046
|
schema: this.schema,
|
|
2035
2047
|
});
|
|
2036
|
-
return await service.readAll(args
|
|
2048
|
+
return await service.readAll(args['collection']);
|
|
2037
2049
|
},
|
|
2038
2050
|
},
|
|
2039
2051
|
fields_by_name: {
|
|
@@ -2047,7 +2059,7 @@ class GraphQLService {
|
|
|
2047
2059
|
accountability: this.accountability,
|
|
2048
2060
|
schema: this.schema,
|
|
2049
2061
|
});
|
|
2050
|
-
return await service.readOne(args
|
|
2062
|
+
return await service.readOne(args['collection'], args['field']);
|
|
2051
2063
|
},
|
|
2052
2064
|
},
|
|
2053
2065
|
});
|
|
@@ -2101,7 +2113,7 @@ class GraphQLService {
|
|
|
2101
2113
|
accountability: this.accountability,
|
|
2102
2114
|
schema: this.schema,
|
|
2103
2115
|
});
|
|
2104
|
-
return await service.readAll(args
|
|
2116
|
+
return await service.readAll(args['collection']);
|
|
2105
2117
|
},
|
|
2106
2118
|
},
|
|
2107
2119
|
relations_by_name: {
|
|
@@ -2115,12 +2127,12 @@ class GraphQLService {
|
|
|
2115
2127
|
accountability: this.accountability,
|
|
2116
2128
|
schema: this.schema,
|
|
2117
2129
|
});
|
|
2118
|
-
return await service.readOne(args
|
|
2130
|
+
return await service.readOne(args['collection'], args['field']);
|
|
2119
2131
|
},
|
|
2120
2132
|
},
|
|
2121
2133
|
});
|
|
2122
2134
|
}
|
|
2123
|
-
if (
|
|
2135
|
+
if (this.accountability?.admin === true) {
|
|
2124
2136
|
schemaComposer.Mutation.addFields({
|
|
2125
2137
|
create_collections_item: {
|
|
2126
2138
|
type: Collection,
|
|
@@ -2138,7 +2150,7 @@ class GraphQLService {
|
|
|
2138
2150
|
accountability: this.accountability,
|
|
2139
2151
|
schema: this.schema,
|
|
2140
2152
|
});
|
|
2141
|
-
const collectionKey = await collectionsService.createOne(args
|
|
2153
|
+
const collectionKey = await collectionsService.createOne(args['data']);
|
|
2142
2154
|
return await collectionsService.readOne(collectionKey);
|
|
2143
2155
|
},
|
|
2144
2156
|
},
|
|
@@ -2155,7 +2167,7 @@ class GraphQLService {
|
|
|
2155
2167
|
accountability: this.accountability,
|
|
2156
2168
|
schema: this.schema,
|
|
2157
2169
|
});
|
|
2158
|
-
const collectionKey = await collectionsService.updateOne(args
|
|
2170
|
+
const collectionKey = await collectionsService.updateOne(args['collection'], args['data']);
|
|
2159
2171
|
return await collectionsService.readOne(collectionKey);
|
|
2160
2172
|
},
|
|
2161
2173
|
},
|
|
@@ -2174,8 +2186,8 @@ class GraphQLService {
|
|
|
2174
2186
|
accountability: this.accountability,
|
|
2175
2187
|
schema: this.schema,
|
|
2176
2188
|
});
|
|
2177
|
-
await collectionsService.deleteOne(args
|
|
2178
|
-
return { collection: args
|
|
2189
|
+
await collectionsService.deleteOne(args['collection']);
|
|
2190
|
+
return { collection: args['collection'] };
|
|
2179
2191
|
},
|
|
2180
2192
|
},
|
|
2181
2193
|
});
|
|
@@ -2191,8 +2203,8 @@ class GraphQLService {
|
|
|
2191
2203
|
accountability: this.accountability,
|
|
2192
2204
|
schema: this.schema,
|
|
2193
2205
|
});
|
|
2194
|
-
await service.createField(args
|
|
2195
|
-
return await service.readOne(args
|
|
2206
|
+
await service.createField(args['collection'], args['data']);
|
|
2207
|
+
return await service.readOne(args['collection'], args['data'].field);
|
|
2196
2208
|
},
|
|
2197
2209
|
},
|
|
2198
2210
|
update_fields_item: {
|
|
@@ -2207,11 +2219,11 @@ class GraphQLService {
|
|
|
2207
2219
|
accountability: this.accountability,
|
|
2208
2220
|
schema: this.schema,
|
|
2209
2221
|
});
|
|
2210
|
-
await service.updateField(args
|
|
2211
|
-
...args
|
|
2212
|
-
field: args
|
|
2222
|
+
await service.updateField(args['collection'], {
|
|
2223
|
+
...args['data'],
|
|
2224
|
+
field: args['field'],
|
|
2213
2225
|
});
|
|
2214
|
-
return await service.readOne(args
|
|
2226
|
+
return await service.readOne(args['collection'], args['data'].field);
|
|
2215
2227
|
},
|
|
2216
2228
|
},
|
|
2217
2229
|
delete_fields_item: {
|
|
@@ -2231,7 +2243,7 @@ class GraphQLService {
|
|
|
2231
2243
|
accountability: this.accountability,
|
|
2232
2244
|
schema: this.schema,
|
|
2233
2245
|
});
|
|
2234
|
-
await service.deleteField(args
|
|
2246
|
+
await service.deleteField(args['collection'], args['field']);
|
|
2235
2247
|
const { collection, field } = args;
|
|
2236
2248
|
return { collection, field };
|
|
2237
2249
|
},
|
|
@@ -2248,8 +2260,8 @@ class GraphQLService {
|
|
|
2248
2260
|
accountability: this.accountability,
|
|
2249
2261
|
schema: this.schema,
|
|
2250
2262
|
});
|
|
2251
|
-
await relationsService.createOne(args
|
|
2252
|
-
return await relationsService.readOne(args
|
|
2263
|
+
await relationsService.createOne(args['data']);
|
|
2264
|
+
return await relationsService.readOne(args['data'].collection, args['data'].field);
|
|
2253
2265
|
},
|
|
2254
2266
|
},
|
|
2255
2267
|
update_relations_item: {
|
|
@@ -2264,8 +2276,8 @@ class GraphQLService {
|
|
|
2264
2276
|
accountability: this.accountability,
|
|
2265
2277
|
schema: this.schema,
|
|
2266
2278
|
});
|
|
2267
|
-
await relationsService.updateOne(args
|
|
2268
|
-
return await relationsService.readOne(args
|
|
2279
|
+
await relationsService.updateOne(args['collection'], args['field'], args['data']);
|
|
2280
|
+
return await relationsService.readOne(args['data'].collection, args['data'].field);
|
|
2269
2281
|
},
|
|
2270
2282
|
},
|
|
2271
2283
|
delete_relations_item: {
|
|
@@ -2285,8 +2297,8 @@ class GraphQLService {
|
|
|
2285
2297
|
accountability: this.accountability,
|
|
2286
2298
|
schema: this.schema,
|
|
2287
2299
|
});
|
|
2288
|
-
await relationsService.deleteOne(args
|
|
2289
|
-
return { collection: args
|
|
2300
|
+
await relationsService.deleteOne(args['collection'], args['field']);
|
|
2301
|
+
return { collection: args['collection'], field: args['field'] };
|
|
2290
2302
|
},
|
|
2291
2303
|
},
|
|
2292
2304
|
});
|
|
@@ -2296,18 +2308,17 @@ class GraphQLService {
|
|
|
2296
2308
|
users_me: {
|
|
2297
2309
|
type: ReadCollectionTypes['directus_users'],
|
|
2298
2310
|
resolve: async (_, args, __, info) => {
|
|
2299
|
-
|
|
2300
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
2311
|
+
if (!this.accountability?.user)
|
|
2301
2312
|
return null;
|
|
2302
2313
|
const service = new users_1.UsersService({ schema: this.schema, accountability: this.accountability });
|
|
2303
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2314
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2304
2315
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2305
2316
|
return await service.readOne(this.accountability.user, query);
|
|
2306
2317
|
},
|
|
2307
2318
|
},
|
|
2308
2319
|
});
|
|
2309
2320
|
}
|
|
2310
|
-
if ('directus_users' in schema.update.collections &&
|
|
2321
|
+
if ('directus_users' in schema.update.collections && this.accountability?.user) {
|
|
2311
2322
|
schemaComposer.Mutation.addFields({
|
|
2312
2323
|
update_users_me: {
|
|
2313
2324
|
type: ReadCollectionTypes['directus_users'],
|
|
@@ -2315,16 +2326,15 @@ class GraphQLService {
|
|
|
2315
2326
|
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes['directus_users']),
|
|
2316
2327
|
},
|
|
2317
2328
|
resolve: async (_, args, __, info) => {
|
|
2318
|
-
|
|
2319
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
2329
|
+
if (!this.accountability?.user)
|
|
2320
2330
|
return null;
|
|
2321
2331
|
const service = new users_1.UsersService({
|
|
2322
2332
|
schema: this.schema,
|
|
2323
2333
|
accountability: this.accountability,
|
|
2324
2334
|
});
|
|
2325
|
-
await service.updateOne(this.accountability.user, args
|
|
2335
|
+
await service.updateOne(this.accountability.user, args['data']);
|
|
2326
2336
|
if ('directus_users' in ReadCollectionTypes) {
|
|
2327
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2337
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2328
2338
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2329
2339
|
return await service.readOne(this.accountability.user, query);
|
|
2330
2340
|
}
|
|
@@ -2336,14 +2346,13 @@ class GraphQLService {
|
|
|
2336
2346
|
if ('directus_activity' in schema.create.collections) {
|
|
2337
2347
|
schemaComposer.Mutation.addFields({
|
|
2338
2348
|
create_comment: {
|
|
2339
|
-
type:
|
|
2349
|
+
type: ReadCollectionTypes['directus_activity'] ?? graphql_1.GraphQLBoolean,
|
|
2340
2350
|
args: {
|
|
2341
2351
|
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2342
2352
|
item: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2343
2353
|
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2344
2354
|
},
|
|
2345
2355
|
resolve: async (_, args, __, info) => {
|
|
2346
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2347
2356
|
const service = new activity_1.ActivityService({
|
|
2348
2357
|
accountability: this.accountability,
|
|
2349
2358
|
schema: this.schema,
|
|
@@ -2351,13 +2360,13 @@ class GraphQLService {
|
|
|
2351
2360
|
const primaryKey = await service.createOne({
|
|
2352
2361
|
...args,
|
|
2353
2362
|
action: types_1.Action.COMMENT,
|
|
2354
|
-
user:
|
|
2355
|
-
ip:
|
|
2356
|
-
user_agent:
|
|
2357
|
-
origin:
|
|
2363
|
+
user: this.accountability?.user,
|
|
2364
|
+
ip: this.accountability?.ip,
|
|
2365
|
+
user_agent: this.accountability?.userAgent,
|
|
2366
|
+
origin: this.accountability?.origin,
|
|
2358
2367
|
});
|
|
2359
2368
|
if ('directus_activity' in ReadCollectionTypes) {
|
|
2360
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2369
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2361
2370
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2362
2371
|
return await service.readOne(primaryKey, query);
|
|
2363
2372
|
}
|
|
@@ -2369,20 +2378,19 @@ class GraphQLService {
|
|
|
2369
2378
|
if ('directus_activity' in schema.update.collections) {
|
|
2370
2379
|
schemaComposer.Mutation.addFields({
|
|
2371
2380
|
update_comment: {
|
|
2372
|
-
type:
|
|
2381
|
+
type: ReadCollectionTypes['directus_activity'] ?? graphql_1.GraphQLBoolean,
|
|
2373
2382
|
args: {
|
|
2374
2383
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2375
2384
|
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2376
2385
|
},
|
|
2377
2386
|
resolve: async (_, args, __, info) => {
|
|
2378
|
-
var _a, _b;
|
|
2379
2387
|
const service = new activity_1.ActivityService({
|
|
2380
2388
|
accountability: this.accountability,
|
|
2381
2389
|
schema: this.schema,
|
|
2382
2390
|
});
|
|
2383
|
-
const primaryKey = await service.updateOne(args
|
|
2391
|
+
const primaryKey = await service.updateOne(args['id'], { comment: args['comment'] });
|
|
2384
2392
|
if ('directus_activity' in ReadCollectionTypes) {
|
|
2385
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2393
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2386
2394
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2387
2395
|
return await service.readOne(primaryKey, query);
|
|
2388
2396
|
}
|
|
@@ -2394,7 +2402,7 @@ class GraphQLService {
|
|
|
2394
2402
|
if ('directus_activity' in schema.delete.collections) {
|
|
2395
2403
|
schemaComposer.Mutation.addFields({
|
|
2396
2404
|
delete_comment: {
|
|
2397
|
-
type: DeleteCollectionTypes
|
|
2405
|
+
type: DeleteCollectionTypes['one'],
|
|
2398
2406
|
args: {
|
|
2399
2407
|
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2400
2408
|
},
|
|
@@ -2403,8 +2411,8 @@ class GraphQLService {
|
|
|
2403
2411
|
accountability: this.accountability,
|
|
2404
2412
|
schema: this.schema,
|
|
2405
2413
|
});
|
|
2406
|
-
await service.deleteOne(args
|
|
2407
|
-
return { id: args
|
|
2414
|
+
await service.deleteOne(args['id']);
|
|
2415
|
+
return { id: args['id'] };
|
|
2408
2416
|
},
|
|
2409
2417
|
},
|
|
2410
2418
|
});
|
|
@@ -2412,20 +2420,19 @@ class GraphQLService {
|
|
|
2412
2420
|
if ('directus_files' in schema.create.collections) {
|
|
2413
2421
|
schemaComposer.Mutation.addFields({
|
|
2414
2422
|
import_file: {
|
|
2415
|
-
type:
|
|
2423
|
+
type: ReadCollectionTypes['directus_files'] ?? graphql_1.GraphQLBoolean,
|
|
2416
2424
|
args: {
|
|
2417
2425
|
url: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2418
2426
|
data: (0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes['directus_files']).setTypeName('create_directus_files_input'),
|
|
2419
2427
|
},
|
|
2420
2428
|
resolve: async (_, args, __, info) => {
|
|
2421
|
-
var _a, _b;
|
|
2422
2429
|
const service = new files_1.FilesService({
|
|
2423
2430
|
accountability: this.accountability,
|
|
2424
2431
|
schema: this.schema,
|
|
2425
2432
|
});
|
|
2426
|
-
const primaryKey = await service.importOne(args
|
|
2433
|
+
const primaryKey = await service.importOne(args['url'], args['data']);
|
|
2427
2434
|
if ('directus_files' in ReadCollectionTypes) {
|
|
2428
|
-
const selections = this.replaceFragmentsInSelections(
|
|
2435
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2429
2436
|
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2430
2437
|
return await service.readOne(primaryKey, query);
|
|
2431
2438
|
}
|
|
@@ -2448,7 +2455,7 @@ class GraphQLService {
|
|
|
2448
2455
|
accountability: this.accountability,
|
|
2449
2456
|
schema: this.schema,
|
|
2450
2457
|
});
|
|
2451
|
-
await service.inviteUser(args
|
|
2458
|
+
await service.inviteUser(args['email'], args['role'], args['invite_url'] || null);
|
|
2452
2459
|
return true;
|
|
2453
2460
|
},
|
|
2454
2461
|
},
|