directus 9.24.0 → 9.25.0
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/cli.js +1 -1
- package/package.json +5 -170
- package/LICENSE +0 -674
- package/README.md +0 -89
- package/dist/app.d.ts +0 -2
- package/dist/app.js +0 -250
- package/dist/app.test.d.ts +0 -1
- package/dist/auth/auth.d.ts +0 -46
- package/dist/auth/auth.js +0 -40
- package/dist/auth/drivers/index.d.ts +0 -5
- package/dist/auth/drivers/index.js +0 -21
- package/dist/auth/drivers/ldap.d.ts +0 -20
- package/dist/auth/drivers/ldap.js +0 -349
- package/dist/auth/drivers/local.d.ts +0 -9
- package/dist/auth/drivers/local.js +0 -91
- package/dist/auth/drivers/oauth2.d.ts +0 -19
- package/dist/auth/drivers/oauth2.js +0 -310
- package/dist/auth/drivers/openid.d.ts +0 -19
- package/dist/auth/drivers/openid.js +0 -332
- package/dist/auth/drivers/saml.d.ts +0 -14
- package/dist/auth/drivers/saml.js +0 -169
- package/dist/auth.d.ts +0 -3
- package/dist/auth.js +0 -70
- package/dist/cache.d.ts +0 -20
- package/dist/cache.js +0 -151
- package/dist/cli/commands/bootstrap/index.d.ts +0 -3
- package/dist/cli/commands/bootstrap/index.js +0 -98
- package/dist/cli/commands/count/index.d.ts +0 -1
- package/dist/cli/commands/count/index.js +0 -27
- package/dist/cli/commands/database/install.d.ts +0 -1
- package/dist/cli/commands/database/install.js +0 -22
- package/dist/cli/commands/database/migrate.d.ts +0 -1
- package/dist/cli/commands/database/migrate.js +0 -29
- package/dist/cli/commands/init/index.d.ts +0 -1
- package/dist/cli/commands/init/index.js +0 -108
- package/dist/cli/commands/init/questions.d.ts +0 -20
- package/dist/cli/commands/init/questions.js +0 -71
- package/dist/cli/commands/roles/create.d.ts +0 -4
- package/dist/cli/commands/roles/create.js +0 -29
- package/dist/cli/commands/schema/apply.d.ts +0 -4
- package/dist/cli/commands/schema/apply.js +0 -183
- package/dist/cli/commands/schema/snapshot.d.ts +0 -4
- package/dist/cli/commands/schema/snapshot.js +0 -63
- package/dist/cli/commands/security/key.d.ts +0 -1
- package/dist/cli/commands/security/key.js +0 -8
- package/dist/cli/commands/security/secret.d.ts +0 -1
- package/dist/cli/commands/security/secret.js +0 -8
- package/dist/cli/commands/users/create.d.ts +0 -5
- package/dist/cli/commands/users/create.js +0 -29
- package/dist/cli/commands/users/passwd.d.ts +0 -4
- package/dist/cli/commands/users/passwd.js +0 -41
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -96
- package/dist/cli/index.test.d.ts +0 -1
- package/dist/cli/run.d.ts +0 -1
- package/dist/cli/run.js +0 -10
- package/dist/cli/utils/create-db-connection.d.ts +0 -13
- package/dist/cli/utils/create-db-connection.js +0 -61
- package/dist/cli/utils/create-env/env-stub.liquid +0 -325
- package/dist/cli/utils/create-env/index.d.ts +0 -3
- package/dist/cli/utils/create-env/index.js +0 -44
- package/dist/cli/utils/defaults.d.ts +0 -11
- package/dist/cli/utils/defaults.js +0 -14
- package/dist/cli/utils/drivers.d.ts +0 -3
- package/dist/cli/utils/drivers.js +0 -19
- package/dist/constants.d.ts +0 -13
- package/dist/constants.js +0 -59
- package/dist/controllers/activity.d.ts +0 -2
- package/dist/controllers/activity.js +0 -135
- package/dist/controllers/assets.d.ts +0 -2
- package/dist/controllers/assets.js +0 -186
- package/dist/controllers/auth.d.ts +0 -2
- package/dist/controllers/auth.js +0 -167
- package/dist/controllers/collections.d.ts +0 -2
- package/dist/controllers/collections.js +0 -105
- package/dist/controllers/dashboards.d.ts +0 -2
- package/dist/controllers/dashboards.js +0 -144
- package/dist/controllers/extensions.d.ts +0 -2
- package/dist/controllers/extensions.js +0 -40
- package/dist/controllers/fields.d.ts +0 -2
- package/dist/controllers/fields.js +0 -160
- package/dist/controllers/files.d.ts +0 -4
- package/dist/controllers/files.js +0 -274
- package/dist/controllers/files.test.d.ts +0 -1
- package/dist/controllers/flows.d.ts +0 -2
- package/dist/controllers/flows.js +0 -163
- package/dist/controllers/folders.d.ts +0 -2
- package/dist/controllers/folders.js +0 -153
- package/dist/controllers/graphql.d.ts +0 -2
- package/dist/controllers/graphql.js +0 -36
- package/dist/controllers/items.d.ts +0 -2
- package/dist/controllers/items.js +0 -183
- package/dist/controllers/not-found.d.ts +0 -14
- package/dist/controllers/not-found.js +0 -36
- package/dist/controllers/notifications.d.ts +0 -2
- package/dist/controllers/notifications.js +0 -153
- package/dist/controllers/operations.d.ts +0 -2
- package/dist/controllers/operations.js +0 -144
- package/dist/controllers/panels.d.ts +0 -2
- package/dist/controllers/panels.js +0 -144
- package/dist/controllers/permissions.d.ts +0 -2
- package/dist/controllers/permissions.js +0 -155
- package/dist/controllers/presets.d.ts +0 -2
- package/dist/controllers/presets.js +0 -153
- package/dist/controllers/relations.d.ts +0 -2
- package/dist/controllers/relations.js +0 -117
- package/dist/controllers/revisions.d.ts +0 -2
- package/dist/controllers/revisions.js +0 -39
- package/dist/controllers/roles.d.ts +0 -2
- package/dist/controllers/roles.js +0 -144
- package/dist/controllers/schema.d.ts +0 -2
- package/dist/controllers/schema.js +0 -98
- package/dist/controllers/server.d.ts +0 -2
- package/dist/controllers/server.js +0 -61
- package/dist/controllers/settings.d.ts +0 -2
- package/dist/controllers/settings.js +0 -41
- package/dist/controllers/shares.d.ts +0 -2
- package/dist/controllers/shares.js +0 -218
- package/dist/controllers/users.d.ts +0 -2
- package/dist/controllers/users.js +0 -358
- package/dist/controllers/utils.d.ts +0 -2
- package/dist/controllers/utils.js +0 -121
- package/dist/controllers/webhooks.d.ts +0 -2
- package/dist/controllers/webhooks.js +0 -141
- package/dist/database/helpers/date/dialects/default.d.ts +0 -3
- package/dist/database/helpers/date/dialects/default.js +0 -7
- package/dist/database/helpers/date/dialects/mssql.d.ts +0 -4
- package/dist/database/helpers/date/dialects/mssql.js +0 -12
- package/dist/database/helpers/date/dialects/mysql.d.ts +0 -5
- package/dist/database/helpers/date/dialects/mysql.js +0 -16
- package/dist/database/helpers/date/dialects/oracle.d.ts +0 -4
- package/dist/database/helpers/date/dialects/oracle.js +0 -15
- package/dist/database/helpers/date/dialects/sqlite.d.ts +0 -5
- package/dist/database/helpers/date/dialects/sqlite.js +0 -30
- package/dist/database/helpers/date/index.d.ts +0 -7
- package/dist/database/helpers/date/index.js +0 -17
- package/dist/database/helpers/date/types.d.ts +0 -7
- package/dist/database/helpers/date/types.js +0 -24
- package/dist/database/helpers/fn/dialects/mssql.d.ts +0 -13
- package/dist/database/helpers/fn/dialects/mssql.js +0 -48
- package/dist/database/helpers/fn/dialects/mysql.d.ts +0 -13
- package/dist/database/helpers/fn/dialects/mysql.js +0 -42
- package/dist/database/helpers/fn/dialects/oracle.d.ts +0 -13
- package/dist/database/helpers/fn/dialects/oracle.js +0 -48
- package/dist/database/helpers/fn/dialects/postgres.d.ts +0 -13
- package/dist/database/helpers/fn/dialects/postgres.js +0 -52
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +0 -13
- package/dist/database/helpers/fn/dialects/sqlite.js +0 -72
- package/dist/database/helpers/fn/index.d.ts +0 -7
- package/dist/database/helpers/fn/index.js +0 -17
- package/dist/database/helpers/fn/types.d.ts +0 -22
- package/dist/database/helpers/fn/types.js +0 -30
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +0 -14
- package/dist/database/helpers/geometry/dialects/mssql.js +0 -36
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +0 -7
- package/dist/database/helpers/geometry/dialects/mysql.js +0 -16
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +0 -15
- package/dist/database/helpers/geometry/dialects/oracle.js +0 -39
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +0 -10
- package/dist/database/helpers/geometry/dialects/postgres.js +0 -22
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +0 -7
- package/dist/database/helpers/geometry/dialects/redshift.js +0 -16
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +0 -6
- package/dist/database/helpers/geometry/dialects/sqlite.js +0 -14
- package/dist/database/helpers/geometry/index.d.ts +0 -7
- package/dist/database/helpers/geometry/index.js +0 -17
- package/dist/database/helpers/geometry/types.d.ts +0 -20
- package/dist/database/helpers/geometry/types.js +0 -53
- package/dist/database/helpers/index.d.ts +0 -13
- package/dist/database/helpers/index.js +0 -45
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +0 -6
- package/dist/database/helpers/schema/dialects/cockroachdb.js +0 -21
- package/dist/database/helpers/schema/dialects/default.d.ts +0 -3
- package/dist/database/helpers/schema/dialects/default.js +0 -7
- package/dist/database/helpers/schema/dialects/mssql.d.ts +0 -7
- package/dist/database/helpers/schema/dialects/mssql.js +0 -24
- package/dist/database/helpers/schema/dialects/mysql.d.ts +0 -5
- package/dist/database/helpers/schema/dialects/mysql.js +0 -18
- package/dist/database/helpers/schema/dialects/oracle.d.ts +0 -9
- package/dist/database/helpers/schema/dialects/oracle.js +0 -36
- package/dist/database/helpers/schema/dialects/sqlite.d.ts +0 -5
- package/dist/database/helpers/schema/dialects/sqlite.js +0 -17
- package/dist/database/helpers/schema/index.d.ts +0 -7
- package/dist/database/helpers/schema/index.js +0 -17
- package/dist/database/helpers/schema/types.d.ts +0 -26
- package/dist/database/helpers/schema/types.js +0 -95
- package/dist/database/helpers/types.d.ts +0 -5
- package/dist/database/helpers/types.js +0 -10
- package/dist/database/index.d.ts +0 -20
- package/dist/database/index.js +0 -279
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +0 -3
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.js +0 -47
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +0 -3
- package/dist/database/migrations/20201029A-remove-system-relations.js +0 -127
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +0 -3
- package/dist/database/migrations/20201029B-remove-system-collections.js +0 -98
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +0 -3
- package/dist/database/migrations/20201029C-remove-system-fields.js +0 -1648
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +0 -8
- package/dist/database/migrations/20201105A-add-cascade-system-relations.js +0 -136
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +0 -3
- package/dist/database/migrations/20201105B-change-webhook-url-type.js +0 -17
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +0 -3
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +0 -33
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +0 -3
- package/dist/database/migrations/20210304A-remove-locked-fields.js +0 -15
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +0 -3
- package/dist/database/migrations/20210312A-webhooks-collections-text.js +0 -17
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +0 -3
- package/dist/database/migrations/20210331A-add-refresh-interval.js +0 -15
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +0 -3
- package/dist/database/migrations/20210415A-make-filesize-nullable.js +0 -20
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +0 -3
- package/dist/database/migrations/20210416A-add-collections-accountability.js +0 -16
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +0 -3
- package/dist/database/migrations/20210422A-remove-files-interface.js +0 -11
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +0 -3
- package/dist/database/migrations/20210506A-rename-interfaces.js +0 -79
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +0 -3
- package/dist/database/migrations/20210510A-restructure-relations.js +0 -32
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +0 -3
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +0 -114
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +0 -3
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +0 -172
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +0 -3
- package/dist/database/migrations/20210521A-add-collections-icon-color.js +0 -15
- package/dist/database/migrations/20210525A-add-insights.d.ts +0 -3
- package/dist/database/migrations/20210525A-add-insights.js +0 -36
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +0 -3
- package/dist/database/migrations/20210608A-add-deep-clone-config.js +0 -15
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +0 -3
- package/dist/database/migrations/20210626A-change-filesize-bigint.js +0 -24
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +0 -3
- package/dist/database/migrations/20210716A-add-conditions-to-fields.js +0 -15
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +0 -3
- package/dist/database/migrations/20210721A-add-default-folder.js +0 -23
- package/dist/database/migrations/20210802A-replace-groups.d.ts +0 -3
- package/dist/database/migrations/20210802A-replace-groups.js +0 -53
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +0 -3
- package/dist/database/migrations/20210803A-add-required-to-fields.js +0 -15
- package/dist/database/migrations/20210805A-update-groups.d.ts +0 -3
- package/dist/database/migrations/20210805A-update-groups.js +0 -34
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +0 -3
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +0 -89
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +0 -3
- package/dist/database/migrations/20210811A-add-geometry-config.js +0 -17
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +0 -3
- package/dist/database/migrations/20210831A-remove-limit-column.js +0 -15
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +0 -3
- package/dist/database/migrations/20210903A-add-auth-provider.js +0 -40
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +0 -3
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.js +0 -18
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +0 -3
- package/dist/database/migrations/20210910A-move-module-setup.js +0 -21
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +0 -3
- package/dist/database/migrations/20210920A-webhooks-url-not-null.js +0 -26
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +0 -3
- package/dist/database/migrations/20210924A-add-collection-organization.js +0 -19
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +0 -3
- package/dist/database/migrations/20210927A-replace-fields-group.js +0 -53
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +0 -3
- package/dist/database/migrations/20210927B-replace-m2m-interface.js +0 -21
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +0 -3
- package/dist/database/migrations/20210929A-rename-login-action.js +0 -19
- package/dist/database/migrations/20211007A-update-presets.d.ts +0 -3
- package/dist/database/migrations/20211007A-update-presets.js +0 -103
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +0 -3
- package/dist/database/migrations/20211009A-add-auth-data.js +0 -15
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +0 -3
- package/dist/database/migrations/20211016A-add-webhook-headers.js +0 -15
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +0 -3
- package/dist/database/migrations/20211103A-set-unique-to-user-token.js +0 -15
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +0 -3
- package/dist/database/migrations/20211103B-update-special-geometry.js +0 -25
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +0 -3
- package/dist/database/migrations/20211104A-remove-collections-listing.js +0 -15
- package/dist/database/migrations/20211118A-add-notifications.d.ts +0 -3
- package/dist/database/migrations/20211118A-add-notifications.js +0 -28
- package/dist/database/migrations/20211211A-add-shares.d.ts +0 -3
- package/dist/database/migrations/20211211A-add-shares.js +0 -38
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +0 -3
- package/dist/database/migrations/20211230A-add-project-descriptor.js +0 -15
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +0 -3
- package/dist/database/migrations/20220303A-remove-default-project-color.js +0 -22
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +0 -3
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.js +0 -17
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +0 -3
- package/dist/database/migrations/20220314A-add-translation-strings.js +0 -15
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +0 -3
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.js +0 -77
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +0 -3
- package/dist/database/migrations/20220323A-add-field-validation.js +0 -17
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +0 -3
- package/dist/database/migrations/20220325A-fix-typecast-flags.js +0 -49
- package/dist/database/migrations/20220325B-add-default-language.d.ts +0 -3
- package/dist/database/migrations/20220325B-add-default-language.js +0 -28
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +0 -3
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.js +0 -22
- package/dist/database/migrations/20220429A-add-flows.d.ts +0 -3
- package/dist/database/migrations/20220429A-add-flows.js +0 -82
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +0 -3
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.js +0 -15
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +0 -3
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.js +0 -15
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +0 -3
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.js +0 -15
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +0 -3
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.js +0 -11
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +0 -3
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.js +0 -19
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +0 -3
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.js +0 -15
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +0 -3
- package/dist/database/migrations/20220826A-add-origin-to-accountability.js +0 -21
- package/dist/database/migrations/run.d.ts +0 -2
- package/dist/database/migrations/run.js +0 -96
- package/dist/database/migrations/run.test.d.ts +0 -1
- package/dist/database/run-ast.d.ts +0 -26
- package/dist/database/run-ast.js +0 -474
- package/dist/database/seeds/01-collections.yaml +0 -42
- package/dist/database/seeds/02-roles.yaml +0 -36
- package/dist/database/seeds/03-users.yaml +0 -63
- package/dist/database/seeds/04-fields.yaml +0 -58
- package/dist/database/seeds/05-activity.yaml +0 -35
- package/dist/database/seeds/06-folders.yaml +0 -16
- package/dist/database/seeds/07-files.yaml +0 -74
- package/dist/database/seeds/08-permissions.yaml +0 -32
- package/dist/database/seeds/09-presets.yaml +0 -37
- package/dist/database/seeds/10-relations.yaml +0 -40
- package/dist/database/seeds/11-revisions.yaml +0 -33
- package/dist/database/seeds/12-sessions.yaml +0 -23
- package/dist/database/seeds/13-settings.yaml +0 -49
- package/dist/database/seeds/14-webhooks.yaml +0 -35
- package/dist/database/seeds/15-migrations.yaml +0 -14
- package/dist/database/seeds/run.d.ts +0 -2
- package/dist/database/seeds/run.js +0 -76
- package/dist/database/system-data/app-access-permissions/app-access-permissions.yaml +0 -102
- package/dist/database/system-data/app-access-permissions/index.d.ts +0 -3
- package/dist/database/system-data/app-access-permissions/index.js +0 -17
- package/dist/database/system-data/app-access-permissions/schema-access-permissions.yaml +0 -17
- package/dist/database/system-data/collections/collections.yaml +0 -74
- package/dist/database/system-data/collections/index.d.ts +0 -2
- package/dist/database/system-data/collections/index.js +0 -9
- package/dist/database/system-data/fields/_defaults.yaml +0 -16
- package/dist/database/system-data/fields/activity.yaml +0 -83
- package/dist/database/system-data/fields/collections.yaml +0 -214
- package/dist/database/system-data/fields/dashboards.yaml +0 -20
- package/dist/database/system-data/fields/fields.yaml +0 -104
- package/dist/database/system-data/fields/files.yaml +0 -144
- package/dist/database/system-data/fields/flows.yaml +0 -26
- package/dist/database/system-data/fields/folders.yaml +0 -14
- package/dist/database/system-data/fields/index.d.ts +0 -2
- package/dist/database/system-data/fields/index.js +0 -37
- package/dist/database/system-data/fields/migrations.yaml +0 -10
- package/dist/database/system-data/fields/notifications.yaml +0 -15
- package/dist/database/system-data/fields/operations.yaml +0 -23
- package/dist/database/system-data/fields/panels.yaml +0 -29
- package/dist/database/system-data/fields/permissions.yaml +0 -37
- package/dist/database/system-data/fields/presets.yaml +0 -56
- package/dist/database/system-data/fields/relations.yaml +0 -34
- package/dist/database/system-data/fields/revisions.yaml +0 -27
- package/dist/database/system-data/fields/roles.yaml +0 -61
- package/dist/database/system-data/fields/sessions.yaml +0 -16
- package/dist/database/system-data/fields/settings.yaml +0 -413
- package/dist/database/system-data/fields/shares.yaml +0 -83
- package/dist/database/system-data/fields/users.yaml +0 -182
- package/dist/database/system-data/fields/webhooks.yaml +0 -141
- package/dist/database/system-data/relations/index.d.ts +0 -2
- package/dist/database/system-data/relations/index.js +0 -9
- package/dist/database/system-data/relations/relations.yaml +0 -125
- package/dist/emitter.d.ts +0 -19
- package/dist/emitter.js +0 -86
- package/dist/env.d.ts +0 -15
- package/dist/env.js +0 -466
- package/dist/env.test.d.ts +0 -1
- package/dist/exceptions/database/contains-null-values.d.ts +0 -9
- package/dist/exceptions/database/contains-null-values.js +0 -10
- package/dist/exceptions/database/dialects/mssql.d.ts +0 -2
- package/dist/exceptions/database/dialects/mssql.js +0 -159
- package/dist/exceptions/database/dialects/mysql.d.ts +0 -2
- package/dist/exceptions/database/dialects/mysql.js +0 -148
- package/dist/exceptions/database/dialects/oracle.d.ts +0 -2
- package/dist/exceptions/database/dialects/oracle.js +0 -27
- package/dist/exceptions/database/dialects/postgres.d.ts +0 -2
- package/dist/exceptions/database/dialects/postgres.js +0 -106
- package/dist/exceptions/database/dialects/sqlite.d.ts +0 -2
- package/dist/exceptions/database/dialects/sqlite.js +0 -55
- package/dist/exceptions/database/dialects/types.d.ts +0 -41
- package/dist/exceptions/database/dialects/types.js +0 -2
- package/dist/exceptions/database/invalid-foreign-key.d.ts +0 -10
- package/dist/exceptions/database/invalid-foreign-key.js +0 -15
- package/dist/exceptions/database/not-null-violation.d.ts +0 -9
- package/dist/exceptions/database/not-null-violation.js +0 -10
- package/dist/exceptions/database/record-not-unique.d.ts +0 -10
- package/dist/exceptions/database/record-not-unique.js +0 -15
- package/dist/exceptions/database/translate.d.ts +0 -11
- package/dist/exceptions/database/translate.js +0 -74
- package/dist/exceptions/database/value-out-of-range.d.ts +0 -10
- package/dist/exceptions/database/value-out-of-range.js +0 -15
- package/dist/exceptions/database/value-too-long.d.ts +0 -9
- package/dist/exceptions/database/value-too-long.js +0 -15
- package/dist/exceptions/forbidden.d.ts +0 -4
- package/dist/exceptions/forbidden.js +0 -16
- package/dist/exceptions/graphql-validation.d.ts +0 -4
- package/dist/exceptions/graphql-validation.js +0 -10
- package/dist/exceptions/hit-rate-limit.d.ts +0 -9
- package/dist/exceptions/hit-rate-limit.js +0 -10
- package/dist/exceptions/illegal-asset-transformation.d.ts +0 -4
- package/dist/exceptions/illegal-asset-transformation.js +0 -10
- package/dist/exceptions/index.d.ts +0 -21
- package/dist/exceptions/index.js +0 -37
- package/dist/exceptions/invalid-config.d.ts +0 -4
- package/dist/exceptions/invalid-config.js +0 -10
- package/dist/exceptions/invalid-credentials.d.ts +0 -4
- package/dist/exceptions/invalid-credentials.js +0 -10
- package/dist/exceptions/invalid-ip.d.ts +0 -4
- package/dist/exceptions/invalid-ip.js +0 -10
- package/dist/exceptions/invalid-otp.d.ts +0 -4
- package/dist/exceptions/invalid-otp.js +0 -10
- package/dist/exceptions/invalid-payload.d.ts +0 -4
- package/dist/exceptions/invalid-payload.js +0 -10
- package/dist/exceptions/invalid-provider.d.ts +0 -4
- package/dist/exceptions/invalid-provider.js +0 -10
- package/dist/exceptions/invalid-query.d.ts +0 -4
- package/dist/exceptions/invalid-query.js +0 -10
- package/dist/exceptions/invalid-token.d.ts +0 -4
- package/dist/exceptions/invalid-token.js +0 -10
- package/dist/exceptions/method-not-allowed.d.ts +0 -8
- package/dist/exceptions/method-not-allowed.js +0 -10
- package/dist/exceptions/range-not-satisfiable.d.ts +0 -5
- package/dist/exceptions/range-not-satisfiable.js +0 -13
- package/dist/exceptions/route-not-found.d.ts +0 -4
- package/dist/exceptions/route-not-found.js +0 -10
- package/dist/exceptions/service-unavailable.d.ts +0 -9
- package/dist/exceptions/service-unavailable.js +0 -10
- package/dist/exceptions/token-expired.d.ts +0 -4
- package/dist/exceptions/token-expired.js +0 -10
- package/dist/exceptions/unexpected-response.d.ts +0 -4
- package/dist/exceptions/unexpected-response.js +0 -10
- package/dist/exceptions/unprocessable-entity.d.ts +0 -4
- package/dist/exceptions/unprocessable-entity.js +0 -10
- package/dist/exceptions/unsupported-media-type.d.ts +0 -4
- package/dist/exceptions/unsupported-media-type.js +0 -10
- package/dist/exceptions/user-suspended.d.ts +0 -4
- package/dist/exceptions/user-suspended.js +0 -10
- package/dist/extensions.d.ts +0 -49
- package/dist/extensions.js +0 -501
- package/dist/flows.d.ts +0 -22
- package/dist/flows.js +0 -377
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -24
- package/dist/logger.d.ts +0 -7
- package/dist/logger.js +0 -134
- package/dist/logger.test.d.ts +0 -1
- package/dist/mailer.d.ts +0 -2
- package/dist/mailer.js +0 -71
- package/dist/messenger.d.ts +0 -24
- package/dist/messenger.js +0 -66
- package/dist/middleware/authenticate.d.ts +0 -8
- package/dist/middleware/authenticate.js +0 -82
- package/dist/middleware/authenticate.test.d.ts +0 -1
- package/dist/middleware/cache.d.ts +0 -3
- package/dist/middleware/cache.js +0 -61
- package/dist/middleware/check-ip.d.ts +0 -2
- package/dist/middleware/check-ip.js +0 -24
- package/dist/middleware/collection-exists.d.ts +0 -6
- package/dist/middleware/collection-exists.js +0 -30
- package/dist/middleware/cors.d.ts +0 -3
- package/dist/middleware/cors.js +0 -19
- package/dist/middleware/error-handler.d.ts +0 -3
- package/dist/middleware/error-handler.js +0 -95
- package/dist/middleware/extract-token.d.ts +0 -11
- package/dist/middleware/extract-token.js +0 -32
- package/dist/middleware/extract-token.test.d.ts +0 -1
- package/dist/middleware/get-permissions.d.ts +0 -3
- package/dist/middleware/get-permissions.js +0 -15
- package/dist/middleware/graphql.d.ts +0 -2
- package/dist/middleware/graphql.js +0 -69
- package/dist/middleware/rate-limiter-global.d.ts +0 -5
- package/dist/middleware/rate-limiter-global.js +0 -48
- package/dist/middleware/rate-limiter-ip.d.ts +0 -5
- package/dist/middleware/rate-limiter-ip.js +0 -34
- package/dist/middleware/respond.d.ts +0 -2
- package/dist/middleware/respond.js +0 -88
- package/dist/middleware/sanitize-query.d.ts +0 -7
- package/dist/middleware/sanitize-query.js +0 -21
- package/dist/middleware/schema.d.ts +0 -3
- package/dist/middleware/schema.js +0 -12
- package/dist/middleware/use-collection.d.ts +0 -7
- package/dist/middleware/use-collection.js +0 -11
- package/dist/middleware/validate-batch.d.ts +0 -3
- package/dist/middleware/validate-batch.js +0 -49
- package/dist/middleware/validate-batch.test.d.ts +0 -1
- package/dist/operations/condition/index.d.ts +0 -6
- package/dist/operations/condition/index.js +0 -15
- package/dist/operations/condition/index.test.d.ts +0 -1
- package/dist/operations/exec/index.d.ts +0 -5
- package/dist/operations/exec/index.js +0 -40
- package/dist/operations/exec/index.test.d.ts +0 -1
- package/dist/operations/item-create/index.d.ts +0 -8
- package/dist/operations/item-create/index.js +0 -38
- package/dist/operations/item-create/index.test.d.ts +0 -1
- package/dist/operations/item-delete/index.d.ts +0 -10
- package/dist/operations/item-delete/index.js +0 -46
- package/dist/operations/item-delete/index.test.d.ts +0 -1
- package/dist/operations/item-read/index.d.ts +0 -10
- package/dist/operations/item-read/index.js +0 -46
- package/dist/operations/item-read/index.test.d.ts +0 -1
- package/dist/operations/item-update/index.d.ts +0 -11
- package/dist/operations/item-update/index.js +0 -50
- package/dist/operations/item-update/index.test.d.ts +0 -1
- package/dist/operations/log/index.d.ts +0 -5
- package/dist/operations/log/index.js +0 -13
- package/dist/operations/log/index.test.d.ts +0 -1
- package/dist/operations/mail/index.d.ts +0 -8
- package/dist/operations/mail/index.js +0 -19
- package/dist/operations/notification/index.d.ts +0 -8
- package/dist/operations/notification/index.js +0 -40
- package/dist/operations/notification/index.test.d.ts +0 -1
- package/dist/operations/request/index.d.ts +0 -11
- package/dist/operations/request/index.js +0 -38
- package/dist/operations/request/index.test.d.ts +0 -1
- package/dist/operations/sleep/index.d.ts +0 -5
- package/dist/operations/sleep/index.js +0 -9
- package/dist/operations/sleep/index.test.d.ts +0 -1
- package/dist/operations/transform/index.d.ts +0 -5
- package/dist/operations/transform/index.js +0 -9
- package/dist/operations/transform/index.test.d.ts +0 -1
- package/dist/operations/trigger/index.d.ts +0 -8
- package/dist/operations/trigger/index.js +0 -39
- package/dist/operations/trigger/index.test.d.ts +0 -1
- package/dist/rate-limiter.d.ts +0 -4
- package/dist/rate-limiter.js +0 -38
- package/dist/request/index.d.ts +0 -5
- package/dist/request/index.js +0 -18
- package/dist/request/index.test.d.ts +0 -1
- package/dist/request/request-interceptor.d.ts +0 -2
- package/dist/request/request-interceptor.js +0 -33
- package/dist/request/request-interceptor.test.d.ts +0 -1
- package/dist/request/response-interceptor.d.ts +0 -2
- package/dist/request/response-interceptor.js +0 -9
- package/dist/request/response-interceptor.test.d.ts +0 -1
- package/dist/request/validate-ip.d.ts +0 -1
- package/dist/request/validate-ip.js +0 -27
- package/dist/request/validate-ip.test.d.ts +0 -1
- package/dist/server.d.ts +0 -4
- package/dist/server.js +0 -162
- package/dist/services/activity.d.ts +0 -10
- package/dist/services/activity.js +0 -101
- package/dist/services/assets.d.ts +0 -18
- package/dist/services/assets.js +0 -179
- package/dist/services/authentication.d.ts +0 -21
- package/dist/services/authentication.js +0 -332
- package/dist/services/authorization.d.ts +0 -17
- package/dist/services/authorization.js +0 -451
- package/dist/services/collections.d.ts +0 -64
- package/dist/services/collections.js +0 -595
- package/dist/services/dashboards.d.ts +0 -5
- package/dist/services/dashboards.js +0 -10
- package/dist/services/fields.d.ts +0 -32
- package/dist/services/fields.js +0 -625
- package/dist/services/fields.test.d.ts +0 -1
- package/dist/services/files.d.ts +0 -34
- package/dist/services/files.js +0 -280
- package/dist/services/files.test.d.ts +0 -1
- package/dist/services/flows.d.ts +0 -11
- package/dist/services/flows.js +0 -43
- package/dist/services/flows.test.d.ts +0 -1
- package/dist/services/folders.d.ts +0 -5
- package/dist/services/folders.js +0 -10
- package/dist/services/graphql/index.d.ts +0 -86
- package/dist/services/graphql/index.js +0 -2519
- package/dist/services/graphql/types/bigint.d.ts +0 -2
- package/dist/services/graphql/types/bigint.js +0 -39
- package/dist/services/graphql/types/date.d.ts +0 -2
- package/dist/services/graphql/types/date.js +0 -9
- package/dist/services/graphql/types/geojson.d.ts +0 -2
- package/dist/services/graphql/types/geojson.js +0 -10
- package/dist/services/graphql/types/hash.d.ts +0 -2
- package/dist/services/graphql/types/hash.js +0 -9
- package/dist/services/graphql/types/string-or-float.d.ts +0 -5
- package/dist/services/graphql/types/string-or-float.js +0 -34
- package/dist/services/graphql/types/void.d.ts +0 -2
- package/dist/services/graphql/types/void.js +0 -17
- package/dist/services/graphql/utils/add-path-to-validation-error.d.ts +0 -2
- package/dist/services/graphql/utils/add-path-to-validation-error.js +0 -19
- package/dist/services/graphql/utils/process-error.d.ts +0 -4
- package/dist/services/graphql/utils/process-error.js +0 -46
- package/dist/services/graphql/utils/process-error.test.d.ts +0 -1
- package/dist/services/import-export.d.ts +0 -37
- package/dist/services/import-export.js +0 -300
- package/dist/services/import-export.test.d.ts +0 -1
- package/dist/services/index.d.ts +0 -33
- package/dist/services/index.js +0 -50
- package/dist/services/items.d.ts +0 -83
- package/dist/services/items.js +0 -719
- package/dist/services/items.test.d.ts +0 -1
- package/dist/services/mail/index.d.ts +0 -20
- package/dist/services/mail/index.js +0 -96
- package/dist/services/mail/templates/base.liquid +0 -162
- package/dist/services/mail/templates/password-reset.liquid +0 -24
- package/dist/services/mail/templates/user-invitation.liquid +0 -19
- package/dist/services/meta.d.ts +0 -12
- package/dist/services/meta.js +0 -78
- package/dist/services/notifications.d.ts +0 -13
- package/dist/services/notifications.js +0 -59
- package/dist/services/notifications.test.d.ts +0 -1
- package/dist/services/operations.d.ts +0 -11
- package/dist/services/operations.js +0 -41
- package/dist/services/operations.test.d.ts +0 -1
- package/dist/services/panels.d.ts +0 -5
- package/dist/services/panels.js +0 -10
- package/dist/services/payload.d.ts +0 -73
- package/dist/services/payload.js +0 -644
- package/dist/services/payload.test.d.ts +0 -1
- package/dist/services/permissions.d.ts +0 -17
- package/dist/services/permissions.js +0 -84
- package/dist/services/permissions.test.d.ts +0 -1
- package/dist/services/presets.d.ts +0 -5
- package/dist/services/presets.js +0 -10
- package/dist/services/relations.d.ts +0 -60
- package/dist/services/relations.js +0 -477
- package/dist/services/revisions.d.ts +0 -6
- package/dist/services/revisions.js +0 -24
- package/dist/services/roles.d.ts +0 -14
- package/dist/services/roles.js +0 -148
- package/dist/services/roles.test.d.ts +0 -1
- package/dist/services/schema.d.ts +0 -15
- package/dist/services/schema.js +0 -56
- package/dist/services/schema.test.d.ts +0 -1
- package/dist/services/server.d.ts +0 -13
- package/dist/services/server.js +0 -366
- package/dist/services/settings.d.ts +0 -5
- package/dist/services/settings.js +0 -10
- package/dist/services/shares.d.ts +0 -17
- package/dist/services/shares.js +0 -136
- package/dist/services/specifications.d.ts +0 -53
- package/dist/services/specifications.js +0 -500
- package/dist/services/specifications.test.d.ts +0 -1
- package/dist/services/tfa.d.ts +0 -12
- package/dist/services/tfa.js +0 -57
- package/dist/services/users.d.ts +0 -55
- package/dist/services/users.js +0 -380
- package/dist/services/users.test.d.ts +0 -1
- package/dist/services/utils.d.ts +0 -13
- package/dist/services/utils.js +0 -115
- package/dist/services/webhooks.d.ts +0 -11
- package/dist/services/webhooks.js +0 -33
- package/dist/services/webhooks.test.d.ts +0 -1
- package/dist/start.d.ts +0 -1
- package/dist/start.js +0 -4
- package/dist/storage/get-storage-driver.d.ts +0 -3
- package/dist/storage/get-storage-driver.js +0 -20
- package/dist/storage/get-storage-driver.test.d.ts +0 -1
- package/dist/storage/index.d.ts +0 -5
- package/dist/storage/index.js +0 -20
- package/dist/storage/index.test.d.ts +0 -1
- package/dist/storage/register-drivers.d.ts +0 -2
- package/dist/storage/register-drivers.js +0 -22
- package/dist/storage/register-drivers.test.d.ts +0 -1
- package/dist/storage/register-locations.d.ts +0 -2
- package/dist/storage/register-locations.js +0 -17
- package/dist/storage/register-locations.test.d.ts +0 -1
- package/dist/types/assets.d.ts +0 -20
- package/dist/types/assets.js +0 -54
- package/dist/types/ast.d.ts +0 -56
- package/dist/types/ast.js +0 -2
- package/dist/types/auth.d.ts +0 -54
- package/dist/types/auth.js +0 -2
- package/dist/types/collection.d.ts +0 -19
- package/dist/types/collection.js +0 -2
- package/dist/types/database.d.ts +0 -3
- package/dist/types/database.js +0 -4
- package/dist/types/events.d.ts +0 -18
- package/dist/types/events.js +0 -2
- package/dist/types/files.d.ts +0 -29
- package/dist/types/files.js +0 -2
- package/dist/types/graphql.d.ts +0 -14
- package/dist/types/graphql.js +0 -2
- package/dist/types/index.d.ts +0 -15
- package/dist/types/index.js +0 -31
- package/dist/types/items.d.ts +0 -49
- package/dist/types/items.js +0 -6
- package/dist/types/meta.d.ts +0 -4
- package/dist/types/meta.js +0 -8
- package/dist/types/migration.d.ts +0 -5
- package/dist/types/migration.js +0 -2
- package/dist/types/revision.d.ts +0 -7
- package/dist/types/revision.js +0 -2
- package/dist/types/services.d.ts +0 -21
- package/dist/types/services.js +0 -2
- package/dist/types/snapshot.d.ts +0 -55
- package/dist/types/snapshot.js +0 -16
- package/dist/types/webhooks.d.ts +0 -15
- package/dist/types/webhooks.js +0 -2
- package/dist/utils/apply-diff.d.ts +0 -9
- package/dist/utils/apply-diff.js +0 -256
- package/dist/utils/apply-diff.test.d.ts +0 -1
- package/dist/utils/apply-function-to-column-name.d.ts +0 -12
- package/dist/utils/apply-function-to-column-name.js +0 -26
- package/dist/utils/apply-function-to-column-name.test.d.ts +0 -1
- package/dist/utils/apply-query.d.ts +0 -34
- package/dist/utils/apply-query.js +0 -568
- package/dist/utils/apply-snapshot.d.ts +0 -9
- package/dist/utils/apply-snapshot.js +0 -22
- package/dist/utils/apply-snapshot.test.d.ts +0 -1
- package/dist/utils/async-handler.d.ts +0 -3
- package/dist/utils/async-handler.js +0 -4
- package/dist/utils/async-handler.test.d.ts +0 -1
- package/dist/utils/calculate-field-depth.d.ts +0 -33
- package/dist/utils/calculate-field-depth.js +0 -75
- package/dist/utils/calculate-field-depth.test.d.ts +0 -1
- package/dist/utils/compress.d.ts +0 -3
- package/dist/utils/compress.js +0 -17
- package/dist/utils/construct-flow-tree.d.ts +0 -2
- package/dist/utils/construct-flow-tree.js +0 -31
- package/dist/utils/dynamic-import.d.ts +0 -1
- package/dist/utils/dynamic-import.js +0 -7
- package/dist/utils/filter-items.d.ts +0 -2
- package/dist/utils/filter-items.js +0 -37
- package/dist/utils/filter-items.test.d.ts +0 -1
- package/dist/utils/generate-hash.d.ts +0 -1
- package/dist/utils/generate-hash.js +0 -16
- package/dist/utils/get-accountability-for-role.d.ts +0 -7
- package/dist/utils/get-accountability-for-role.js +0 -45
- package/dist/utils/get-ast-from-query.d.ts +0 -13
- package/dist/utils/get-ast-from-query.js +0 -300
- package/dist/utils/get-auth-providers.d.ts +0 -8
- package/dist/utils/get-auth-providers.js +0 -19
- package/dist/utils/get-auth-providers.test.d.ts +0 -1
- package/dist/utils/get-cache-headers.d.ts +0 -10
- package/dist/utils/get-cache-headers.js +0 -43
- package/dist/utils/get-cache-headers.test.d.ts +0 -1
- package/dist/utils/get-cache-key.d.ts +0 -2
- package/dist/utils/get-cache-key.js +0 -21
- package/dist/utils/get-cache-key.test.d.ts +0 -1
- package/dist/utils/get-collection-from-alias.d.ts +0 -6
- package/dist/utils/get-collection-from-alias.js +0 -16
- package/dist/utils/get-collection-from-alias.test.d.ts +0 -1
- package/dist/utils/get-column-path.d.ts +0 -26
- package/dist/utils/get-column-path.js +0 -65
- package/dist/utils/get-column-path.test.d.ts +0 -1
- package/dist/utils/get-column.d.ts +0 -20
- package/dist/utils/get-column.js +0 -52
- package/dist/utils/get-config-from-env.d.ts +0 -1
- package/dist/utils/get-config-from-env.js +0 -48
- package/dist/utils/get-config-from-env.test.d.ts +0 -1
- package/dist/utils/get-date-formatted.d.ts +0 -1
- package/dist/utils/get-date-formatted.js +0 -14
- package/dist/utils/get-date-formatted.test.d.ts +0 -1
- package/dist/utils/get-default-index-name.d.ts +0 -10
- package/dist/utils/get-default-index-name.js +0 -25
- package/dist/utils/get-default-value.d.ts +0 -3
- package/dist/utils/get-default-value.js +0 -62
- package/dist/utils/get-graphql-query-and-variables.d.ts +0 -2
- package/dist/utils/get-graphql-query-and-variables.js +0 -9
- package/dist/utils/get-graphql-query-and-variables.test.d.ts +0 -1
- package/dist/utils/get-graphql-type.d.ts +0 -3
- package/dist/utils/get-graphql-type.js +0 -40
- package/dist/utils/get-ip-from-req.d.ts +0 -2
- package/dist/utils/get-ip-from-req.js +0 -24
- package/dist/utils/get-local-type.d.ts +0 -9
- package/dist/utils/get-local-type.js +0 -131
- package/dist/utils/get-milliseconds.d.ts +0 -4
- package/dist/utils/get-milliseconds.js +0 -14
- package/dist/utils/get-milliseconds.test.d.ts +0 -1
- package/dist/utils/get-module-default.d.ts +0 -3
- package/dist/utils/get-module-default.js +0 -9
- package/dist/utils/get-os-info.d.ts +0 -9
- package/dist/utils/get-os-info.js +0 -47
- package/dist/utils/get-permissions.d.ts +0 -2
- package/dist/utils/get-permissions.js +0 -158
- package/dist/utils/get-relation-info.d.ts +0 -7
- package/dist/utils/get-relation-info.js +0 -49
- package/dist/utils/get-relation-info.test.d.ts +0 -1
- package/dist/utils/get-relation-type.d.ts +0 -6
- package/dist/utils/get-relation-type.js +0 -22
- package/dist/utils/get-relation-type.test.d.ts +0 -1
- package/dist/utils/get-schema.d.ts +0 -10
- package/dist/utils/get-schema.js +0 -138
- package/dist/utils/get-snapshot-diff.d.ts +0 -2
- package/dist/utils/get-snapshot-diff.js +0 -82
- package/dist/utils/get-snapshot.d.ts +0 -7
- package/dist/utils/get-snapshot.js +0 -80
- package/dist/utils/get-string-byte-size.d.ts +0 -4
- package/dist/utils/get-string-byte-size.js +0 -10
- package/dist/utils/get-string-byte-size.test.d.ts +0 -1
- package/dist/utils/get-versioned-hash.d.ts +0 -1
- package/dist/utils/get-versioned-hash.js +0 -12
- package/dist/utils/get-versioned-hash.test.d.ts +0 -1
- package/dist/utils/is-directus-jwt.d.ts +0 -5
- package/dist/utils/is-directus-jwt.js +0 -22
- package/dist/utils/is-directus-jwt.test.d.ts +0 -1
- package/dist/utils/is-url-allowed.d.ts +0 -4
- package/dist/utils/is-url-allowed.js +0 -36
- package/dist/utils/job-queue.d.ts +0 -9
- package/dist/utils/job-queue.js +0 -26
- package/dist/utils/jwt.d.ts +0 -2
- package/dist/utils/jwt.js +0 -53
- package/dist/utils/jwt.test.d.ts +0 -1
- package/dist/utils/map-values-deep.d.ts +0 -1
- package/dist/utils/map-values-deep.js +0 -29
- package/dist/utils/map-values-deep.test.d.ts +0 -1
- package/dist/utils/md.d.ts +0 -4
- package/dist/utils/md.js +0 -15
- package/dist/utils/md.test.d.ts +0 -1
- package/dist/utils/merge-permissions-for-share.d.ts +0 -4
- package/dist/utils/merge-permissions-for-share.js +0 -115
- package/dist/utils/merge-permissions.d.ts +0 -14
- package/dist/utils/merge-permissions.js +0 -100
- package/dist/utils/merge-permissions.test.d.ts +0 -1
- package/dist/utils/parse-image-metadata.d.ts +0 -3
- package/dist/utils/parse-image-metadata.js +0 -73
- package/dist/utils/reduce-schema.d.ts +0 -9
- package/dist/utils/reduce-schema.js +0 -82
- package/dist/utils/require-yaml.d.ts +0 -1
- package/dist/utils/require-yaml.js +0 -13
- package/dist/utils/sanitize-query.d.ts +0 -2
- package/dist/utils/sanitize-query.js +0 -179
- package/dist/utils/sanitize-query.test.d.ts +0 -1
- package/dist/utils/sanitize-schema.d.ts +0 -30
- package/dist/utils/sanitize-schema.js +0 -80
- package/dist/utils/sanitize-schema.test.d.ts +0 -1
- package/dist/utils/should-skip-cache.d.ts +0 -7
- package/dist/utils/should-skip-cache.js +0 -30
- package/dist/utils/should-skip-cache.test.d.ts +0 -1
- package/dist/utils/stall.d.ts +0 -26
- package/dist/utils/stall.js +0 -38
- package/dist/utils/stall.test.d.ts +0 -1
- package/dist/utils/strip-function.d.ts +0 -4
- package/dist/utils/strip-function.js +0 -16
- package/dist/utils/strip-function.test.d.ts +0 -1
- package/dist/utils/telemetry.d.ts +0 -1
- package/dist/utils/telemetry.js +0 -30
- package/dist/utils/transformations.d.ts +0 -6
- package/dist/utils/transformations.js +0 -55
- package/dist/utils/url.d.ts +0 -17
- package/dist/utils/url.js +0 -63
- package/dist/utils/url.test.d.ts +0 -1
- package/dist/utils/user-name.d.ts +0 -2
- package/dist/utils/user-name.js +0 -19
- package/dist/utils/user-name.test.d.ts +0 -1
- package/dist/utils/validate-diff.d.ts +0 -7
- package/dist/utils/validate-diff.js +0 -113
- package/dist/utils/validate-diff.test.d.ts +0 -1
- package/dist/utils/validate-env.d.ts +0 -1
- package/dist/utils/validate-env.js +0 -18
- package/dist/utils/validate-env.test.d.ts +0 -1
- package/dist/utils/validate-keys.d.ts +0 -6
- package/dist/utils/validate-keys.js +0 -28
- package/dist/utils/validate-keys.test.d.ts +0 -1
- package/dist/utils/validate-query.d.ts +0 -2
- package/dist/utils/validate-query.js +0 -205
- package/dist/utils/validate-query.test.d.ts +0 -1
- package/dist/utils/validate-snapshot.d.ts +0 -5
- package/dist/utils/validate-snapshot.js +0 -71
- package/dist/utils/validate-snapshot.test.d.ts +0 -1
- package/dist/utils/validate-storage.d.ts +0 -1
- package/dist/utils/validate-storage.js +0 -38
- package/dist/webhooks.d.ts +0 -4
- package/dist/webhooks.js +0 -89
|
@@ -1,2519 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GraphQLService = void 0;
|
|
7
|
-
const constants_1 = require("@directus/shared/constants");
|
|
8
|
-
const types_1 = require("@directus/shared/types");
|
|
9
|
-
const utils_1 = require("@directus/shared/utils");
|
|
10
|
-
const argon2_1 = __importDefault(require("argon2"));
|
|
11
|
-
const graphql_1 = require("graphql");
|
|
12
|
-
const graphql_compose_1 = require("graphql-compose");
|
|
13
|
-
const lodash_1 = require("lodash");
|
|
14
|
-
const cache_1 = require("../../cache");
|
|
15
|
-
const constants_2 = require("../../constants");
|
|
16
|
-
const database_1 = __importDefault(require("../../database"));
|
|
17
|
-
const env_1 = __importDefault(require("../../env"));
|
|
18
|
-
const exceptions_1 = require("../../exceptions");
|
|
19
|
-
const extensions_1 = require("../../extensions");
|
|
20
|
-
const generate_hash_1 = require("../../utils/generate-hash");
|
|
21
|
-
const get_graphql_type_1 = require("../../utils/get-graphql-type");
|
|
22
|
-
const get_milliseconds_1 = require("../../utils/get-milliseconds");
|
|
23
|
-
const reduce_schema_1 = require("../../utils/reduce-schema");
|
|
24
|
-
const sanitize_query_1 = require("../../utils/sanitize-query");
|
|
25
|
-
const validate_query_1 = require("../../utils/validate-query");
|
|
26
|
-
const activity_1 = require("../activity");
|
|
27
|
-
const authentication_1 = require("../authentication");
|
|
28
|
-
const collections_1 = require("../collections");
|
|
29
|
-
const fields_1 = require("../fields");
|
|
30
|
-
const files_1 = require("../files");
|
|
31
|
-
const flows_1 = require("../flows");
|
|
32
|
-
const folders_1 = require("../folders");
|
|
33
|
-
const items_1 = require("../items");
|
|
34
|
-
const notifications_1 = require("../notifications");
|
|
35
|
-
const operations_1 = require("../operations");
|
|
36
|
-
const permissions_1 = require("../permissions");
|
|
37
|
-
const presets_1 = require("../presets");
|
|
38
|
-
const relations_1 = require("../relations");
|
|
39
|
-
const revisions_1 = require("../revisions");
|
|
40
|
-
const roles_1 = require("../roles");
|
|
41
|
-
const server_1 = require("../server");
|
|
42
|
-
const settings_1 = require("../settings");
|
|
43
|
-
const shares_1 = require("../shares");
|
|
44
|
-
const specifications_1 = require("../specifications");
|
|
45
|
-
const tfa_1 = require("../tfa");
|
|
46
|
-
const users_1 = require("../users");
|
|
47
|
-
const utils_2 = require("../utils");
|
|
48
|
-
const webhooks_1 = require("../webhooks");
|
|
49
|
-
const bigint_1 = require("./types/bigint");
|
|
50
|
-
const date_1 = require("./types/date");
|
|
51
|
-
const geojson_1 = require("./types/geojson");
|
|
52
|
-
const hash_1 = require("./types/hash");
|
|
53
|
-
const string_or_float_1 = require("./types/string-or-float");
|
|
54
|
-
const void_1 = require("./types/void");
|
|
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
|
-
const validationRules = Array.from(graphql_1.specifiedRules);
|
|
58
|
-
if (env_1.default['GRAPHQL_INTROSPECTION'] === false) {
|
|
59
|
-
validationRules.push(graphql_1.NoSchemaIntrospectionCustomRule);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* These should be ignored in the context of GraphQL, and/or are replaced by a custom resolver (for non-standard structures)
|
|
63
|
-
*/
|
|
64
|
-
const SYSTEM_DENY_LIST = [
|
|
65
|
-
'directus_collections',
|
|
66
|
-
'directus_fields',
|
|
67
|
-
'directus_relations',
|
|
68
|
-
'directus_migrations',
|
|
69
|
-
'directus_sessions',
|
|
70
|
-
];
|
|
71
|
-
const READ_ONLY = ['directus_activity', 'directus_revisions'];
|
|
72
|
-
class GraphQLService {
|
|
73
|
-
accountability;
|
|
74
|
-
knex;
|
|
75
|
-
schema;
|
|
76
|
-
scope;
|
|
77
|
-
constructor(options) {
|
|
78
|
-
this.accountability = options?.accountability || null;
|
|
79
|
-
this.knex = options?.knex || (0, database_1.default)();
|
|
80
|
-
this.schema = options.schema;
|
|
81
|
-
this.scope = options.scope;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Execute a GraphQL structure
|
|
85
|
-
*/
|
|
86
|
-
async execute({ document, variables, operationName, contextValue, }) {
|
|
87
|
-
const schema = this.getSchema();
|
|
88
|
-
const validationErrors = (0, graphql_1.validate)(schema, document, validationRules).map((validationError) => (0, add_path_to_validation_error_1.addPathToValidationError)(validationError));
|
|
89
|
-
if (validationErrors.length > 0) {
|
|
90
|
-
throw new exceptions_1.GraphQLValidationException({ graphqlErrors: validationErrors });
|
|
91
|
-
}
|
|
92
|
-
let result;
|
|
93
|
-
try {
|
|
94
|
-
result = await (0, graphql_1.execute)({
|
|
95
|
-
schema,
|
|
96
|
-
document,
|
|
97
|
-
contextValue,
|
|
98
|
-
variableValues: variables,
|
|
99
|
-
operationName,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
throw new exceptions_1.InvalidPayloadException('GraphQL execution error.', { graphqlErrors: [err.message] });
|
|
104
|
-
}
|
|
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'];
|
|
112
|
-
return formattedResult;
|
|
113
|
-
}
|
|
114
|
-
getSchema(type = 'schema') {
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
116
|
-
const self = this;
|
|
117
|
-
const schemaComposer = new graphql_compose_1.SchemaComposer();
|
|
118
|
-
const schema = {
|
|
119
|
-
read: this.accountability?.admin === true
|
|
120
|
-
? this.schema
|
|
121
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['read']),
|
|
122
|
-
create: this.accountability?.admin === true
|
|
123
|
-
? this.schema
|
|
124
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['create']),
|
|
125
|
-
update: this.accountability?.admin === true
|
|
126
|
-
? this.schema
|
|
127
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['update']),
|
|
128
|
-
delete: this.accountability?.admin === true
|
|
129
|
-
? this.schema
|
|
130
|
-
: (0, reduce_schema_1.reduceSchema)(this.schema, this.accountability?.permissions || null, ['delete']),
|
|
131
|
-
};
|
|
132
|
-
const { ReadCollectionTypes } = getReadableTypes();
|
|
133
|
-
const { CreateCollectionTypes, UpdateCollectionTypes, DeleteCollectionTypes } = getWritableTypes();
|
|
134
|
-
const scopeFilter = (collection) => {
|
|
135
|
-
if (this.scope === 'items' && collection.collection.startsWith('directus_') === true)
|
|
136
|
-
return false;
|
|
137
|
-
if (this.scope === 'system') {
|
|
138
|
-
if (collection.collection.startsWith('directus_') === false)
|
|
139
|
-
return false;
|
|
140
|
-
if (SYSTEM_DENY_LIST.includes(collection.collection))
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
return true;
|
|
144
|
-
};
|
|
145
|
-
if (this.scope === 'system') {
|
|
146
|
-
this.injectSystemResolvers(schemaComposer, {
|
|
147
|
-
CreateCollectionTypes,
|
|
148
|
-
ReadCollectionTypes,
|
|
149
|
-
UpdateCollectionTypes,
|
|
150
|
-
DeleteCollectionTypes,
|
|
151
|
-
}, schema);
|
|
152
|
-
}
|
|
153
|
-
const readableCollections = Object.values(schema.read.collections)
|
|
154
|
-
.filter((collection) => collection.collection in ReadCollectionTypes)
|
|
155
|
-
.filter(scopeFilter);
|
|
156
|
-
if (readableCollections.length > 0) {
|
|
157
|
-
schemaComposer.Query.addFields(readableCollections.reduce((acc, collection) => {
|
|
158
|
-
const collectionName = this.scope === 'items' ? collection.collection : collection.collection.substring(9);
|
|
159
|
-
acc[collectionName] = ReadCollectionTypes[collection.collection].getResolver(collection.collection);
|
|
160
|
-
if (this.schema.collections[collection.collection].singleton === false) {
|
|
161
|
-
acc[`${collectionName}_by_id`] = ReadCollectionTypes[collection.collection].getResolver(`${collection.collection}_by_id`);
|
|
162
|
-
acc[`${collectionName}_aggregated`] = ReadCollectionTypes[collection.collection].getResolver(`${collection.collection}_aggregated`);
|
|
163
|
-
}
|
|
164
|
-
return acc;
|
|
165
|
-
}, {}));
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
schemaComposer.Query.addFields({
|
|
169
|
-
_empty: {
|
|
170
|
-
type: void_1.GraphQLVoid,
|
|
171
|
-
description: "There's no data to query.",
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (Object.keys(schema.create.collections).length > 0) {
|
|
176
|
-
schemaComposer.Mutation.addFields(Object.values(schema.create.collections)
|
|
177
|
-
.filter((collection) => collection.collection in CreateCollectionTypes && collection.singleton === false)
|
|
178
|
-
.filter(scopeFilter)
|
|
179
|
-
.filter((collection) => READ_ONLY.includes(collection.collection) === false)
|
|
180
|
-
.reduce((acc, collection) => {
|
|
181
|
-
const collectionName = this.scope === 'items' ? collection.collection : collection.collection.substring(9);
|
|
182
|
-
acc[`create_${collectionName}_items`] = CreateCollectionTypes[collection.collection].getResolver(`create_${collection.collection}_items`);
|
|
183
|
-
acc[`create_${collectionName}_item`] = CreateCollectionTypes[collection.collection].getResolver(`create_${collection.collection}_item`);
|
|
184
|
-
return acc;
|
|
185
|
-
}, {}));
|
|
186
|
-
}
|
|
187
|
-
if (Object.keys(schema.update.collections).length > 0) {
|
|
188
|
-
schemaComposer.Mutation.addFields(Object.values(schema.update.collections)
|
|
189
|
-
.filter((collection) => collection.collection in UpdateCollectionTypes)
|
|
190
|
-
.filter(scopeFilter)
|
|
191
|
-
.filter((collection) => READ_ONLY.includes(collection.collection) === false)
|
|
192
|
-
.reduce((acc, collection) => {
|
|
193
|
-
const collectionName = this.scope === 'items' ? collection.collection : collection.collection.substring(9);
|
|
194
|
-
if (collection.singleton) {
|
|
195
|
-
acc[`update_${collectionName}`] = UpdateCollectionTypes[collection.collection].getResolver(`update_${collection.collection}`);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
acc[`update_${collectionName}_items`] = UpdateCollectionTypes[collection.collection].getResolver(`update_${collection.collection}_items`);
|
|
199
|
-
acc[`update_${collectionName}_batch`] = UpdateCollectionTypes[collection.collection].getResolver(`update_${collection.collection}_batch`);
|
|
200
|
-
acc[`update_${collectionName}_item`] = UpdateCollectionTypes[collection.collection].getResolver(`update_${collection.collection}_item`);
|
|
201
|
-
}
|
|
202
|
-
return acc;
|
|
203
|
-
}, {}));
|
|
204
|
-
}
|
|
205
|
-
if (Object.keys(schema.delete.collections).length > 0) {
|
|
206
|
-
schemaComposer.Mutation.addFields(Object.values(schema.delete.collections)
|
|
207
|
-
.filter((collection) => collection.singleton === false)
|
|
208
|
-
.filter(scopeFilter)
|
|
209
|
-
.filter((collection) => READ_ONLY.includes(collection.collection) === false)
|
|
210
|
-
.reduce((acc, collection) => {
|
|
211
|
-
const collectionName = this.scope === 'items' ? collection.collection : collection.collection.substring(9);
|
|
212
|
-
acc[`delete_${collectionName}_items`] = DeleteCollectionTypes['many'].getResolver(`delete_${collection.collection}_items`);
|
|
213
|
-
acc[`delete_${collectionName}_item`] = DeleteCollectionTypes['one'].getResolver(`delete_${collection.collection}_item`);
|
|
214
|
-
return acc;
|
|
215
|
-
}, {}));
|
|
216
|
-
}
|
|
217
|
-
if (type === 'sdl') {
|
|
218
|
-
return schemaComposer.toSDL();
|
|
219
|
-
}
|
|
220
|
-
return schemaComposer.buildSchema();
|
|
221
|
-
/**
|
|
222
|
-
* Construct an object of types for every collection, using the permitted fields per action type
|
|
223
|
-
* as it's fields.
|
|
224
|
-
*/
|
|
225
|
-
function getTypes(action) {
|
|
226
|
-
const CollectionTypes = {};
|
|
227
|
-
const CountFunctions = schemaComposer.createObjectTC({
|
|
228
|
-
name: 'count_functions',
|
|
229
|
-
fields: {
|
|
230
|
-
count: {
|
|
231
|
-
type: graphql_1.GraphQLInt,
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
const DateFunctions = schemaComposer.createObjectTC({
|
|
236
|
-
name: 'date_functions',
|
|
237
|
-
fields: {
|
|
238
|
-
year: {
|
|
239
|
-
type: graphql_1.GraphQLInt,
|
|
240
|
-
},
|
|
241
|
-
month: {
|
|
242
|
-
type: graphql_1.GraphQLInt,
|
|
243
|
-
},
|
|
244
|
-
week: {
|
|
245
|
-
type: graphql_1.GraphQLInt,
|
|
246
|
-
},
|
|
247
|
-
day: {
|
|
248
|
-
type: graphql_1.GraphQLInt,
|
|
249
|
-
},
|
|
250
|
-
weekday: {
|
|
251
|
-
type: graphql_1.GraphQLInt,
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
const TimeFunctions = schemaComposer.createObjectTC({
|
|
256
|
-
name: 'time_functions',
|
|
257
|
-
fields: {
|
|
258
|
-
hour: {
|
|
259
|
-
type: graphql_1.GraphQLInt,
|
|
260
|
-
},
|
|
261
|
-
minute: {
|
|
262
|
-
type: graphql_1.GraphQLInt,
|
|
263
|
-
},
|
|
264
|
-
second: {
|
|
265
|
-
type: graphql_1.GraphQLInt,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
const DateTimeFunctions = schemaComposer.createObjectTC({
|
|
270
|
-
name: 'datetime_functions',
|
|
271
|
-
fields: {
|
|
272
|
-
...DateFunctions.getFields(),
|
|
273
|
-
...TimeFunctions.getFields(),
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
for (const collection of Object.values(schema[action].collections)) {
|
|
277
|
-
if (Object.keys(collection.fields).length === 0)
|
|
278
|
-
continue;
|
|
279
|
-
if (SYSTEM_DENY_LIST.includes(collection.collection))
|
|
280
|
-
continue;
|
|
281
|
-
CollectionTypes[collection.collection] = schemaComposer.createObjectTC({
|
|
282
|
-
name: action === 'read' ? collection.collection : `${action}_${collection.collection}`,
|
|
283
|
-
fields: Object.values(collection.fields).reduce((acc, field) => {
|
|
284
|
-
let type = (0, get_graphql_type_1.getGraphQLType)(field.type, field.special);
|
|
285
|
-
// GraphQL doesn't differentiate between not-null and has-to-be-submitted. We
|
|
286
|
-
// can't non-null in update, as that would require every not-nullable field to be
|
|
287
|
-
// submitted on updates
|
|
288
|
-
if (field.nullable === false &&
|
|
289
|
-
!field.defaultValue &&
|
|
290
|
-
!constants_2.GENERATE_SPECIAL.some((flag) => field.special.includes(flag)) &&
|
|
291
|
-
action !== 'update') {
|
|
292
|
-
type = new graphql_1.GraphQLNonNull(type);
|
|
293
|
-
}
|
|
294
|
-
if (collection.primary === field.field) {
|
|
295
|
-
if (!field.defaultValue && !field.special.includes('uuid') && action === 'create')
|
|
296
|
-
type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
|
|
297
|
-
else if (['create', 'update'].includes(action))
|
|
298
|
-
type = graphql_1.GraphQLID;
|
|
299
|
-
else
|
|
300
|
-
type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
|
|
301
|
-
}
|
|
302
|
-
acc[field.field] = {
|
|
303
|
-
type,
|
|
304
|
-
description: field.note,
|
|
305
|
-
resolve: (obj) => {
|
|
306
|
-
return obj[field.field];
|
|
307
|
-
},
|
|
308
|
-
};
|
|
309
|
-
if (action === 'read') {
|
|
310
|
-
if (field.type === 'date') {
|
|
311
|
-
acc[`${field.field}_func`] = {
|
|
312
|
-
type: DateFunctions,
|
|
313
|
-
resolve: (obj) => {
|
|
314
|
-
const funcFields = Object.keys(DateFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
|
315
|
-
return (0, lodash_1.mapKeys)((0, lodash_1.pick)(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
if (field.type === 'time') {
|
|
320
|
-
acc[`${field.field}_func`] = {
|
|
321
|
-
type: TimeFunctions,
|
|
322
|
-
resolve: (obj) => {
|
|
323
|
-
const funcFields = Object.keys(TimeFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
|
324
|
-
return (0, lodash_1.mapKeys)((0, lodash_1.pick)(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
|
325
|
-
},
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
if (field.type === 'dateTime' || field.type === 'timestamp') {
|
|
329
|
-
acc[`${field.field}_func`] = {
|
|
330
|
-
type: DateTimeFunctions,
|
|
331
|
-
resolve: (obj) => {
|
|
332
|
-
const funcFields = Object.keys(DateTimeFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
|
333
|
-
return (0, lodash_1.mapKeys)((0, lodash_1.pick)(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
|
334
|
-
},
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
if (field.type === 'json' || field.type === 'alias') {
|
|
338
|
-
acc[`${field.field}_func`] = {
|
|
339
|
-
type: CountFunctions,
|
|
340
|
-
resolve: (obj) => {
|
|
341
|
-
const funcFields = Object.keys(CountFunctions.getFields()).map((key) => `${field.field}_${key}`);
|
|
342
|
-
return (0, lodash_1.mapKeys)((0, lodash_1.pick)(obj, funcFields), (_value, key) => key.substring(field.field.length + 1));
|
|
343
|
-
},
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return acc;
|
|
348
|
-
}, {}),
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
for (const relation of schema[action].relations) {
|
|
352
|
-
if (relation.related_collection) {
|
|
353
|
-
if (SYSTEM_DENY_LIST.includes(relation.related_collection))
|
|
354
|
-
continue;
|
|
355
|
-
CollectionTypes[relation.collection]?.addFields({
|
|
356
|
-
[relation.field]: {
|
|
357
|
-
type: CollectionTypes[relation.related_collection],
|
|
358
|
-
resolve: (obj, _, __, info) => {
|
|
359
|
-
return obj[info?.path?.key ?? relation.field];
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
});
|
|
363
|
-
if (relation.meta?.one_field) {
|
|
364
|
-
CollectionTypes[relation.related_collection]?.addFields({
|
|
365
|
-
[relation.meta.one_field]: {
|
|
366
|
-
type: [CollectionTypes[relation.collection]],
|
|
367
|
-
resolve: (obj, _, __, info) => {
|
|
368
|
-
return obj[info?.path?.key ?? relation.meta.one_field];
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
else if (relation.meta?.one_allowed_collections && action === 'read') {
|
|
375
|
-
// NOTE: There are no union input types in GraphQL, so this only applies to Read actions
|
|
376
|
-
CollectionTypes[relation.collection]?.addFields({
|
|
377
|
-
[relation.field]: {
|
|
378
|
-
type: new graphql_1.GraphQLUnionType({
|
|
379
|
-
name: `${relation.collection}_${relation.field}_union`,
|
|
380
|
-
types: relation.meta.one_allowed_collections.map((collection) => CollectionTypes[collection].getType()),
|
|
381
|
-
resolveType(_value, context, info) {
|
|
382
|
-
let path = [];
|
|
383
|
-
let currentPath = info.path;
|
|
384
|
-
while (currentPath.prev) {
|
|
385
|
-
path.push(currentPath.key);
|
|
386
|
-
currentPath = currentPath.prev;
|
|
387
|
-
}
|
|
388
|
-
path = path.reverse().slice(0, -1);
|
|
389
|
-
let parent = context['data'];
|
|
390
|
-
for (const pathPart of path) {
|
|
391
|
-
parent = parent[pathPart];
|
|
392
|
-
}
|
|
393
|
-
const collection = parent[relation.meta.one_collection_field];
|
|
394
|
-
return CollectionTypes[collection].getType().name;
|
|
395
|
-
},
|
|
396
|
-
}),
|
|
397
|
-
resolve: (obj, _, __, info) => {
|
|
398
|
-
return obj[info?.path?.key ?? relation.field];
|
|
399
|
-
},
|
|
400
|
-
},
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
return { CollectionTypes };
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Create readable types and attach resolvers for each. Also prepares full filter argument structures
|
|
408
|
-
*/
|
|
409
|
-
function getReadableTypes() {
|
|
410
|
-
const { CollectionTypes: ReadCollectionTypes } = getTypes('read');
|
|
411
|
-
const ReadableCollectionFilterTypes = {};
|
|
412
|
-
const AggregatedFunctions = {};
|
|
413
|
-
const AggregatedFields = {};
|
|
414
|
-
const AggregateMethods = {};
|
|
415
|
-
const StringFilterOperators = schemaComposer.createInputTC({
|
|
416
|
-
name: 'string_filter_operators',
|
|
417
|
-
fields: {
|
|
418
|
-
_eq: {
|
|
419
|
-
type: graphql_1.GraphQLString,
|
|
420
|
-
},
|
|
421
|
-
_neq: {
|
|
422
|
-
type: graphql_1.GraphQLString,
|
|
423
|
-
},
|
|
424
|
-
_contains: {
|
|
425
|
-
type: graphql_1.GraphQLString,
|
|
426
|
-
},
|
|
427
|
-
_icontains: {
|
|
428
|
-
type: graphql_1.GraphQLString,
|
|
429
|
-
},
|
|
430
|
-
_ncontains: {
|
|
431
|
-
type: graphql_1.GraphQLString,
|
|
432
|
-
},
|
|
433
|
-
_starts_with: {
|
|
434
|
-
type: graphql_1.GraphQLString,
|
|
435
|
-
},
|
|
436
|
-
_nstarts_with: {
|
|
437
|
-
type: graphql_1.GraphQLString,
|
|
438
|
-
},
|
|
439
|
-
_ends_with: {
|
|
440
|
-
type: graphql_1.GraphQLString,
|
|
441
|
-
},
|
|
442
|
-
_nends_with: {
|
|
443
|
-
type: graphql_1.GraphQLString,
|
|
444
|
-
},
|
|
445
|
-
_in: {
|
|
446
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
447
|
-
},
|
|
448
|
-
_nin: {
|
|
449
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
450
|
-
},
|
|
451
|
-
_null: {
|
|
452
|
-
type: graphql_1.GraphQLBoolean,
|
|
453
|
-
},
|
|
454
|
-
_nnull: {
|
|
455
|
-
type: graphql_1.GraphQLBoolean,
|
|
456
|
-
},
|
|
457
|
-
_empty: {
|
|
458
|
-
type: graphql_1.GraphQLBoolean,
|
|
459
|
-
},
|
|
460
|
-
_nempty: {
|
|
461
|
-
type: graphql_1.GraphQLBoolean,
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
});
|
|
465
|
-
const BooleanFilterOperators = schemaComposer.createInputTC({
|
|
466
|
-
name: 'boolean_filter_operators',
|
|
467
|
-
fields: {
|
|
468
|
-
_eq: {
|
|
469
|
-
type: graphql_1.GraphQLBoolean,
|
|
470
|
-
},
|
|
471
|
-
_neq: {
|
|
472
|
-
type: graphql_1.GraphQLBoolean,
|
|
473
|
-
},
|
|
474
|
-
_null: {
|
|
475
|
-
type: graphql_1.GraphQLBoolean,
|
|
476
|
-
},
|
|
477
|
-
_nnull: {
|
|
478
|
-
type: graphql_1.GraphQLBoolean,
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
});
|
|
482
|
-
const DateFilterOperators = schemaComposer.createInputTC({
|
|
483
|
-
name: 'date_filter_operators',
|
|
484
|
-
fields: {
|
|
485
|
-
_eq: {
|
|
486
|
-
type: graphql_1.GraphQLString,
|
|
487
|
-
},
|
|
488
|
-
_neq: {
|
|
489
|
-
type: graphql_1.GraphQLString,
|
|
490
|
-
},
|
|
491
|
-
_gt: {
|
|
492
|
-
type: graphql_1.GraphQLString,
|
|
493
|
-
},
|
|
494
|
-
_gte: {
|
|
495
|
-
type: graphql_1.GraphQLString,
|
|
496
|
-
},
|
|
497
|
-
_lt: {
|
|
498
|
-
type: graphql_1.GraphQLString,
|
|
499
|
-
},
|
|
500
|
-
_lte: {
|
|
501
|
-
type: graphql_1.GraphQLString,
|
|
502
|
-
},
|
|
503
|
-
_null: {
|
|
504
|
-
type: graphql_1.GraphQLBoolean,
|
|
505
|
-
},
|
|
506
|
-
_nnull: {
|
|
507
|
-
type: graphql_1.GraphQLBoolean,
|
|
508
|
-
},
|
|
509
|
-
_in: {
|
|
510
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
511
|
-
},
|
|
512
|
-
_nin: {
|
|
513
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
514
|
-
},
|
|
515
|
-
_between: {
|
|
516
|
-
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
517
|
-
},
|
|
518
|
-
_nbetween: {
|
|
519
|
-
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
520
|
-
},
|
|
521
|
-
},
|
|
522
|
-
});
|
|
523
|
-
// Uses StringOrFloat rather than Float to support api dynamic variables (like `$NOW`)
|
|
524
|
-
const NumberFilterOperators = schemaComposer.createInputTC({
|
|
525
|
-
name: 'number_filter_operators',
|
|
526
|
-
fields: {
|
|
527
|
-
_eq: {
|
|
528
|
-
type: string_or_float_1.GraphQLStringOrFloat,
|
|
529
|
-
},
|
|
530
|
-
_neq: {
|
|
531
|
-
type: string_or_float_1.GraphQLStringOrFloat,
|
|
532
|
-
},
|
|
533
|
-
_in: {
|
|
534
|
-
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
535
|
-
},
|
|
536
|
-
_nin: {
|
|
537
|
-
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
538
|
-
},
|
|
539
|
-
_gt: {
|
|
540
|
-
type: string_or_float_1.GraphQLStringOrFloat,
|
|
541
|
-
},
|
|
542
|
-
_gte: {
|
|
543
|
-
type: string_or_float_1.GraphQLStringOrFloat,
|
|
544
|
-
},
|
|
545
|
-
_lt: {
|
|
546
|
-
type: string_or_float_1.GraphQLStringOrFloat,
|
|
547
|
-
},
|
|
548
|
-
_lte: {
|
|
549
|
-
type: string_or_float_1.GraphQLStringOrFloat,
|
|
550
|
-
},
|
|
551
|
-
_null: {
|
|
552
|
-
type: graphql_1.GraphQLBoolean,
|
|
553
|
-
},
|
|
554
|
-
_nnull: {
|
|
555
|
-
type: graphql_1.GraphQLBoolean,
|
|
556
|
-
},
|
|
557
|
-
_between: {
|
|
558
|
-
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
559
|
-
},
|
|
560
|
-
_nbetween: {
|
|
561
|
-
type: new graphql_1.GraphQLList(string_or_float_1.GraphQLStringOrFloat),
|
|
562
|
-
},
|
|
563
|
-
},
|
|
564
|
-
});
|
|
565
|
-
const GeometryFilterOperators = schemaComposer.createInputTC({
|
|
566
|
-
name: 'geometry_filter_operators',
|
|
567
|
-
fields: {
|
|
568
|
-
_eq: {
|
|
569
|
-
type: geojson_1.GraphQLGeoJSON,
|
|
570
|
-
},
|
|
571
|
-
_neq: {
|
|
572
|
-
type: geojson_1.GraphQLGeoJSON,
|
|
573
|
-
},
|
|
574
|
-
_intersects: {
|
|
575
|
-
type: geojson_1.GraphQLGeoJSON,
|
|
576
|
-
},
|
|
577
|
-
_nintersects: {
|
|
578
|
-
type: geojson_1.GraphQLGeoJSON,
|
|
579
|
-
},
|
|
580
|
-
_intersects_bbox: {
|
|
581
|
-
type: geojson_1.GraphQLGeoJSON,
|
|
582
|
-
},
|
|
583
|
-
_nintersects_bbox: {
|
|
584
|
-
type: geojson_1.GraphQLGeoJSON,
|
|
585
|
-
},
|
|
586
|
-
_null: {
|
|
587
|
-
type: graphql_1.GraphQLBoolean,
|
|
588
|
-
},
|
|
589
|
-
_nnull: {
|
|
590
|
-
type: graphql_1.GraphQLBoolean,
|
|
591
|
-
},
|
|
592
|
-
},
|
|
593
|
-
});
|
|
594
|
-
const HashFilterOperators = schemaComposer.createInputTC({
|
|
595
|
-
name: 'hash_filter_operators',
|
|
596
|
-
fields: {
|
|
597
|
-
_null: {
|
|
598
|
-
type: graphql_1.GraphQLBoolean,
|
|
599
|
-
},
|
|
600
|
-
_nnull: {
|
|
601
|
-
type: graphql_1.GraphQLBoolean,
|
|
602
|
-
},
|
|
603
|
-
_empty: {
|
|
604
|
-
type: graphql_1.GraphQLBoolean,
|
|
605
|
-
},
|
|
606
|
-
_nempty: {
|
|
607
|
-
type: graphql_1.GraphQLBoolean,
|
|
608
|
-
},
|
|
609
|
-
},
|
|
610
|
-
});
|
|
611
|
-
const CountFunctionFilterOperators = schemaComposer.createInputTC({
|
|
612
|
-
name: 'count_function_filter_operators',
|
|
613
|
-
fields: {
|
|
614
|
-
count: {
|
|
615
|
-
type: NumberFilterOperators,
|
|
616
|
-
},
|
|
617
|
-
},
|
|
618
|
-
});
|
|
619
|
-
const DateFunctionFilterOperators = schemaComposer.createInputTC({
|
|
620
|
-
name: 'date_function_filter_operators',
|
|
621
|
-
fields: {
|
|
622
|
-
year: {
|
|
623
|
-
type: NumberFilterOperators,
|
|
624
|
-
},
|
|
625
|
-
month: {
|
|
626
|
-
type: NumberFilterOperators,
|
|
627
|
-
},
|
|
628
|
-
week: {
|
|
629
|
-
type: NumberFilterOperators,
|
|
630
|
-
},
|
|
631
|
-
day: {
|
|
632
|
-
type: NumberFilterOperators,
|
|
633
|
-
},
|
|
634
|
-
weekday: {
|
|
635
|
-
type: NumberFilterOperators,
|
|
636
|
-
},
|
|
637
|
-
},
|
|
638
|
-
});
|
|
639
|
-
const TimeFunctionFilterOperators = schemaComposer.createInputTC({
|
|
640
|
-
name: 'time_function_filter_operators',
|
|
641
|
-
fields: {
|
|
642
|
-
hour: {
|
|
643
|
-
type: NumberFilterOperators,
|
|
644
|
-
},
|
|
645
|
-
minute: {
|
|
646
|
-
type: NumberFilterOperators,
|
|
647
|
-
},
|
|
648
|
-
second: {
|
|
649
|
-
type: NumberFilterOperators,
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
});
|
|
653
|
-
const DateTimeFunctionFilterOperators = schemaComposer.createInputTC({
|
|
654
|
-
name: 'datetime_function_filter_operators',
|
|
655
|
-
fields: {
|
|
656
|
-
...DateFunctionFilterOperators.getFields(),
|
|
657
|
-
...TimeFunctionFilterOperators.getFields(),
|
|
658
|
-
},
|
|
659
|
-
});
|
|
660
|
-
for (const collection of Object.values(schema.read.collections)) {
|
|
661
|
-
if (Object.keys(collection.fields).length === 0)
|
|
662
|
-
continue;
|
|
663
|
-
if (SYSTEM_DENY_LIST.includes(collection.collection))
|
|
664
|
-
continue;
|
|
665
|
-
ReadableCollectionFilterTypes[collection.collection] = schemaComposer.createInputTC({
|
|
666
|
-
name: `${collection.collection}_filter`,
|
|
667
|
-
fields: Object.values(collection.fields).reduce((acc, field) => {
|
|
668
|
-
const graphqlType = (0, get_graphql_type_1.getGraphQLType)(field.type, field.special);
|
|
669
|
-
let filterOperatorType;
|
|
670
|
-
switch (graphqlType) {
|
|
671
|
-
case graphql_1.GraphQLBoolean:
|
|
672
|
-
filterOperatorType = BooleanFilterOperators;
|
|
673
|
-
break;
|
|
674
|
-
case bigint_1.GraphQLBigInt:
|
|
675
|
-
case graphql_1.GraphQLInt:
|
|
676
|
-
case graphql_1.GraphQLFloat:
|
|
677
|
-
filterOperatorType = NumberFilterOperators;
|
|
678
|
-
break;
|
|
679
|
-
case date_1.GraphQLDate:
|
|
680
|
-
filterOperatorType = DateFilterOperators;
|
|
681
|
-
break;
|
|
682
|
-
case geojson_1.GraphQLGeoJSON:
|
|
683
|
-
filterOperatorType = GeometryFilterOperators;
|
|
684
|
-
break;
|
|
685
|
-
case hash_1.GraphQLHash:
|
|
686
|
-
filterOperatorType = HashFilterOperators;
|
|
687
|
-
break;
|
|
688
|
-
default:
|
|
689
|
-
filterOperatorType = StringFilterOperators;
|
|
690
|
-
}
|
|
691
|
-
acc[field.field] = filterOperatorType;
|
|
692
|
-
if (field.type === 'date') {
|
|
693
|
-
acc[`${field.field}_func`] = {
|
|
694
|
-
type: DateFunctionFilterOperators,
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
if (field.type === 'time') {
|
|
698
|
-
acc[`${field.field}_func`] = {
|
|
699
|
-
type: TimeFunctionFilterOperators,
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
if (field.type === 'dateTime' || field.type === 'timestamp') {
|
|
703
|
-
acc[`${field.field}_func`] = {
|
|
704
|
-
type: DateTimeFunctionFilterOperators,
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
if (field.type === 'json' || field.type === 'alias') {
|
|
708
|
-
acc[`${field.field}_func`] = {
|
|
709
|
-
type: CountFunctionFilterOperators,
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
return acc;
|
|
713
|
-
}, {}),
|
|
714
|
-
});
|
|
715
|
-
ReadableCollectionFilterTypes[collection.collection].addFields({
|
|
716
|
-
_and: [ReadableCollectionFilterTypes[collection.collection]],
|
|
717
|
-
_or: [ReadableCollectionFilterTypes[collection.collection]],
|
|
718
|
-
});
|
|
719
|
-
AggregatedFields[collection.collection] = schemaComposer.createObjectTC({
|
|
720
|
-
name: `${collection.collection}_aggregated_fields`,
|
|
721
|
-
fields: Object.values(collection.fields).reduce((acc, field) => {
|
|
722
|
-
const graphqlType = (0, get_graphql_type_1.getGraphQLType)(field.type, field.special);
|
|
723
|
-
switch (graphqlType) {
|
|
724
|
-
case bigint_1.GraphQLBigInt:
|
|
725
|
-
case graphql_1.GraphQLInt:
|
|
726
|
-
case graphql_1.GraphQLFloat:
|
|
727
|
-
acc[field.field] = {
|
|
728
|
-
type: graphql_1.GraphQLFloat,
|
|
729
|
-
description: field.note,
|
|
730
|
-
};
|
|
731
|
-
break;
|
|
732
|
-
default:
|
|
733
|
-
break;
|
|
734
|
-
}
|
|
735
|
-
return acc;
|
|
736
|
-
}, {}),
|
|
737
|
-
});
|
|
738
|
-
const countType = schemaComposer.createObjectTC({
|
|
739
|
-
name: `${collection.collection}_aggregated_count`,
|
|
740
|
-
fields: Object.values(collection.fields).reduce((acc, field) => {
|
|
741
|
-
acc[field.field] = {
|
|
742
|
-
type: graphql_1.GraphQLInt,
|
|
743
|
-
description: field.note,
|
|
744
|
-
};
|
|
745
|
-
return acc;
|
|
746
|
-
}, {}),
|
|
747
|
-
});
|
|
748
|
-
AggregateMethods[collection.collection] = {
|
|
749
|
-
group: {
|
|
750
|
-
name: 'group',
|
|
751
|
-
type: graphql_compose_1.GraphQLJSON,
|
|
752
|
-
},
|
|
753
|
-
countAll: {
|
|
754
|
-
name: 'countAll',
|
|
755
|
-
type: graphql_1.GraphQLInt,
|
|
756
|
-
},
|
|
757
|
-
count: {
|
|
758
|
-
name: 'count',
|
|
759
|
-
type: countType,
|
|
760
|
-
},
|
|
761
|
-
countDistinct: {
|
|
762
|
-
name: 'countDistinct',
|
|
763
|
-
type: countType,
|
|
764
|
-
},
|
|
765
|
-
};
|
|
766
|
-
const hasNumericAggregates = Object.values(collection.fields).some((field) => {
|
|
767
|
-
const graphqlType = (0, get_graphql_type_1.getGraphQLType)(field.type, field.special);
|
|
768
|
-
if (graphqlType === graphql_1.GraphQLInt || graphqlType === graphql_1.GraphQLFloat) {
|
|
769
|
-
return true;
|
|
770
|
-
}
|
|
771
|
-
return false;
|
|
772
|
-
});
|
|
773
|
-
if (hasNumericAggregates) {
|
|
774
|
-
Object.assign(AggregateMethods[collection.collection], {
|
|
775
|
-
avg: {
|
|
776
|
-
name: 'avg',
|
|
777
|
-
type: AggregatedFields[collection.collection],
|
|
778
|
-
},
|
|
779
|
-
sum: {
|
|
780
|
-
name: 'sum',
|
|
781
|
-
type: AggregatedFields[collection.collection],
|
|
782
|
-
},
|
|
783
|
-
avgDistinct: {
|
|
784
|
-
name: 'avgDistinct',
|
|
785
|
-
type: AggregatedFields[collection.collection],
|
|
786
|
-
},
|
|
787
|
-
sumDistinct: {
|
|
788
|
-
name: 'sumDistinct',
|
|
789
|
-
type: AggregatedFields[collection.collection],
|
|
790
|
-
},
|
|
791
|
-
min: {
|
|
792
|
-
name: 'min',
|
|
793
|
-
type: AggregatedFields[collection.collection],
|
|
794
|
-
},
|
|
795
|
-
max: {
|
|
796
|
-
name: 'max',
|
|
797
|
-
type: AggregatedFields[collection.collection],
|
|
798
|
-
},
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
AggregatedFunctions[collection.collection] = schemaComposer.createObjectTC({
|
|
802
|
-
name: `${collection.collection}_aggregated`,
|
|
803
|
-
fields: AggregateMethods[collection.collection],
|
|
804
|
-
});
|
|
805
|
-
const resolver = {
|
|
806
|
-
name: collection.collection,
|
|
807
|
-
type: collection.singleton
|
|
808
|
-
? ReadCollectionTypes[collection.collection]
|
|
809
|
-
: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType()))),
|
|
810
|
-
resolve: async ({ info, context }) => {
|
|
811
|
-
const result = await self.resolveQuery(info);
|
|
812
|
-
context['data'] = result;
|
|
813
|
-
return result;
|
|
814
|
-
},
|
|
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);
|
|
837
|
-
ReadCollectionTypes[collection.collection].addResolver({
|
|
838
|
-
name: `${collection.collection}_aggregated`,
|
|
839
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(AggregatedFunctions[collection.collection].getType()))),
|
|
840
|
-
args: {
|
|
841
|
-
groupBy: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
842
|
-
filter: ReadableCollectionFilterTypes[collection.collection],
|
|
843
|
-
limit: {
|
|
844
|
-
type: graphql_1.GraphQLInt,
|
|
845
|
-
},
|
|
846
|
-
offset: {
|
|
847
|
-
type: graphql_1.GraphQLInt,
|
|
848
|
-
},
|
|
849
|
-
page: {
|
|
850
|
-
type: graphql_1.GraphQLInt,
|
|
851
|
-
},
|
|
852
|
-
search: {
|
|
853
|
-
type: graphql_1.GraphQLString,
|
|
854
|
-
},
|
|
855
|
-
sort: {
|
|
856
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
857
|
-
},
|
|
858
|
-
},
|
|
859
|
-
resolve: async ({ info, context }) => {
|
|
860
|
-
const result = await self.resolveQuery(info);
|
|
861
|
-
context['data'] = result;
|
|
862
|
-
return result;
|
|
863
|
-
},
|
|
864
|
-
});
|
|
865
|
-
if (collection.singleton === false) {
|
|
866
|
-
ReadCollectionTypes[collection.collection].addResolver({
|
|
867
|
-
name: `${collection.collection}_by_id`,
|
|
868
|
-
type: ReadCollectionTypes[collection.collection],
|
|
869
|
-
args: {
|
|
870
|
-
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
871
|
-
},
|
|
872
|
-
resolve: async ({ info, context }) => {
|
|
873
|
-
const result = await self.resolveQuery(info);
|
|
874
|
-
context['data'] = result;
|
|
875
|
-
return result;
|
|
876
|
-
},
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
for (const relation of schema.read.relations) {
|
|
881
|
-
if (relation.related_collection) {
|
|
882
|
-
if (SYSTEM_DENY_LIST.includes(relation.related_collection))
|
|
883
|
-
continue;
|
|
884
|
-
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
|
885
|
-
[relation.field]: ReadableCollectionFilterTypes[relation.related_collection],
|
|
886
|
-
});
|
|
887
|
-
ReadCollectionTypes[relation.collection]?.addFieldArgs(relation.field, {
|
|
888
|
-
filter: ReadableCollectionFilterTypes[relation.related_collection],
|
|
889
|
-
sort: {
|
|
890
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
891
|
-
},
|
|
892
|
-
limit: {
|
|
893
|
-
type: graphql_1.GraphQLInt,
|
|
894
|
-
},
|
|
895
|
-
offset: {
|
|
896
|
-
type: graphql_1.GraphQLInt,
|
|
897
|
-
},
|
|
898
|
-
page: {
|
|
899
|
-
type: graphql_1.GraphQLInt,
|
|
900
|
-
},
|
|
901
|
-
search: {
|
|
902
|
-
type: graphql_1.GraphQLString,
|
|
903
|
-
},
|
|
904
|
-
});
|
|
905
|
-
if (relation.meta?.one_field) {
|
|
906
|
-
ReadableCollectionFilterTypes[relation.related_collection]?.addFields({
|
|
907
|
-
[relation.meta.one_field]: ReadableCollectionFilterTypes[relation.collection],
|
|
908
|
-
});
|
|
909
|
-
ReadCollectionTypes[relation.related_collection]?.addFieldArgs(relation.meta.one_field, {
|
|
910
|
-
filter: ReadableCollectionFilterTypes[relation.collection],
|
|
911
|
-
sort: {
|
|
912
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
913
|
-
},
|
|
914
|
-
limit: {
|
|
915
|
-
type: graphql_1.GraphQLInt,
|
|
916
|
-
},
|
|
917
|
-
offset: {
|
|
918
|
-
type: graphql_1.GraphQLInt,
|
|
919
|
-
},
|
|
920
|
-
page: {
|
|
921
|
-
type: graphql_1.GraphQLInt,
|
|
922
|
-
},
|
|
923
|
-
search: {
|
|
924
|
-
type: graphql_1.GraphQLString,
|
|
925
|
-
},
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
else if (relation.meta?.one_allowed_collections) {
|
|
930
|
-
ReadableCollectionFilterTypes[relation.collection]?.removeField('item');
|
|
931
|
-
for (const collection of relation.meta.one_allowed_collections) {
|
|
932
|
-
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
|
933
|
-
[`item__${collection}`]: ReadableCollectionFilterTypes[collection],
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
return { ReadCollectionTypes, ReadableCollectionFilterTypes };
|
|
939
|
-
}
|
|
940
|
-
function getWritableTypes() {
|
|
941
|
-
const { CollectionTypes: CreateCollectionTypes } = getTypes('create');
|
|
942
|
-
const { CollectionTypes: UpdateCollectionTypes } = getTypes('update');
|
|
943
|
-
const DeleteCollectionTypes = {};
|
|
944
|
-
for (const collection of Object.values(schema.create.collections)) {
|
|
945
|
-
if (Object.keys(collection.fields).length === 0)
|
|
946
|
-
continue;
|
|
947
|
-
if (SYSTEM_DENY_LIST.includes(collection.collection))
|
|
948
|
-
continue;
|
|
949
|
-
if (collection.collection in CreateCollectionTypes === false)
|
|
950
|
-
continue;
|
|
951
|
-
const collectionIsReadable = collection.collection in ReadCollectionTypes;
|
|
952
|
-
const creatableFields = CreateCollectionTypes[collection.collection]?.getFields() || {};
|
|
953
|
-
if (Object.keys(creatableFields).length > 0) {
|
|
954
|
-
const resolverDefinition = {
|
|
955
|
-
name: `create_${collection.collection}_items`,
|
|
956
|
-
type: collectionIsReadable
|
|
957
|
-
? new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType())))
|
|
958
|
-
: graphql_1.GraphQLBoolean,
|
|
959
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
960
|
-
};
|
|
961
|
-
if (collectionIsReadable) {
|
|
962
|
-
resolverDefinition.args = ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs();
|
|
963
|
-
}
|
|
964
|
-
CreateCollectionTypes[collection.collection].addResolver(resolverDefinition);
|
|
965
|
-
CreateCollectionTypes[collection.collection].addResolver({
|
|
966
|
-
name: `create_${collection.collection}_item`,
|
|
967
|
-
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
968
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
969
|
-
});
|
|
970
|
-
CreateCollectionTypes[collection.collection].getResolver(`create_${collection.collection}_items`).addArgs({
|
|
971
|
-
...CreateCollectionTypes[collection.collection].getResolver(`create_${collection.collection}_items`).getArgs(),
|
|
972
|
-
data: [
|
|
973
|
-
(0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes[collection.collection]).setTypeName(`create_${collection.collection}_input`).NonNull,
|
|
974
|
-
],
|
|
975
|
-
});
|
|
976
|
-
CreateCollectionTypes[collection.collection].getResolver(`create_${collection.collection}_item`).addArgs({
|
|
977
|
-
...CreateCollectionTypes[collection.collection].getResolver(`create_${collection.collection}_item`).getArgs(),
|
|
978
|
-
data: (0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes[collection.collection]).setTypeName(`create_${collection.collection}_input`).NonNull,
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
for (const collection of Object.values(schema.update.collections)) {
|
|
983
|
-
if (Object.keys(collection.fields).length === 0)
|
|
984
|
-
continue;
|
|
985
|
-
if (SYSTEM_DENY_LIST.includes(collection.collection))
|
|
986
|
-
continue;
|
|
987
|
-
if (collection.collection in UpdateCollectionTypes === false)
|
|
988
|
-
continue;
|
|
989
|
-
const collectionIsReadable = collection.collection in ReadCollectionTypes;
|
|
990
|
-
const updatableFields = UpdateCollectionTypes[collection.collection]?.getFields() || {};
|
|
991
|
-
if (Object.keys(updatableFields).length > 0) {
|
|
992
|
-
if (collection.singleton) {
|
|
993
|
-
UpdateCollectionTypes[collection.collection].addResolver({
|
|
994
|
-
name: `update_${collection.collection}`,
|
|
995
|
-
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
996
|
-
args: {
|
|
997
|
-
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
998
|
-
},
|
|
999
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
else {
|
|
1003
|
-
UpdateCollectionTypes[collection.collection].addResolver({
|
|
1004
|
-
name: `update_${collection.collection}_batch`,
|
|
1005
|
-
type: collectionIsReadable
|
|
1006
|
-
? new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType())))
|
|
1007
|
-
: graphql_1.GraphQLBoolean,
|
|
1008
|
-
args: {
|
|
1009
|
-
...(collectionIsReadable
|
|
1010
|
-
? ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs()
|
|
1011
|
-
: {}),
|
|
1012
|
-
data: [
|
|
1013
|
-
(0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
1014
|
-
],
|
|
1015
|
-
},
|
|
1016
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1017
|
-
});
|
|
1018
|
-
UpdateCollectionTypes[collection.collection].addResolver({
|
|
1019
|
-
name: `update_${collection.collection}_items`,
|
|
1020
|
-
type: collectionIsReadable
|
|
1021
|
-
? new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(ReadCollectionTypes[collection.collection].getType())))
|
|
1022
|
-
: graphql_1.GraphQLBoolean,
|
|
1023
|
-
args: {
|
|
1024
|
-
...(collectionIsReadable
|
|
1025
|
-
? ReadCollectionTypes[collection.collection].getResolver(collection.collection).getArgs()
|
|
1026
|
-
: {}),
|
|
1027
|
-
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1028
|
-
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
1029
|
-
},
|
|
1030
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1031
|
-
});
|
|
1032
|
-
UpdateCollectionTypes[collection.collection].addResolver({
|
|
1033
|
-
name: `update_${collection.collection}_item`,
|
|
1034
|
-
type: collectionIsReadable ? ReadCollectionTypes[collection.collection] : graphql_1.GraphQLBoolean,
|
|
1035
|
-
args: {
|
|
1036
|
-
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1037
|
-
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes[collection.collection]).setTypeName(`update_${collection.collection}_input`).NonNull,
|
|
1038
|
-
},
|
|
1039
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
DeleteCollectionTypes['many'] = schemaComposer.createObjectTC({
|
|
1045
|
-
name: `delete_many`,
|
|
1046
|
-
fields: {
|
|
1047
|
-
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1048
|
-
},
|
|
1049
|
-
});
|
|
1050
|
-
DeleteCollectionTypes['one'] = schemaComposer.createObjectTC({
|
|
1051
|
-
name: `delete_one`,
|
|
1052
|
-
fields: {
|
|
1053
|
-
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1054
|
-
},
|
|
1055
|
-
});
|
|
1056
|
-
for (const collection of Object.values(schema.delete.collections)) {
|
|
1057
|
-
DeleteCollectionTypes['many'].addResolver({
|
|
1058
|
-
name: `delete_${collection.collection}_items`,
|
|
1059
|
-
type: DeleteCollectionTypes['many'],
|
|
1060
|
-
args: {
|
|
1061
|
-
ids: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(graphql_1.GraphQLID)),
|
|
1062
|
-
},
|
|
1063
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1064
|
-
});
|
|
1065
|
-
DeleteCollectionTypes['one'].addResolver({
|
|
1066
|
-
name: `delete_${collection.collection}_item`,
|
|
1067
|
-
type: DeleteCollectionTypes['one'],
|
|
1068
|
-
args: {
|
|
1069
|
-
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1070
|
-
},
|
|
1071
|
-
resolve: async ({ args, info }) => await self.resolveMutation(args, info),
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
return { CreateCollectionTypes, UpdateCollectionTypes, DeleteCollectionTypes };
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
/**
|
|
1078
|
-
* Generic resolver that's used for every "regular" items/system query. Converts the incoming GraphQL AST / fragments into
|
|
1079
|
-
* Directus' query structure which is then executed by the services.
|
|
1080
|
-
*/
|
|
1081
|
-
async resolveQuery(info) {
|
|
1082
|
-
let collection = info.fieldName;
|
|
1083
|
-
if (this.scope === 'system')
|
|
1084
|
-
collection = `directus_${collection}`;
|
|
1085
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
1086
|
-
if (!selections)
|
|
1087
|
-
return null;
|
|
1088
|
-
const args = this.parseArgs(info.fieldNodes[0].arguments || [], info.variableValues);
|
|
1089
|
-
let query;
|
|
1090
|
-
const isAggregate = collection.endsWith('_aggregated') && collection in this.schema.collections === false;
|
|
1091
|
-
if (isAggregate) {
|
|
1092
|
-
query = this.getAggregateQuery(args, selections);
|
|
1093
|
-
collection = collection.slice(0, -11);
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
query = this.getQuery(args, selections, info.variableValues);
|
|
1097
|
-
if (collection.endsWith('_by_id') && collection in this.schema.collections === false) {
|
|
1098
|
-
collection = collection.slice(0, -6);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
if (args['id']) {
|
|
1102
|
-
query.filter = {
|
|
1103
|
-
_and: [
|
|
1104
|
-
query.filter || {},
|
|
1105
|
-
{
|
|
1106
|
-
[this.schema.collections[collection].primary]: {
|
|
1107
|
-
_eq: args['id'],
|
|
1108
|
-
},
|
|
1109
|
-
},
|
|
1110
|
-
],
|
|
1111
|
-
};
|
|
1112
|
-
query.limit = 1;
|
|
1113
|
-
}
|
|
1114
|
-
// Transform count(a.b.c) into a.b.count(c)
|
|
1115
|
-
if (query.fields?.length) {
|
|
1116
|
-
for (let fieldIndex = 0; fieldIndex < query.fields.length; fieldIndex++) {
|
|
1117
|
-
query.fields[fieldIndex] = (0, utils_1.parseFilterFunctionPath)(query.fields[fieldIndex]);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
const result = await this.read(collection, query);
|
|
1121
|
-
if (args['id']) {
|
|
1122
|
-
return result?.[0] || null;
|
|
1123
|
-
}
|
|
1124
|
-
if (query.group) {
|
|
1125
|
-
// for every entry in result add a group field based on query.group;
|
|
1126
|
-
const aggregateKeys = Object.keys(query.aggregate ?? {});
|
|
1127
|
-
result['map']((field) => {
|
|
1128
|
-
field['group'] = (0, lodash_1.omit)(field, aggregateKeys);
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
return result;
|
|
1132
|
-
}
|
|
1133
|
-
async resolveMutation(args, info) {
|
|
1134
|
-
const action = info.fieldName.split('_')[0];
|
|
1135
|
-
let collection = info.fieldName.substring(action.length + 1);
|
|
1136
|
-
if (this.scope === 'system')
|
|
1137
|
-
collection = `directus_${collection}`;
|
|
1138
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
1139
|
-
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
1140
|
-
const singleton = collection.endsWith('_batch') === false &&
|
|
1141
|
-
collection.endsWith('_items') === false &&
|
|
1142
|
-
collection.endsWith('_item') === false &&
|
|
1143
|
-
collection in this.schema.collections;
|
|
1144
|
-
const single = collection.endsWith('_items') === false && collection.endsWith('_batch') === false;
|
|
1145
|
-
const batchUpdate = action === 'update' && collection.endsWith('_batch');
|
|
1146
|
-
if (collection.endsWith('_batch'))
|
|
1147
|
-
collection = collection.slice(0, -6);
|
|
1148
|
-
if (collection.endsWith('_items'))
|
|
1149
|
-
collection = collection.slice(0, -6);
|
|
1150
|
-
if (collection.endsWith('_item'))
|
|
1151
|
-
collection = collection.slice(0, -5);
|
|
1152
|
-
if (singleton && action === 'update') {
|
|
1153
|
-
return await this.upsertSingleton(collection, args['data'], query);
|
|
1154
|
-
}
|
|
1155
|
-
const service = this.getService(collection);
|
|
1156
|
-
const hasQuery = (query.fields || []).length > 0;
|
|
1157
|
-
try {
|
|
1158
|
-
if (single) {
|
|
1159
|
-
if (action === 'create') {
|
|
1160
|
-
const key = await service.createOne(args['data']);
|
|
1161
|
-
return hasQuery ? await service.readOne(key, query) : true;
|
|
1162
|
-
}
|
|
1163
|
-
if (action === 'update') {
|
|
1164
|
-
const key = await service.updateOne(args['id'], args['data']);
|
|
1165
|
-
return hasQuery ? await service.readOne(key, query) : true;
|
|
1166
|
-
}
|
|
1167
|
-
if (action === 'delete') {
|
|
1168
|
-
await service.deleteOne(args['id']);
|
|
1169
|
-
return { id: args['id'] };
|
|
1170
|
-
}
|
|
1171
|
-
return undefined;
|
|
1172
|
-
}
|
|
1173
|
-
else {
|
|
1174
|
-
if (action === 'create') {
|
|
1175
|
-
const keys = await service.createMany(args['data']);
|
|
1176
|
-
return hasQuery ? await service.readMany(keys, query) : true;
|
|
1177
|
-
}
|
|
1178
|
-
if (action === 'update') {
|
|
1179
|
-
const keys = [];
|
|
1180
|
-
if (batchUpdate) {
|
|
1181
|
-
keys.push(...(await service.updateBatch(args['data'])));
|
|
1182
|
-
}
|
|
1183
|
-
else {
|
|
1184
|
-
keys.push(...(await service.updateMany(args['ids'], args['data'])));
|
|
1185
|
-
}
|
|
1186
|
-
return hasQuery ? await service.readMany(keys, query) : true;
|
|
1187
|
-
}
|
|
1188
|
-
if (action === 'delete') {
|
|
1189
|
-
const keys = await service.deleteMany(args['ids']);
|
|
1190
|
-
return { ids: keys };
|
|
1191
|
-
}
|
|
1192
|
-
return undefined;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
catch (err) {
|
|
1196
|
-
return this.formatError(err);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
/**
|
|
1200
|
-
* Execute the read action on the correct service. Checks for singleton as well.
|
|
1201
|
-
*/
|
|
1202
|
-
async read(collection, query) {
|
|
1203
|
-
const service = this.getService(collection);
|
|
1204
|
-
const result = this.schema.collections[collection].singleton
|
|
1205
|
-
? await service.readSingleton(query, { stripNonRequested: false })
|
|
1206
|
-
: await service.readByQuery(query, { stripNonRequested: false });
|
|
1207
|
-
return result;
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Upsert and read singleton item
|
|
1211
|
-
*/
|
|
1212
|
-
async upsertSingleton(collection, body, query) {
|
|
1213
|
-
const service = this.getService(collection);
|
|
1214
|
-
try {
|
|
1215
|
-
await service.upsertSingleton(body);
|
|
1216
|
-
if ((query.fields || []).length > 0) {
|
|
1217
|
-
const result = await service.readSingleton(query);
|
|
1218
|
-
return result;
|
|
1219
|
-
}
|
|
1220
|
-
return true;
|
|
1221
|
-
}
|
|
1222
|
-
catch (err) {
|
|
1223
|
-
throw this.formatError(err);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* GraphQL's regular resolver `args` variable only contains the "top-level" arguments. Seeing that we convert the
|
|
1228
|
-
* whole nested tree into one big query using Directus' own query resolver, we want to have a nested structure of
|
|
1229
|
-
* arguments for the whole resolving tree, which can later be transformed into Directus' AST using `deep`.
|
|
1230
|
-
* In order to do that, we'll parse over all ArgumentNodes and ObjectFieldNodes to manually recreate an object structure
|
|
1231
|
-
* of arguments
|
|
1232
|
-
*/
|
|
1233
|
-
parseArgs(args, variableValues) {
|
|
1234
|
-
if (!args || args['length'] === 0)
|
|
1235
|
-
return {};
|
|
1236
|
-
const parse = (node) => {
|
|
1237
|
-
switch (node.kind) {
|
|
1238
|
-
case 'Variable':
|
|
1239
|
-
return variableValues[node.name.value];
|
|
1240
|
-
case 'ListValue':
|
|
1241
|
-
return node.values.map(parse);
|
|
1242
|
-
case 'ObjectValue':
|
|
1243
|
-
return Object.fromEntries(node.fields.map((node) => [node.name.value, parse(node.value)]));
|
|
1244
|
-
case 'NullValue':
|
|
1245
|
-
return null;
|
|
1246
|
-
case 'StringValue':
|
|
1247
|
-
return String(node.value);
|
|
1248
|
-
case 'IntValue':
|
|
1249
|
-
case 'FloatValue':
|
|
1250
|
-
return Number(node.value);
|
|
1251
|
-
case 'BooleanValue':
|
|
1252
|
-
return Boolean(node.value);
|
|
1253
|
-
case 'EnumValue':
|
|
1254
|
-
default:
|
|
1255
|
-
return 'value' in node ? node.value : null;
|
|
1256
|
-
}
|
|
1257
|
-
};
|
|
1258
|
-
const argsObject = Object.fromEntries(args['map']((arg) => [arg.name.value, parse(arg.value)]));
|
|
1259
|
-
return argsObject;
|
|
1260
|
-
}
|
|
1261
|
-
/**
|
|
1262
|
-
* Get a Directus Query object from the parsed arguments (rawQuery) and GraphQL AST selectionSet. Converts SelectionSet into
|
|
1263
|
-
* Directus' `fields` query for use in the resolver. Also applies variables where appropriate.
|
|
1264
|
-
*/
|
|
1265
|
-
getQuery(rawQuery, selections, variableValues) {
|
|
1266
|
-
const query = (0, sanitize_query_1.sanitizeQuery)(rawQuery, this.accountability);
|
|
1267
|
-
const parseAliases = (selections) => {
|
|
1268
|
-
const aliases = {};
|
|
1269
|
-
for (const selection of selections) {
|
|
1270
|
-
if (selection.kind !== 'Field')
|
|
1271
|
-
continue;
|
|
1272
|
-
if (selection.alias?.value) {
|
|
1273
|
-
aliases[selection.alias.value] = selection.name.value;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
return aliases;
|
|
1277
|
-
};
|
|
1278
|
-
const parseFields = (selections, parent) => {
|
|
1279
|
-
const fields = [];
|
|
1280
|
-
for (let selection of selections) {
|
|
1281
|
-
if ((selection.kind === 'Field' || selection.kind === 'InlineFragment') !== true)
|
|
1282
|
-
continue;
|
|
1283
|
-
selection = selection;
|
|
1284
|
-
let current;
|
|
1285
|
-
let currentAlias = null;
|
|
1286
|
-
// Union type (Many-to-Any)
|
|
1287
|
-
if (selection.kind === 'InlineFragment') {
|
|
1288
|
-
if (selection.typeCondition.name.value.startsWith('__'))
|
|
1289
|
-
continue;
|
|
1290
|
-
current = `${parent}:${selection.typeCondition.name.value}`;
|
|
1291
|
-
}
|
|
1292
|
-
// Any other field type
|
|
1293
|
-
else {
|
|
1294
|
-
// filter out graphql pointers, like __typename
|
|
1295
|
-
if (selection.name.value.startsWith('__'))
|
|
1296
|
-
continue;
|
|
1297
|
-
current = selection.name.value;
|
|
1298
|
-
if (selection.alias) {
|
|
1299
|
-
currentAlias = selection.alias.value;
|
|
1300
|
-
}
|
|
1301
|
-
if (parent) {
|
|
1302
|
-
current = `${parent}.${current}`;
|
|
1303
|
-
if (currentAlias) {
|
|
1304
|
-
currentAlias = `${parent}.${currentAlias}`;
|
|
1305
|
-
// add nested aliases into deep query
|
|
1306
|
-
if (selection.selectionSet) {
|
|
1307
|
-
if (!query.deep)
|
|
1308
|
-
query.deep = {};
|
|
1309
|
-
(0, lodash_1.set)(query.deep, parent, (0, lodash_1.merge)({}, (0, lodash_1.get)(query.deep, parent), { _alias: { [selection.alias.value]: selection.name.value } }));
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
if (selection.selectionSet) {
|
|
1315
|
-
let children;
|
|
1316
|
-
if (current.endsWith('_func')) {
|
|
1317
|
-
children = [];
|
|
1318
|
-
const rootField = current.slice(0, -5);
|
|
1319
|
-
for (const subSelection of selection.selectionSet.selections) {
|
|
1320
|
-
if (subSelection.kind !== 'Field')
|
|
1321
|
-
continue;
|
|
1322
|
-
if (subSelection.name.value.startsWith('__'))
|
|
1323
|
-
continue;
|
|
1324
|
-
children.push(`${subSelection.name.value}(${rootField})`);
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
else {
|
|
1328
|
-
children = parseFields(selection.selectionSet.selections, currentAlias ?? current);
|
|
1329
|
-
}
|
|
1330
|
-
fields.push(...children);
|
|
1331
|
-
}
|
|
1332
|
-
else {
|
|
1333
|
-
fields.push(current);
|
|
1334
|
-
}
|
|
1335
|
-
if (selection.kind === 'Field' && selection.arguments && selection.arguments.length > 0) {
|
|
1336
|
-
if (selection.arguments && selection.arguments.length > 0) {
|
|
1337
|
-
if (!query.deep)
|
|
1338
|
-
query.deep = {};
|
|
1339
|
-
const args = this.parseArgs(selection.arguments, variableValues);
|
|
1340
|
-
(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}`)));
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
return (0, lodash_1.uniq)(fields);
|
|
1345
|
-
};
|
|
1346
|
-
query.alias = parseAliases(selections);
|
|
1347
|
-
query.fields = parseFields(selections);
|
|
1348
|
-
if (query.filter)
|
|
1349
|
-
query.filter = this.replaceFuncs(query.filter);
|
|
1350
|
-
query.deep = this.replaceFuncs(query.deep);
|
|
1351
|
-
(0, validate_query_1.validateQuery)(query);
|
|
1352
|
-
return query;
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* Resolve the aggregation query based on the requested aggregated fields
|
|
1356
|
-
*/
|
|
1357
|
-
getAggregateQuery(rawQuery, selections) {
|
|
1358
|
-
const query = (0, sanitize_query_1.sanitizeQuery)(rawQuery, this.accountability);
|
|
1359
|
-
query.aggregate = {};
|
|
1360
|
-
for (let aggregationGroup of selections) {
|
|
1361
|
-
if ((aggregationGroup.kind === 'Field') !== true)
|
|
1362
|
-
continue;
|
|
1363
|
-
aggregationGroup = aggregationGroup;
|
|
1364
|
-
// filter out graphql pointers, like __typename
|
|
1365
|
-
if (aggregationGroup.name.value.startsWith('__'))
|
|
1366
|
-
continue;
|
|
1367
|
-
const aggregateProperty = aggregationGroup.name.value;
|
|
1368
|
-
query.aggregate[aggregateProperty] =
|
|
1369
|
-
aggregationGroup.selectionSet?.selections
|
|
1370
|
-
// filter out graphql pointers, like __typename
|
|
1371
|
-
.filter((selectionNode) => !selectionNode?.name.value.startsWith('__'))
|
|
1372
|
-
.map((selectionNode) => {
|
|
1373
|
-
selectionNode = selectionNode;
|
|
1374
|
-
return selectionNode.name.value;
|
|
1375
|
-
}) ?? [];
|
|
1376
|
-
}
|
|
1377
|
-
if (query.filter) {
|
|
1378
|
-
query.filter = this.replaceFuncs(query.filter);
|
|
1379
|
-
}
|
|
1380
|
-
(0, validate_query_1.validateQuery)(query);
|
|
1381
|
-
return query;
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Replace functions from GraphQL format to Directus-Filter format
|
|
1385
|
-
*/
|
|
1386
|
-
replaceFuncs(filter) {
|
|
1387
|
-
return replaceFuncDeep(filter);
|
|
1388
|
-
function replaceFuncDeep(filter) {
|
|
1389
|
-
return (0, lodash_1.transform)(filter, (result, value, key) => {
|
|
1390
|
-
const isFunctionKey = typeof key === 'string' && key.endsWith('_func') && constants_1.FUNCTIONS.includes(Object.keys(value)[0]);
|
|
1391
|
-
if (isFunctionKey) {
|
|
1392
|
-
const functionName = Object.keys(value)[0];
|
|
1393
|
-
const fieldName = key.slice(0, -5);
|
|
1394
|
-
result[`${functionName}(${fieldName})`] = Object.values(value)[0];
|
|
1395
|
-
}
|
|
1396
|
-
else {
|
|
1397
|
-
result[key] = value?.constructor === Object || value?.constructor === Array ? replaceFuncDeep(value) : value;
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
/**
|
|
1403
|
-
* Convert Directus-Exception into a GraphQL format, so it can be returned by GraphQL properly.
|
|
1404
|
-
*/
|
|
1405
|
-
formatError(error) {
|
|
1406
|
-
if (Array.isArray(error)) {
|
|
1407
|
-
error[0].extensions['code'] = error[0].code;
|
|
1408
|
-
return new graphql_1.GraphQLError(error[0].message, undefined, undefined, undefined, undefined, error[0]);
|
|
1409
|
-
}
|
|
1410
|
-
error.extensions['code'] = error.code;
|
|
1411
|
-
return new graphql_1.GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
|
|
1412
|
-
}
|
|
1413
|
-
/**
|
|
1414
|
-
* Select the correct service for the given collection. This allows the individual services to run
|
|
1415
|
-
* their custom checks (f.e. it allows UsersService to prevent updating TFA secret from outside)
|
|
1416
|
-
*/
|
|
1417
|
-
getService(collection) {
|
|
1418
|
-
const opts = {
|
|
1419
|
-
knex: this.knex,
|
|
1420
|
-
accountability: this.accountability,
|
|
1421
|
-
schema: this.schema,
|
|
1422
|
-
};
|
|
1423
|
-
switch (collection) {
|
|
1424
|
-
case 'directus_activity':
|
|
1425
|
-
return new activity_1.ActivityService(opts);
|
|
1426
|
-
case 'directus_files':
|
|
1427
|
-
return new files_1.FilesService(opts);
|
|
1428
|
-
case 'directus_folders':
|
|
1429
|
-
return new folders_1.FoldersService(opts);
|
|
1430
|
-
case 'directus_permissions':
|
|
1431
|
-
return new permissions_1.PermissionsService(opts);
|
|
1432
|
-
case 'directus_presets':
|
|
1433
|
-
return new presets_1.PresetsService(opts);
|
|
1434
|
-
case 'directus_notifications':
|
|
1435
|
-
return new notifications_1.NotificationsService(opts);
|
|
1436
|
-
case 'directus_revisions':
|
|
1437
|
-
return new revisions_1.RevisionsService(opts);
|
|
1438
|
-
case 'directus_roles':
|
|
1439
|
-
return new roles_1.RolesService(opts);
|
|
1440
|
-
case 'directus_settings':
|
|
1441
|
-
return new settings_1.SettingsService(opts);
|
|
1442
|
-
case 'directus_users':
|
|
1443
|
-
return new users_1.UsersService(opts);
|
|
1444
|
-
case 'directus_webhooks':
|
|
1445
|
-
return new webhooks_1.WebhooksService(opts);
|
|
1446
|
-
case 'directus_shares':
|
|
1447
|
-
return new shares_1.SharesService(opts);
|
|
1448
|
-
case 'directus_flows':
|
|
1449
|
-
return new flows_1.FlowsService(opts);
|
|
1450
|
-
case 'directus_operations':
|
|
1451
|
-
return new operations_1.OperationsService(opts);
|
|
1452
|
-
default:
|
|
1453
|
-
return new items_1.ItemsService(collection, opts);
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
/**
|
|
1457
|
-
* Replace all fragments in a selectionset for the actual selection set as defined in the fragment
|
|
1458
|
-
* Effectively merges the selections with the fragments used in those selections
|
|
1459
|
-
*/
|
|
1460
|
-
replaceFragmentsInSelections(selections, fragments) {
|
|
1461
|
-
if (!selections)
|
|
1462
|
-
return null;
|
|
1463
|
-
const result = (0, lodash_1.flatten)(selections.map((selection) => {
|
|
1464
|
-
// Fragments can contains fragments themselves. This allows for nested fragments
|
|
1465
|
-
if (selection.kind === 'FragmentSpread') {
|
|
1466
|
-
return this.replaceFragmentsInSelections(fragments[selection.name.value].selectionSet.selections, fragments);
|
|
1467
|
-
}
|
|
1468
|
-
// Nested relational fields can also contain fragments
|
|
1469
|
-
if ((selection.kind === 'Field' || selection.kind === 'InlineFragment') && selection.selectionSet) {
|
|
1470
|
-
selection.selectionSet.selections = this.replaceFragmentsInSelections(selection.selectionSet.selections, fragments);
|
|
1471
|
-
}
|
|
1472
|
-
return selection;
|
|
1473
|
-
})).filter((s) => s);
|
|
1474
|
-
return result;
|
|
1475
|
-
}
|
|
1476
|
-
injectSystemResolvers(schemaComposer, { CreateCollectionTypes, ReadCollectionTypes, UpdateCollectionTypes, DeleteCollectionTypes, }, schema) {
|
|
1477
|
-
const AuthTokens = schemaComposer.createObjectTC({
|
|
1478
|
-
name: 'auth_tokens',
|
|
1479
|
-
fields: {
|
|
1480
|
-
access_token: graphql_1.GraphQLString,
|
|
1481
|
-
expires: bigint_1.GraphQLBigInt,
|
|
1482
|
-
refresh_token: graphql_1.GraphQLString,
|
|
1483
|
-
},
|
|
1484
|
-
});
|
|
1485
|
-
const AuthMode = new graphql_1.GraphQLEnumType({
|
|
1486
|
-
name: 'auth_mode',
|
|
1487
|
-
values: {
|
|
1488
|
-
json: { value: 'json' },
|
|
1489
|
-
cookie: { value: 'cookie' },
|
|
1490
|
-
},
|
|
1491
|
-
});
|
|
1492
|
-
const ServerInfo = schemaComposer.createObjectTC({
|
|
1493
|
-
name: 'server_info',
|
|
1494
|
-
fields: {
|
|
1495
|
-
project: {
|
|
1496
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1497
|
-
name: 'server_info_project',
|
|
1498
|
-
fields: {
|
|
1499
|
-
project_name: { type: graphql_1.GraphQLString },
|
|
1500
|
-
project_descriptor: { type: graphql_1.GraphQLString },
|
|
1501
|
-
project_logo: { type: graphql_1.GraphQLString },
|
|
1502
|
-
project_color: { type: graphql_1.GraphQLString },
|
|
1503
|
-
default_language: { type: graphql_1.GraphQLString },
|
|
1504
|
-
public_foreground: { type: graphql_1.GraphQLString },
|
|
1505
|
-
public_background: { type: graphql_1.GraphQLString },
|
|
1506
|
-
public_note: { type: graphql_1.GraphQLString },
|
|
1507
|
-
custom_css: { type: graphql_1.GraphQLString },
|
|
1508
|
-
},
|
|
1509
|
-
}),
|
|
1510
|
-
},
|
|
1511
|
-
},
|
|
1512
|
-
});
|
|
1513
|
-
if (this.accountability?.user) {
|
|
1514
|
-
ServerInfo.addFields({
|
|
1515
|
-
rateLimit: env_1.default['RATE_LIMITER_ENABLED']
|
|
1516
|
-
? {
|
|
1517
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1518
|
-
name: 'server_info_rate_limit',
|
|
1519
|
-
fields: {
|
|
1520
|
-
points: { type: graphql_1.GraphQLInt },
|
|
1521
|
-
duration: { type: graphql_1.GraphQLInt },
|
|
1522
|
-
},
|
|
1523
|
-
}),
|
|
1524
|
-
}
|
|
1525
|
-
: graphql_1.GraphQLBoolean,
|
|
1526
|
-
rateLimitGlobal: env_1.default['RATE_LIMITER_GLOBAL_ENABLED']
|
|
1527
|
-
? {
|
|
1528
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1529
|
-
name: 'server_info_rate_limit_global',
|
|
1530
|
-
fields: {
|
|
1531
|
-
points: { type: graphql_1.GraphQLInt },
|
|
1532
|
-
duration: { type: graphql_1.GraphQLInt },
|
|
1533
|
-
},
|
|
1534
|
-
}),
|
|
1535
|
-
}
|
|
1536
|
-
: graphql_1.GraphQLBoolean,
|
|
1537
|
-
flows: {
|
|
1538
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1539
|
-
name: 'server_info_flows',
|
|
1540
|
-
fields: {
|
|
1541
|
-
execAllowedModules: {
|
|
1542
|
-
type: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
1543
|
-
},
|
|
1544
|
-
},
|
|
1545
|
-
}),
|
|
1546
|
-
},
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
|
-
if (this.accountability?.admin === true) {
|
|
1550
|
-
ServerInfo.addFields({
|
|
1551
|
-
directus: {
|
|
1552
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1553
|
-
name: 'server_info_directus',
|
|
1554
|
-
fields: {
|
|
1555
|
-
version: {
|
|
1556
|
-
type: graphql_1.GraphQLString,
|
|
1557
|
-
},
|
|
1558
|
-
},
|
|
1559
|
-
}),
|
|
1560
|
-
},
|
|
1561
|
-
node: {
|
|
1562
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1563
|
-
name: 'server_info_node',
|
|
1564
|
-
fields: {
|
|
1565
|
-
version: {
|
|
1566
|
-
type: graphql_1.GraphQLString,
|
|
1567
|
-
},
|
|
1568
|
-
uptime: {
|
|
1569
|
-
type: graphql_1.GraphQLInt,
|
|
1570
|
-
},
|
|
1571
|
-
},
|
|
1572
|
-
}),
|
|
1573
|
-
},
|
|
1574
|
-
os: {
|
|
1575
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1576
|
-
name: 'server_info_os',
|
|
1577
|
-
fields: {
|
|
1578
|
-
type: {
|
|
1579
|
-
type: graphql_1.GraphQLString,
|
|
1580
|
-
},
|
|
1581
|
-
version: {
|
|
1582
|
-
type: graphql_1.GraphQLString,
|
|
1583
|
-
},
|
|
1584
|
-
uptime: {
|
|
1585
|
-
type: graphql_1.GraphQLInt,
|
|
1586
|
-
},
|
|
1587
|
-
totalmem: {
|
|
1588
|
-
type: graphql_1.GraphQLInt,
|
|
1589
|
-
},
|
|
1590
|
-
},
|
|
1591
|
-
}),
|
|
1592
|
-
},
|
|
1593
|
-
});
|
|
1594
|
-
}
|
|
1595
|
-
/** Globally available query */
|
|
1596
|
-
schemaComposer.Query.addFields({
|
|
1597
|
-
extensions: {
|
|
1598
|
-
type: schemaComposer.createObjectTC({
|
|
1599
|
-
name: 'extensions',
|
|
1600
|
-
fields: {
|
|
1601
|
-
interfaces: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
1602
|
-
displays: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
1603
|
-
layouts: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
1604
|
-
modules: new graphql_1.GraphQLList(graphql_1.GraphQLString),
|
|
1605
|
-
},
|
|
1606
|
-
}),
|
|
1607
|
-
resolve: async () => {
|
|
1608
|
-
const extensionManager = (0, extensions_1.getExtensionManager)();
|
|
1609
|
-
return {
|
|
1610
|
-
interfaces: extensionManager.getExtensionsList('interface'),
|
|
1611
|
-
displays: extensionManager.getExtensionsList('display'),
|
|
1612
|
-
layouts: extensionManager.getExtensionsList('layout'),
|
|
1613
|
-
modules: extensionManager.getExtensionsList('module'),
|
|
1614
|
-
};
|
|
1615
|
-
},
|
|
1616
|
-
},
|
|
1617
|
-
server_specs_oas: {
|
|
1618
|
-
type: graphql_compose_1.GraphQLJSON,
|
|
1619
|
-
resolve: async () => {
|
|
1620
|
-
const service = new specifications_1.SpecificationService({ schema: this.schema, accountability: this.accountability });
|
|
1621
|
-
return await service.oas.generate();
|
|
1622
|
-
},
|
|
1623
|
-
},
|
|
1624
|
-
server_specs_graphql: {
|
|
1625
|
-
type: graphql_1.GraphQLString,
|
|
1626
|
-
args: {
|
|
1627
|
-
scope: new graphql_1.GraphQLEnumType({
|
|
1628
|
-
name: 'graphql_sdl_scope',
|
|
1629
|
-
values: {
|
|
1630
|
-
items: { value: 'items' },
|
|
1631
|
-
system: { value: 'system' },
|
|
1632
|
-
},
|
|
1633
|
-
}),
|
|
1634
|
-
},
|
|
1635
|
-
resolve: async (_, args) => {
|
|
1636
|
-
const service = new GraphQLService({
|
|
1637
|
-
schema: this.schema,
|
|
1638
|
-
accountability: this.accountability,
|
|
1639
|
-
scope: args['scope'] ?? 'items',
|
|
1640
|
-
});
|
|
1641
|
-
return service.getSchema('sdl');
|
|
1642
|
-
},
|
|
1643
|
-
},
|
|
1644
|
-
server_ping: {
|
|
1645
|
-
type: graphql_1.GraphQLString,
|
|
1646
|
-
resolve: () => 'pong',
|
|
1647
|
-
},
|
|
1648
|
-
server_info: {
|
|
1649
|
-
type: ServerInfo,
|
|
1650
|
-
resolve: async () => {
|
|
1651
|
-
const service = new server_1.ServerService({
|
|
1652
|
-
accountability: this.accountability,
|
|
1653
|
-
schema: this.schema,
|
|
1654
|
-
});
|
|
1655
|
-
return await service.serverInfo();
|
|
1656
|
-
},
|
|
1657
|
-
},
|
|
1658
|
-
server_health: {
|
|
1659
|
-
type: graphql_compose_1.GraphQLJSON,
|
|
1660
|
-
resolve: async () => {
|
|
1661
|
-
const service = new server_1.ServerService({
|
|
1662
|
-
accountability: this.accountability,
|
|
1663
|
-
schema: this.schema,
|
|
1664
|
-
});
|
|
1665
|
-
return await service.health();
|
|
1666
|
-
},
|
|
1667
|
-
},
|
|
1668
|
-
});
|
|
1669
|
-
const Collection = schemaComposer.createObjectTC({
|
|
1670
|
-
name: 'directus_collections',
|
|
1671
|
-
});
|
|
1672
|
-
const Field = schemaComposer.createObjectTC({
|
|
1673
|
-
name: 'directus_fields',
|
|
1674
|
-
});
|
|
1675
|
-
const Relation = schemaComposer.createObjectTC({
|
|
1676
|
-
name: 'directus_relations',
|
|
1677
|
-
});
|
|
1678
|
-
/**
|
|
1679
|
-
* Globally available mutations
|
|
1680
|
-
*/
|
|
1681
|
-
schemaComposer.Mutation.addFields({
|
|
1682
|
-
auth_login: {
|
|
1683
|
-
type: AuthTokens,
|
|
1684
|
-
args: {
|
|
1685
|
-
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1686
|
-
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1687
|
-
mode: AuthMode,
|
|
1688
|
-
otp: graphql_1.GraphQLString,
|
|
1689
|
-
},
|
|
1690
|
-
resolve: async (_, args, { req, res }) => {
|
|
1691
|
-
const accountability = { role: null };
|
|
1692
|
-
if (req?.ip)
|
|
1693
|
-
accountability.ip = req.ip;
|
|
1694
|
-
const userAgent = req?.get('user-agent');
|
|
1695
|
-
if (userAgent)
|
|
1696
|
-
accountability.userAgent = userAgent;
|
|
1697
|
-
const origin = req?.get('origin');
|
|
1698
|
-
if (origin)
|
|
1699
|
-
accountability.origin = origin;
|
|
1700
|
-
const authenticationService = new authentication_1.AuthenticationService({
|
|
1701
|
-
accountability: accountability,
|
|
1702
|
-
schema: this.schema,
|
|
1703
|
-
});
|
|
1704
|
-
const result = await authenticationService.login(constants_2.DEFAULT_AUTH_PROVIDER, args, args?.otp);
|
|
1705
|
-
if (args['mode'] === 'cookie') {
|
|
1706
|
-
res?.cookie(env_1.default['REFRESH_TOKEN_COOKIE_NAME'], result['refreshToken'], {
|
|
1707
|
-
httpOnly: true,
|
|
1708
|
-
domain: env_1.default['REFRESH_TOKEN_COOKIE_DOMAIN'],
|
|
1709
|
-
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL']),
|
|
1710
|
-
secure: env_1.default['REFRESH_TOKEN_COOKIE_SECURE'] ?? false,
|
|
1711
|
-
sameSite: env_1.default['REFRESH_TOKEN_COOKIE_SAME_SITE'] || 'strict',
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
return {
|
|
1715
|
-
access_token: result['accessToken'],
|
|
1716
|
-
expires: result['expires'],
|
|
1717
|
-
refresh_token: result['refreshToken'],
|
|
1718
|
-
};
|
|
1719
|
-
},
|
|
1720
|
-
},
|
|
1721
|
-
auth_refresh: {
|
|
1722
|
-
type: AuthTokens,
|
|
1723
|
-
args: {
|
|
1724
|
-
refresh_token: graphql_1.GraphQLString,
|
|
1725
|
-
mode: AuthMode,
|
|
1726
|
-
},
|
|
1727
|
-
resolve: async (_, args, { req, res }) => {
|
|
1728
|
-
const accountability = { role: null };
|
|
1729
|
-
if (req?.ip)
|
|
1730
|
-
accountability.ip = req.ip;
|
|
1731
|
-
const userAgent = req?.get('user-agent');
|
|
1732
|
-
if (userAgent)
|
|
1733
|
-
accountability.userAgent = userAgent;
|
|
1734
|
-
const origin = req?.get('origin');
|
|
1735
|
-
if (origin)
|
|
1736
|
-
accountability.origin = origin;
|
|
1737
|
-
const authenticationService = new authentication_1.AuthenticationService({
|
|
1738
|
-
accountability: accountability,
|
|
1739
|
-
schema: this.schema,
|
|
1740
|
-
});
|
|
1741
|
-
const currentRefreshToken = args['refresh_token'] || req?.cookies[env_1.default['REFRESH_TOKEN_COOKIE_NAME']];
|
|
1742
|
-
if (!currentRefreshToken) {
|
|
1743
|
-
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1744
|
-
}
|
|
1745
|
-
const result = await authenticationService.refresh(currentRefreshToken);
|
|
1746
|
-
if (args['mode'] === 'cookie') {
|
|
1747
|
-
res?.cookie(env_1.default['REFRESH_TOKEN_COOKIE_NAME'], result['refreshToken'], {
|
|
1748
|
-
httpOnly: true,
|
|
1749
|
-
domain: env_1.default['REFRESH_TOKEN_COOKIE_DOMAIN'],
|
|
1750
|
-
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL']),
|
|
1751
|
-
secure: env_1.default['REFRESH_TOKEN_COOKIE_SECURE'] ?? false,
|
|
1752
|
-
sameSite: env_1.default['REFRESH_TOKEN_COOKIE_SAME_SITE'] || 'strict',
|
|
1753
|
-
});
|
|
1754
|
-
}
|
|
1755
|
-
return {
|
|
1756
|
-
access_token: result['accessToken'],
|
|
1757
|
-
expires: result['expires'],
|
|
1758
|
-
refresh_token: result['refreshToken'],
|
|
1759
|
-
};
|
|
1760
|
-
},
|
|
1761
|
-
},
|
|
1762
|
-
auth_logout: {
|
|
1763
|
-
type: graphql_1.GraphQLBoolean,
|
|
1764
|
-
args: {
|
|
1765
|
-
refresh_token: graphql_1.GraphQLString,
|
|
1766
|
-
},
|
|
1767
|
-
resolve: async (_, args, { req }) => {
|
|
1768
|
-
const accountability = { role: null };
|
|
1769
|
-
if (req?.ip)
|
|
1770
|
-
accountability.ip = req.ip;
|
|
1771
|
-
const userAgent = req?.get('user-agent');
|
|
1772
|
-
if (userAgent)
|
|
1773
|
-
accountability.userAgent = userAgent;
|
|
1774
|
-
const origin = req?.get('origin');
|
|
1775
|
-
if (origin)
|
|
1776
|
-
accountability.origin = origin;
|
|
1777
|
-
const authenticationService = new authentication_1.AuthenticationService({
|
|
1778
|
-
accountability: accountability,
|
|
1779
|
-
schema: this.schema,
|
|
1780
|
-
});
|
|
1781
|
-
const currentRefreshToken = args['refresh_token'] || req?.cookies[env_1.default['REFRESH_TOKEN_COOKIE_NAME']];
|
|
1782
|
-
if (!currentRefreshToken) {
|
|
1783
|
-
throw new exceptions_1.InvalidPayloadException(`"refresh_token" is required in either the JSON payload or Cookie`);
|
|
1784
|
-
}
|
|
1785
|
-
await authenticationService.logout(currentRefreshToken);
|
|
1786
|
-
return true;
|
|
1787
|
-
},
|
|
1788
|
-
},
|
|
1789
|
-
auth_password_request: {
|
|
1790
|
-
type: graphql_1.GraphQLBoolean,
|
|
1791
|
-
args: {
|
|
1792
|
-
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1793
|
-
reset_url: graphql_1.GraphQLString,
|
|
1794
|
-
},
|
|
1795
|
-
resolve: async (_, args, { req }) => {
|
|
1796
|
-
const accountability = { role: null };
|
|
1797
|
-
if (req?.ip)
|
|
1798
|
-
accountability.ip = req.ip;
|
|
1799
|
-
const userAgent = req?.get('user-agent');
|
|
1800
|
-
if (userAgent)
|
|
1801
|
-
accountability.userAgent = userAgent;
|
|
1802
|
-
const origin = req?.get('origin');
|
|
1803
|
-
if (origin)
|
|
1804
|
-
accountability.origin = origin;
|
|
1805
|
-
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1806
|
-
try {
|
|
1807
|
-
await service.requestPasswordReset(args['email'], args['reset_url'] || null);
|
|
1808
|
-
}
|
|
1809
|
-
catch (err) {
|
|
1810
|
-
if (err instanceof exceptions_1.InvalidPayloadException) {
|
|
1811
|
-
throw err;
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
return true;
|
|
1815
|
-
},
|
|
1816
|
-
},
|
|
1817
|
-
auth_password_reset: {
|
|
1818
|
-
type: graphql_1.GraphQLBoolean,
|
|
1819
|
-
args: {
|
|
1820
|
-
token: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1821
|
-
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1822
|
-
},
|
|
1823
|
-
resolve: async (_, args, { req }) => {
|
|
1824
|
-
const accountability = { role: null };
|
|
1825
|
-
if (req?.ip)
|
|
1826
|
-
accountability.ip = req.ip;
|
|
1827
|
-
const userAgent = req?.get('user-agent');
|
|
1828
|
-
if (userAgent)
|
|
1829
|
-
accountability.userAgent = userAgent;
|
|
1830
|
-
const origin = req?.get('origin');
|
|
1831
|
-
if (origin)
|
|
1832
|
-
accountability.origin = origin;
|
|
1833
|
-
const service = new users_1.UsersService({ accountability, schema: this.schema });
|
|
1834
|
-
await service.resetPassword(args['token'], args['password']);
|
|
1835
|
-
return true;
|
|
1836
|
-
},
|
|
1837
|
-
},
|
|
1838
|
-
users_me_tfa_generate: {
|
|
1839
|
-
type: new graphql_1.GraphQLObjectType({
|
|
1840
|
-
name: 'users_me_tfa_generate_data',
|
|
1841
|
-
fields: {
|
|
1842
|
-
secret: { type: graphql_1.GraphQLString },
|
|
1843
|
-
otpauth_url: { type: graphql_1.GraphQLString },
|
|
1844
|
-
},
|
|
1845
|
-
}),
|
|
1846
|
-
args: {
|
|
1847
|
-
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1848
|
-
},
|
|
1849
|
-
resolve: async (_, args) => {
|
|
1850
|
-
if (!this.accountability?.user)
|
|
1851
|
-
return null;
|
|
1852
|
-
const service = new tfa_1.TFAService({
|
|
1853
|
-
accountability: this.accountability,
|
|
1854
|
-
schema: this.schema,
|
|
1855
|
-
});
|
|
1856
|
-
const authService = new authentication_1.AuthenticationService({
|
|
1857
|
-
accountability: this.accountability,
|
|
1858
|
-
schema: this.schema,
|
|
1859
|
-
});
|
|
1860
|
-
await authService.verifyPassword(this.accountability.user, args['password']);
|
|
1861
|
-
const { url, secret } = await service.generateTFA(this.accountability.user);
|
|
1862
|
-
return { secret, otpauth_url: url };
|
|
1863
|
-
},
|
|
1864
|
-
},
|
|
1865
|
-
users_me_tfa_enable: {
|
|
1866
|
-
type: graphql_1.GraphQLBoolean,
|
|
1867
|
-
args: {
|
|
1868
|
-
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1869
|
-
secret: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1870
|
-
},
|
|
1871
|
-
resolve: async (_, args) => {
|
|
1872
|
-
if (!this.accountability?.user)
|
|
1873
|
-
return null;
|
|
1874
|
-
const service = new tfa_1.TFAService({
|
|
1875
|
-
accountability: this.accountability,
|
|
1876
|
-
schema: this.schema,
|
|
1877
|
-
});
|
|
1878
|
-
await service.enableTFA(this.accountability.user, args['otp'], args['secret']);
|
|
1879
|
-
return true;
|
|
1880
|
-
},
|
|
1881
|
-
},
|
|
1882
|
-
users_me_tfa_disable: {
|
|
1883
|
-
type: graphql_1.GraphQLBoolean,
|
|
1884
|
-
args: {
|
|
1885
|
-
otp: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1886
|
-
},
|
|
1887
|
-
resolve: async (_, args) => {
|
|
1888
|
-
if (!this.accountability?.user)
|
|
1889
|
-
return null;
|
|
1890
|
-
const service = new tfa_1.TFAService({
|
|
1891
|
-
accountability: this.accountability,
|
|
1892
|
-
schema: this.schema,
|
|
1893
|
-
});
|
|
1894
|
-
const otpValid = await service.verifyOTP(this.accountability.user, args['otp']);
|
|
1895
|
-
if (otpValid === false) {
|
|
1896
|
-
throw new exceptions_1.InvalidPayloadException(`"otp" is invalid`);
|
|
1897
|
-
}
|
|
1898
|
-
await service.disableTFA(this.accountability.user);
|
|
1899
|
-
return true;
|
|
1900
|
-
},
|
|
1901
|
-
},
|
|
1902
|
-
utils_random_string: {
|
|
1903
|
-
type: graphql_1.GraphQLString,
|
|
1904
|
-
args: {
|
|
1905
|
-
length: graphql_1.GraphQLInt,
|
|
1906
|
-
},
|
|
1907
|
-
resolve: async (_, args) => {
|
|
1908
|
-
const { nanoid } = await import('nanoid');
|
|
1909
|
-
if (args['length'] && Number(args['length']) > 500) {
|
|
1910
|
-
throw new exceptions_1.InvalidPayloadException(`"length" can't be more than 500 characters`);
|
|
1911
|
-
}
|
|
1912
|
-
return nanoid(args['length'] ? Number(args['length']) : 32);
|
|
1913
|
-
},
|
|
1914
|
-
},
|
|
1915
|
-
utils_hash_generate: {
|
|
1916
|
-
type: graphql_1.GraphQLString,
|
|
1917
|
-
args: {
|
|
1918
|
-
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1919
|
-
},
|
|
1920
|
-
resolve: async (_, args) => {
|
|
1921
|
-
return await (0, generate_hash_1.generateHash)(args['string']);
|
|
1922
|
-
},
|
|
1923
|
-
},
|
|
1924
|
-
utils_hash_verify: {
|
|
1925
|
-
type: graphql_1.GraphQLBoolean,
|
|
1926
|
-
args: {
|
|
1927
|
-
string: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1928
|
-
hash: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1929
|
-
},
|
|
1930
|
-
resolve: async (_, args) => {
|
|
1931
|
-
return await argon2_1.default.verify(args['hash'], args['string']);
|
|
1932
|
-
},
|
|
1933
|
-
},
|
|
1934
|
-
utils_sort: {
|
|
1935
|
-
type: graphql_1.GraphQLBoolean,
|
|
1936
|
-
args: {
|
|
1937
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1938
|
-
item: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1939
|
-
to: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1940
|
-
},
|
|
1941
|
-
resolve: async (_, args) => {
|
|
1942
|
-
const service = new utils_2.UtilsService({
|
|
1943
|
-
accountability: this.accountability,
|
|
1944
|
-
schema: this.schema,
|
|
1945
|
-
});
|
|
1946
|
-
const { item, to } = args;
|
|
1947
|
-
await service.sort(args['collection'], { item, to });
|
|
1948
|
-
return true;
|
|
1949
|
-
},
|
|
1950
|
-
},
|
|
1951
|
-
utils_revert: {
|
|
1952
|
-
type: graphql_1.GraphQLBoolean,
|
|
1953
|
-
args: {
|
|
1954
|
-
revision: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
1955
|
-
},
|
|
1956
|
-
resolve: async (_, args) => {
|
|
1957
|
-
const service = new revisions_1.RevisionsService({
|
|
1958
|
-
accountability: this.accountability,
|
|
1959
|
-
schema: this.schema,
|
|
1960
|
-
});
|
|
1961
|
-
await service.revert(args['revision']);
|
|
1962
|
-
return true;
|
|
1963
|
-
},
|
|
1964
|
-
},
|
|
1965
|
-
utils_cache_clear: {
|
|
1966
|
-
type: void_1.GraphQLVoid,
|
|
1967
|
-
resolve: async () => {
|
|
1968
|
-
if (this.accountability?.admin !== true) {
|
|
1969
|
-
throw new exceptions_1.ForbiddenException();
|
|
1970
|
-
}
|
|
1971
|
-
const { cache } = (0, cache_1.getCache)();
|
|
1972
|
-
await cache?.clear();
|
|
1973
|
-
await (0, cache_1.clearSystemCache)();
|
|
1974
|
-
return;
|
|
1975
|
-
},
|
|
1976
|
-
},
|
|
1977
|
-
users_invite_accept: {
|
|
1978
|
-
type: graphql_1.GraphQLBoolean,
|
|
1979
|
-
args: {
|
|
1980
|
-
token: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1981
|
-
password: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
1982
|
-
},
|
|
1983
|
-
resolve: async (_, args) => {
|
|
1984
|
-
const service = new users_1.UsersService({
|
|
1985
|
-
accountability: this.accountability,
|
|
1986
|
-
schema: this.schema,
|
|
1987
|
-
});
|
|
1988
|
-
await service.acceptInvite(args['token'], args['password']);
|
|
1989
|
-
return true;
|
|
1990
|
-
},
|
|
1991
|
-
},
|
|
1992
|
-
});
|
|
1993
|
-
if ('directus_collections' in schema.read.collections) {
|
|
1994
|
-
Collection.addFields({
|
|
1995
|
-
collection: graphql_1.GraphQLString,
|
|
1996
|
-
meta: schemaComposer.createObjectTC({
|
|
1997
|
-
name: 'directus_collections_meta',
|
|
1998
|
-
fields: Object.values(schema.read.collections['directus_collections'].fields).reduce((acc, field) => {
|
|
1999
|
-
acc[field.field] = {
|
|
2000
|
-
type: field.nullable
|
|
2001
|
-
? (0, get_graphql_type_1.getGraphQLType)(field.type, field.special)
|
|
2002
|
-
: new graphql_1.GraphQLNonNull((0, get_graphql_type_1.getGraphQLType)(field.type, field.special)),
|
|
2003
|
-
description: field.note,
|
|
2004
|
-
};
|
|
2005
|
-
return acc;
|
|
2006
|
-
}, {}),
|
|
2007
|
-
}),
|
|
2008
|
-
schema: schemaComposer.createObjectTC({
|
|
2009
|
-
name: 'directus_collections_schema',
|
|
2010
|
-
fields: {
|
|
2011
|
-
name: graphql_1.GraphQLString,
|
|
2012
|
-
comment: graphql_1.GraphQLString,
|
|
2013
|
-
},
|
|
2014
|
-
}),
|
|
2015
|
-
});
|
|
2016
|
-
schemaComposer.Query.addFields({
|
|
2017
|
-
collections: {
|
|
2018
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Collection.getType()))),
|
|
2019
|
-
resolve: async () => {
|
|
2020
|
-
const collectionsService = new collections_1.CollectionsService({
|
|
2021
|
-
accountability: this.accountability,
|
|
2022
|
-
schema: this.schema,
|
|
2023
|
-
});
|
|
2024
|
-
return await collectionsService.readByQuery();
|
|
2025
|
-
},
|
|
2026
|
-
},
|
|
2027
|
-
collections_by_name: {
|
|
2028
|
-
type: Collection,
|
|
2029
|
-
args: {
|
|
2030
|
-
name: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2031
|
-
},
|
|
2032
|
-
resolve: async (_, args) => {
|
|
2033
|
-
const collectionsService = new collections_1.CollectionsService({
|
|
2034
|
-
accountability: this.accountability,
|
|
2035
|
-
schema: this.schema,
|
|
2036
|
-
});
|
|
2037
|
-
return await collectionsService.readOne(args['name']);
|
|
2038
|
-
},
|
|
2039
|
-
},
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
if ('directus_fields' in schema.read.collections) {
|
|
2043
|
-
Field.addFields({
|
|
2044
|
-
collection: graphql_1.GraphQLString,
|
|
2045
|
-
field: graphql_1.GraphQLString,
|
|
2046
|
-
type: graphql_1.GraphQLString,
|
|
2047
|
-
meta: schemaComposer.createObjectTC({
|
|
2048
|
-
name: 'directus_fields_meta',
|
|
2049
|
-
fields: Object.values(schema.read.collections['directus_fields'].fields).reduce((acc, field) => {
|
|
2050
|
-
acc[field.field] = {
|
|
2051
|
-
type: field.nullable
|
|
2052
|
-
? (0, get_graphql_type_1.getGraphQLType)(field.type, field.special)
|
|
2053
|
-
: new graphql_1.GraphQLNonNull((0, get_graphql_type_1.getGraphQLType)(field.type, field.special)),
|
|
2054
|
-
description: field.note,
|
|
2055
|
-
};
|
|
2056
|
-
return acc;
|
|
2057
|
-
}, {}),
|
|
2058
|
-
}),
|
|
2059
|
-
schema: schemaComposer.createObjectTC({
|
|
2060
|
-
name: 'directus_fields_schema',
|
|
2061
|
-
fields: {
|
|
2062
|
-
name: graphql_1.GraphQLString,
|
|
2063
|
-
table: graphql_1.GraphQLString,
|
|
2064
|
-
data_type: graphql_1.GraphQLString,
|
|
2065
|
-
default_value: graphql_1.GraphQLString,
|
|
2066
|
-
max_length: graphql_1.GraphQLInt,
|
|
2067
|
-
numeric_precision: graphql_1.GraphQLInt,
|
|
2068
|
-
numeric_scale: graphql_1.GraphQLInt,
|
|
2069
|
-
is_nullable: graphql_1.GraphQLBoolean,
|
|
2070
|
-
is_unique: graphql_1.GraphQLBoolean,
|
|
2071
|
-
is_primary_key: graphql_1.GraphQLBoolean,
|
|
2072
|
-
has_auto_increment: graphql_1.GraphQLBoolean,
|
|
2073
|
-
foreign_key_column: graphql_1.GraphQLString,
|
|
2074
|
-
foreign_key_table: graphql_1.GraphQLString,
|
|
2075
|
-
comment: graphql_1.GraphQLString,
|
|
2076
|
-
},
|
|
2077
|
-
}),
|
|
2078
|
-
});
|
|
2079
|
-
schemaComposer.Query.addFields({
|
|
2080
|
-
fields: {
|
|
2081
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Field.getType()))),
|
|
2082
|
-
resolve: async () => {
|
|
2083
|
-
const service = new fields_1.FieldsService({
|
|
2084
|
-
accountability: this.accountability,
|
|
2085
|
-
schema: this.schema,
|
|
2086
|
-
});
|
|
2087
|
-
return await service.readAll();
|
|
2088
|
-
},
|
|
2089
|
-
},
|
|
2090
|
-
fields_in_collection: {
|
|
2091
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Field.getType()))),
|
|
2092
|
-
args: {
|
|
2093
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2094
|
-
},
|
|
2095
|
-
resolve: async (_, args) => {
|
|
2096
|
-
const service = new fields_1.FieldsService({
|
|
2097
|
-
accountability: this.accountability,
|
|
2098
|
-
schema: this.schema,
|
|
2099
|
-
});
|
|
2100
|
-
return await service.readAll(args['collection']);
|
|
2101
|
-
},
|
|
2102
|
-
},
|
|
2103
|
-
fields_by_name: {
|
|
2104
|
-
type: Field,
|
|
2105
|
-
args: {
|
|
2106
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2107
|
-
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2108
|
-
},
|
|
2109
|
-
resolve: async (_, args) => {
|
|
2110
|
-
const service = new fields_1.FieldsService({
|
|
2111
|
-
accountability: this.accountability,
|
|
2112
|
-
schema: this.schema,
|
|
2113
|
-
});
|
|
2114
|
-
return await service.readOne(args['collection'], args['field']);
|
|
2115
|
-
},
|
|
2116
|
-
},
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
if ('directus_relations' in schema.read.collections) {
|
|
2120
|
-
Relation.addFields({
|
|
2121
|
-
collection: graphql_1.GraphQLString,
|
|
2122
|
-
field: graphql_1.GraphQLString,
|
|
2123
|
-
related_collection: graphql_1.GraphQLString,
|
|
2124
|
-
schema: schemaComposer.createObjectTC({
|
|
2125
|
-
name: 'directus_relations_schema',
|
|
2126
|
-
fields: {
|
|
2127
|
-
table: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2128
|
-
column: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2129
|
-
foreign_key_table: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2130
|
-
foreign_key_column: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2131
|
-
constraint_name: graphql_1.GraphQLString,
|
|
2132
|
-
on_update: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2133
|
-
on_delete: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2134
|
-
},
|
|
2135
|
-
}),
|
|
2136
|
-
meta: schemaComposer.createObjectTC({
|
|
2137
|
-
name: 'directus_relations_meta',
|
|
2138
|
-
fields: Object.values(schema.read.collections['directus_relations'].fields).reduce((acc, field) => {
|
|
2139
|
-
acc[field.field] = {
|
|
2140
|
-
type: (0, get_graphql_type_1.getGraphQLType)(field.type, field.special),
|
|
2141
|
-
description: field.note,
|
|
2142
|
-
};
|
|
2143
|
-
return acc;
|
|
2144
|
-
}, {}),
|
|
2145
|
-
}),
|
|
2146
|
-
});
|
|
2147
|
-
schemaComposer.Query.addFields({
|
|
2148
|
-
relations: {
|
|
2149
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Relation.getType()))),
|
|
2150
|
-
resolve: async () => {
|
|
2151
|
-
const service = new relations_1.RelationsService({
|
|
2152
|
-
accountability: this.accountability,
|
|
2153
|
-
schema: this.schema,
|
|
2154
|
-
});
|
|
2155
|
-
return await service.readAll();
|
|
2156
|
-
},
|
|
2157
|
-
},
|
|
2158
|
-
relations_in_collection: {
|
|
2159
|
-
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(Relation.getType()))),
|
|
2160
|
-
args: {
|
|
2161
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2162
|
-
},
|
|
2163
|
-
resolve: async (_, args) => {
|
|
2164
|
-
const service = new relations_1.RelationsService({
|
|
2165
|
-
accountability: this.accountability,
|
|
2166
|
-
schema: this.schema,
|
|
2167
|
-
});
|
|
2168
|
-
return await service.readAll(args['collection']);
|
|
2169
|
-
},
|
|
2170
|
-
},
|
|
2171
|
-
relations_by_name: {
|
|
2172
|
-
type: Relation,
|
|
2173
|
-
args: {
|
|
2174
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2175
|
-
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2176
|
-
},
|
|
2177
|
-
resolve: async (_, args) => {
|
|
2178
|
-
const service = new relations_1.RelationsService({
|
|
2179
|
-
accountability: this.accountability,
|
|
2180
|
-
schema: this.schema,
|
|
2181
|
-
});
|
|
2182
|
-
return await service.readOne(args['collection'], args['field']);
|
|
2183
|
-
},
|
|
2184
|
-
},
|
|
2185
|
-
});
|
|
2186
|
-
}
|
|
2187
|
-
if (this.accountability?.admin === true) {
|
|
2188
|
-
schemaComposer.Mutation.addFields({
|
|
2189
|
-
create_collections_item: {
|
|
2190
|
-
type: Collection,
|
|
2191
|
-
args: {
|
|
2192
|
-
data: (0, graphql_compose_1.toInputObjectType)(Collection.clone('create_directus_collections'), {
|
|
2193
|
-
postfix: '_input',
|
|
2194
|
-
}).addFields({
|
|
2195
|
-
fields: [
|
|
2196
|
-
(0, graphql_compose_1.toInputObjectType)(Field.clone('create_directus_collections_fields'), { postfix: '_input' }).NonNull,
|
|
2197
|
-
],
|
|
2198
|
-
}).NonNull,
|
|
2199
|
-
},
|
|
2200
|
-
resolve: async (_, args) => {
|
|
2201
|
-
const collectionsService = new collections_1.CollectionsService({
|
|
2202
|
-
accountability: this.accountability,
|
|
2203
|
-
schema: this.schema,
|
|
2204
|
-
});
|
|
2205
|
-
const collectionKey = await collectionsService.createOne(args['data']);
|
|
2206
|
-
return await collectionsService.readOne(collectionKey);
|
|
2207
|
-
},
|
|
2208
|
-
},
|
|
2209
|
-
update_collections_item: {
|
|
2210
|
-
type: Collection,
|
|
2211
|
-
args: {
|
|
2212
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2213
|
-
data: (0, graphql_compose_1.toInputObjectType)(Collection.clone('update_directus_collections'), {
|
|
2214
|
-
postfix: '_input',
|
|
2215
|
-
}).removeField(['collection', 'schema']).NonNull,
|
|
2216
|
-
},
|
|
2217
|
-
resolve: async (_, args) => {
|
|
2218
|
-
const collectionsService = new collections_1.CollectionsService({
|
|
2219
|
-
accountability: this.accountability,
|
|
2220
|
-
schema: this.schema,
|
|
2221
|
-
});
|
|
2222
|
-
const collectionKey = await collectionsService.updateOne(args['collection'], args['data']);
|
|
2223
|
-
return await collectionsService.readOne(collectionKey);
|
|
2224
|
-
},
|
|
2225
|
-
},
|
|
2226
|
-
delete_collections_item: {
|
|
2227
|
-
type: schemaComposer.createObjectTC({
|
|
2228
|
-
name: 'delete_collection',
|
|
2229
|
-
fields: {
|
|
2230
|
-
collection: graphql_1.GraphQLString,
|
|
2231
|
-
},
|
|
2232
|
-
}),
|
|
2233
|
-
args: {
|
|
2234
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2235
|
-
},
|
|
2236
|
-
resolve: async (_, args) => {
|
|
2237
|
-
const collectionsService = new collections_1.CollectionsService({
|
|
2238
|
-
accountability: this.accountability,
|
|
2239
|
-
schema: this.schema,
|
|
2240
|
-
});
|
|
2241
|
-
await collectionsService.deleteOne(args['collection']);
|
|
2242
|
-
return { collection: args['collection'] };
|
|
2243
|
-
},
|
|
2244
|
-
},
|
|
2245
|
-
});
|
|
2246
|
-
schemaComposer.Mutation.addFields({
|
|
2247
|
-
create_fields_item: {
|
|
2248
|
-
type: Field,
|
|
2249
|
-
args: {
|
|
2250
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2251
|
-
data: (0, graphql_compose_1.toInputObjectType)(Field.clone('create_directus_fields'), { postfix: '_input' }).NonNull,
|
|
2252
|
-
},
|
|
2253
|
-
resolve: async (_, args) => {
|
|
2254
|
-
const service = new fields_1.FieldsService({
|
|
2255
|
-
accountability: this.accountability,
|
|
2256
|
-
schema: this.schema,
|
|
2257
|
-
});
|
|
2258
|
-
await service.createField(args['collection'], args['data']);
|
|
2259
|
-
return await service.readOne(args['collection'], args['data'].field);
|
|
2260
|
-
},
|
|
2261
|
-
},
|
|
2262
|
-
update_fields_item: {
|
|
2263
|
-
type: Field,
|
|
2264
|
-
args: {
|
|
2265
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2266
|
-
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2267
|
-
data: (0, graphql_compose_1.toInputObjectType)(Field.clone('update_directus_fields'), { postfix: '_input' }).NonNull,
|
|
2268
|
-
},
|
|
2269
|
-
resolve: async (_, args) => {
|
|
2270
|
-
const service = new fields_1.FieldsService({
|
|
2271
|
-
accountability: this.accountability,
|
|
2272
|
-
schema: this.schema,
|
|
2273
|
-
});
|
|
2274
|
-
await service.updateField(args['collection'], {
|
|
2275
|
-
...args['data'],
|
|
2276
|
-
field: args['field'],
|
|
2277
|
-
});
|
|
2278
|
-
return await service.readOne(args['collection'], args['data'].field);
|
|
2279
|
-
},
|
|
2280
|
-
},
|
|
2281
|
-
delete_fields_item: {
|
|
2282
|
-
type: schemaComposer.createObjectTC({
|
|
2283
|
-
name: 'delete_field',
|
|
2284
|
-
fields: {
|
|
2285
|
-
collection: graphql_1.GraphQLString,
|
|
2286
|
-
field: graphql_1.GraphQLString,
|
|
2287
|
-
},
|
|
2288
|
-
}),
|
|
2289
|
-
args: {
|
|
2290
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2291
|
-
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2292
|
-
},
|
|
2293
|
-
resolve: async (_, args) => {
|
|
2294
|
-
const service = new fields_1.FieldsService({
|
|
2295
|
-
accountability: this.accountability,
|
|
2296
|
-
schema: this.schema,
|
|
2297
|
-
});
|
|
2298
|
-
await service.deleteField(args['collection'], args['field']);
|
|
2299
|
-
const { collection, field } = args;
|
|
2300
|
-
return { collection, field };
|
|
2301
|
-
},
|
|
2302
|
-
},
|
|
2303
|
-
});
|
|
2304
|
-
schemaComposer.Mutation.addFields({
|
|
2305
|
-
create_relations_item: {
|
|
2306
|
-
type: Relation,
|
|
2307
|
-
args: {
|
|
2308
|
-
data: (0, graphql_compose_1.toInputObjectType)(Relation.clone('create_directus_relations'), { postfix: '_input' }).NonNull,
|
|
2309
|
-
},
|
|
2310
|
-
resolve: async (_, args) => {
|
|
2311
|
-
const relationsService = new relations_1.RelationsService({
|
|
2312
|
-
accountability: this.accountability,
|
|
2313
|
-
schema: this.schema,
|
|
2314
|
-
});
|
|
2315
|
-
await relationsService.createOne(args['data']);
|
|
2316
|
-
return await relationsService.readOne(args['data'].collection, args['data'].field);
|
|
2317
|
-
},
|
|
2318
|
-
},
|
|
2319
|
-
update_relations_item: {
|
|
2320
|
-
type: Relation,
|
|
2321
|
-
args: {
|
|
2322
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2323
|
-
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2324
|
-
data: (0, graphql_compose_1.toInputObjectType)(Relation.clone('update_directus_relations'), { postfix: '_input' }).NonNull,
|
|
2325
|
-
},
|
|
2326
|
-
resolve: async (_, args) => {
|
|
2327
|
-
const relationsService = new relations_1.RelationsService({
|
|
2328
|
-
accountability: this.accountability,
|
|
2329
|
-
schema: this.schema,
|
|
2330
|
-
});
|
|
2331
|
-
await relationsService.updateOne(args['collection'], args['field'], args['data']);
|
|
2332
|
-
return await relationsService.readOne(args['data'].collection, args['data'].field);
|
|
2333
|
-
},
|
|
2334
|
-
},
|
|
2335
|
-
delete_relations_item: {
|
|
2336
|
-
type: schemaComposer.createObjectTC({
|
|
2337
|
-
name: 'delete_relation',
|
|
2338
|
-
fields: {
|
|
2339
|
-
collection: graphql_1.GraphQLString,
|
|
2340
|
-
field: graphql_1.GraphQLString,
|
|
2341
|
-
},
|
|
2342
|
-
}),
|
|
2343
|
-
args: {
|
|
2344
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2345
|
-
field: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2346
|
-
},
|
|
2347
|
-
resolve: async (_, args) => {
|
|
2348
|
-
const relationsService = new relations_1.RelationsService({
|
|
2349
|
-
accountability: this.accountability,
|
|
2350
|
-
schema: this.schema,
|
|
2351
|
-
});
|
|
2352
|
-
await relationsService.deleteOne(args['collection'], args['field']);
|
|
2353
|
-
return { collection: args['collection'], field: args['field'] };
|
|
2354
|
-
},
|
|
2355
|
-
},
|
|
2356
|
-
});
|
|
2357
|
-
}
|
|
2358
|
-
if ('directus_users' in schema.read.collections) {
|
|
2359
|
-
schemaComposer.Query.addFields({
|
|
2360
|
-
users_me: {
|
|
2361
|
-
type: ReadCollectionTypes['directus_users'],
|
|
2362
|
-
resolve: async (_, args, __, info) => {
|
|
2363
|
-
if (!this.accountability?.user)
|
|
2364
|
-
return null;
|
|
2365
|
-
const service = new users_1.UsersService({ schema: this.schema, accountability: this.accountability });
|
|
2366
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2367
|
-
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2368
|
-
return await service.readOne(this.accountability.user, query);
|
|
2369
|
-
},
|
|
2370
|
-
},
|
|
2371
|
-
});
|
|
2372
|
-
}
|
|
2373
|
-
if ('directus_users' in schema.update.collections && this.accountability?.user) {
|
|
2374
|
-
schemaComposer.Mutation.addFields({
|
|
2375
|
-
update_users_me: {
|
|
2376
|
-
type: ReadCollectionTypes['directus_users'],
|
|
2377
|
-
args: {
|
|
2378
|
-
data: (0, graphql_compose_1.toInputObjectType)(UpdateCollectionTypes['directus_users']),
|
|
2379
|
-
},
|
|
2380
|
-
resolve: async (_, args, __, info) => {
|
|
2381
|
-
if (!this.accountability?.user)
|
|
2382
|
-
return null;
|
|
2383
|
-
const service = new users_1.UsersService({
|
|
2384
|
-
schema: this.schema,
|
|
2385
|
-
accountability: this.accountability,
|
|
2386
|
-
});
|
|
2387
|
-
await service.updateOne(this.accountability.user, args['data']);
|
|
2388
|
-
if ('directus_users' in ReadCollectionTypes) {
|
|
2389
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2390
|
-
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2391
|
-
return await service.readOne(this.accountability.user, query);
|
|
2392
|
-
}
|
|
2393
|
-
return true;
|
|
2394
|
-
},
|
|
2395
|
-
},
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
if ('directus_activity' in schema.create.collections) {
|
|
2399
|
-
schemaComposer.Mutation.addFields({
|
|
2400
|
-
create_comment: {
|
|
2401
|
-
type: ReadCollectionTypes['directus_activity'] ?? graphql_1.GraphQLBoolean,
|
|
2402
|
-
args: {
|
|
2403
|
-
collection: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2404
|
-
item: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2405
|
-
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2406
|
-
},
|
|
2407
|
-
resolve: async (_, args, __, info) => {
|
|
2408
|
-
const service = new activity_1.ActivityService({
|
|
2409
|
-
accountability: this.accountability,
|
|
2410
|
-
schema: this.schema,
|
|
2411
|
-
});
|
|
2412
|
-
const primaryKey = await service.createOne({
|
|
2413
|
-
...args,
|
|
2414
|
-
action: types_1.Action.COMMENT,
|
|
2415
|
-
user: this.accountability?.user,
|
|
2416
|
-
ip: this.accountability?.ip,
|
|
2417
|
-
user_agent: this.accountability?.userAgent,
|
|
2418
|
-
origin: this.accountability?.origin,
|
|
2419
|
-
});
|
|
2420
|
-
if ('directus_activity' in ReadCollectionTypes) {
|
|
2421
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2422
|
-
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2423
|
-
return await service.readOne(primaryKey, query);
|
|
2424
|
-
}
|
|
2425
|
-
return true;
|
|
2426
|
-
},
|
|
2427
|
-
},
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
if ('directus_activity' in schema.update.collections) {
|
|
2431
|
-
schemaComposer.Mutation.addFields({
|
|
2432
|
-
update_comment: {
|
|
2433
|
-
type: ReadCollectionTypes['directus_activity'] ?? graphql_1.GraphQLBoolean,
|
|
2434
|
-
args: {
|
|
2435
|
-
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2436
|
-
comment: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2437
|
-
},
|
|
2438
|
-
resolve: async (_, args, __, info) => {
|
|
2439
|
-
const service = new activity_1.ActivityService({
|
|
2440
|
-
accountability: this.accountability,
|
|
2441
|
-
schema: this.schema,
|
|
2442
|
-
});
|
|
2443
|
-
const primaryKey = await service.updateOne(args['id'], { comment: args['comment'] });
|
|
2444
|
-
if ('directus_activity' in ReadCollectionTypes) {
|
|
2445
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2446
|
-
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2447
|
-
return await service.readOne(primaryKey, query);
|
|
2448
|
-
}
|
|
2449
|
-
return true;
|
|
2450
|
-
},
|
|
2451
|
-
},
|
|
2452
|
-
});
|
|
2453
|
-
}
|
|
2454
|
-
if ('directus_activity' in schema.delete.collections) {
|
|
2455
|
-
schemaComposer.Mutation.addFields({
|
|
2456
|
-
delete_comment: {
|
|
2457
|
-
type: DeleteCollectionTypes['one'],
|
|
2458
|
-
args: {
|
|
2459
|
-
id: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
|
|
2460
|
-
},
|
|
2461
|
-
resolve: async (_, args) => {
|
|
2462
|
-
const service = new activity_1.ActivityService({
|
|
2463
|
-
accountability: this.accountability,
|
|
2464
|
-
schema: this.schema,
|
|
2465
|
-
});
|
|
2466
|
-
await service.deleteOne(args['id']);
|
|
2467
|
-
return { id: args['id'] };
|
|
2468
|
-
},
|
|
2469
|
-
},
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
if ('directus_files' in schema.create.collections) {
|
|
2473
|
-
schemaComposer.Mutation.addFields({
|
|
2474
|
-
import_file: {
|
|
2475
|
-
type: ReadCollectionTypes['directus_files'] ?? graphql_1.GraphQLBoolean,
|
|
2476
|
-
args: {
|
|
2477
|
-
url: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2478
|
-
data: (0, graphql_compose_1.toInputObjectType)(CreateCollectionTypes['directus_files']).setTypeName('create_directus_files_input'),
|
|
2479
|
-
},
|
|
2480
|
-
resolve: async (_, args, __, info) => {
|
|
2481
|
-
const service = new files_1.FilesService({
|
|
2482
|
-
accountability: this.accountability,
|
|
2483
|
-
schema: this.schema,
|
|
2484
|
-
});
|
|
2485
|
-
const primaryKey = await service.importOne(args['url'], args['data']);
|
|
2486
|
-
if ('directus_files' in ReadCollectionTypes) {
|
|
2487
|
-
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2488
|
-
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2489
|
-
return await service.readOne(primaryKey, query);
|
|
2490
|
-
}
|
|
2491
|
-
return true;
|
|
2492
|
-
},
|
|
2493
|
-
},
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
if ('directus_users' in schema.create.collections) {
|
|
2497
|
-
schemaComposer.Mutation.addFields({
|
|
2498
|
-
users_invite: {
|
|
2499
|
-
type: graphql_1.GraphQLBoolean,
|
|
2500
|
-
args: {
|
|
2501
|
-
email: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2502
|
-
role: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
|
|
2503
|
-
invite_url: graphql_1.GraphQLString,
|
|
2504
|
-
},
|
|
2505
|
-
resolve: async (_, args) => {
|
|
2506
|
-
const service = new users_1.UsersService({
|
|
2507
|
-
accountability: this.accountability,
|
|
2508
|
-
schema: this.schema,
|
|
2509
|
-
});
|
|
2510
|
-
await service.inviteUser(args['email'], args['role'], args['invite_url'] || null);
|
|
2511
|
-
return true;
|
|
2512
|
-
},
|
|
2513
|
-
},
|
|
2514
|
-
});
|
|
2515
|
-
}
|
|
2516
|
-
return schemaComposer;
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
exports.GraphQLService = GraphQLService;
|