directus 9.23.1 → 9.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +14 -10
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +39 -28
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +13 -10
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +20 -13
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +21 -14
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +10 -7
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +4 -4
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +57 -14
- package/dist/cli/commands/bootstrap/index.js +2 -2
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +14 -15
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +2 -1
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/drivers.d.ts +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -3
- package/dist/controllers/activity.js +1 -2
- package/dist/controllers/assets.js +14 -9
- package/dist/controllers/auth.js +29 -15
- package/dist/controllers/dashboards.js +5 -2
- package/dist/controllers/fields.js +4 -4
- package/dist/controllers/files.js +10 -5
- package/dist/controllers/flows.js +5 -2
- package/dist/controllers/folders.js +5 -2
- package/dist/controllers/graphql.js +2 -4
- package/dist/controllers/items.js +5 -2
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +5 -2
- package/dist/controllers/operations.js +5 -2
- package/dist/controllers/panels.js +5 -2
- package/dist/controllers/permissions.js +5 -2
- package/dist/controllers/presets.js +5 -2
- package/dist/controllers/roles.js +5 -2
- package/dist/controllers/shares.js +8 -5
- package/dist/controllers/users.js +16 -20
- package/dist/controllers/utils.js +6 -11
- package/dist/controllers/webhooks.js +5 -2
- package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mssql.js +10 -11
- package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mysql.js +2 -3
- package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/oracle.js +10 -11
- package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/postgres.js +10 -11
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
- package/dist/database/helpers/fn/types.d.ts +5 -5
- package/dist/database/helpers/fn/types.js +5 -4
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/geometry/types.d.ts +2 -2
- package/dist/database/helpers/geometry/types.js +1 -2
- package/dist/database/helpers/index.d.ts +5 -5
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.js +1 -2
- package/dist/database/helpers/schema/dialects/oracle.d.ts +2 -2
- package/dist/database/helpers/schema/dialects/oracle.js +4 -6
- package/dist/database/helpers/schema/types.d.ts +4 -4
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.js +8 -8
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
- package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
- package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.js +7 -9
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
- package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
- package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
- package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
- package/dist/database/migrations/run.d.ts +1 -1
- package/dist/database/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +17 -26
- package/dist/database/seeds/run.d.ts +1 -1
- package/dist/database/seeds/run.js +1 -2
- package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.d.ts +1 -1
- package/dist/database/system-data/fields/collections.yaml +2 -0
- package/dist/database/system-data/fields/index.d.ts +1 -1
- package/dist/database/system-data/fields/index.js +1 -2
- package/dist/database/system-data/fields/settings.yaml +4 -0
- package/dist/database/system-data/relations/index.d.ts +1 -1
- package/dist/emitter.d.ts +1 -1
- package/dist/emitter.js +3 -0
- package/dist/env.js +10 -2
- package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mssql.js +5 -6
- package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mysql.js +19 -25
- package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
- package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
- package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
- package/dist/exceptions/database/translate.d.ts +1 -1
- package/dist/exceptions/database/value-out-of-range.js +1 -1
- package/dist/exceptions/range-not-satisfiable.js +2 -3
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +33 -23
- package/dist/flows.js +42 -25
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +19 -3
- package/dist/messenger.js +8 -6
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +12 -5
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +5 -5
- package/dist/middleware/check-ip.d.ts +1 -1
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/collection-exists.d.ts +1 -1
- package/dist/middleware/collection-exists.js +2 -2
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +9 -10
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +3 -3
- package/dist/middleware/rate-limiter-global.d.ts +5 -0
- package/dist/middleware/rate-limiter-global.js +48 -0
- package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
- package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +3 -3
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +6 -7
- package/dist/middleware/sanitize-query.d.ts +1 -1
- package/dist/middleware/schema.d.ts +1 -1
- package/dist/middleware/use-collection.d.ts +1 -1
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/exec/index.js +14 -3
- package/dist/operations/item-create/index.js +1 -2
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/item-update/index.js +1 -2
- package/dist/operations/notification/index.js +1 -2
- package/dist/operations/request/index.js +19 -19
- package/dist/operations/trigger/index.js +2 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +8 -8
- package/dist/server.js +8 -9
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +7 -6
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +33 -35
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +13 -10
- package/dist/services/authorization.d.ts +3 -3
- package/dist/services/authorization.js +27 -31
- package/dist/services/collections.d.ts +5 -5
- package/dist/services/collections.js +52 -48
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +48 -48
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +27 -21
- package/dist/services/flows.d.ts +2 -2
- package/dist/services/folders.d.ts +1 -1
- package/dist/services/graphql/index.d.ts +4 -4
- package/dist/services/graphql/index.js +172 -167
- package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
- package/dist/services/graphql/utils/process-error.d.ts +2 -2
- package/dist/services/graphql/utils/process-error.js +11 -4
- package/dist/services/import-export.d.ts +3 -3
- package/dist/services/import-export.js +25 -22
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +42 -36
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +9 -5
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +10 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +7 -6
- package/dist/services/operations.d.ts +2 -2
- package/dist/services/panels.d.ts +1 -1
- package/dist/services/payload.d.ts +3 -3
- package/dist/services/payload.js +124 -122
- package/dist/services/permissions.d.ts +3 -3
- package/dist/services/permissions.js +11 -11
- package/dist/services/presets.d.ts +1 -1
- package/dist/services/relations.d.ts +6 -6
- package/dist/services/relations.js +45 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +2 -2
- package/dist/services/schema.d.ts +3 -3
- package/dist/services/schema.js +9 -11
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +69 -13
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +1 -1
- package/dist/services/shares.js +5 -6
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +132 -116
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +3 -3
- package/dist/services/users.js +17 -17
- package/dist/services/utils.d.ts +3 -3
- package/dist/services/utils.js +10 -8
- package/dist/services/webhooks.d.ts +2 -2
- package/dist/services/webhooks.js +2 -1
- package/dist/types/assets.d.ts +1 -1
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collection.d.ts +2 -2
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/items.d.ts +3 -3
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/utils/apply-diff.d.ts +3 -3
- package/dist/utils/apply-diff.js +25 -28
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +8 -11
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +5 -6
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/filter-items.d.ts +1 -1
- package/dist/utils/get-accountability-for-role.d.ts +2 -2
- package/dist/utils/get-accountability-for-role.js +1 -1
- package/dist/utils/get-ast-from-query.d.ts +3 -3
- package/dist/utils/get-ast-from-query.js +22 -28
- package/dist/utils/get-cache-headers.d.ts +1 -1
- package/dist/utils/get-cache-headers.js +3 -4
- package/dist/utils/get-cache-key.d.ts +1 -1
- package/dist/utils/get-cache-key.js +2 -3
- package/dist/utils/get-collection-from-alias.d.ts +1 -1
- package/dist/utils/get-column-path.d.ts +2 -2
- package/dist/utils/get-column-path.js +3 -4
- package/dist/utils/get-column.d.ts +4 -4
- package/dist/utils/get-column.js +4 -5
- package/dist/utils/get-default-value.d.ts +2 -2
- package/dist/utils/get-default-value.js +1 -2
- package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
- package/dist/utils/get-graphql-query-and-variables.js +1 -2
- package/dist/utils/get-graphql-type.d.ts +2 -2
- package/dist/utils/get-graphql-type.js +1 -1
- package/dist/utils/get-ip-from-req.d.ts +1 -1
- package/dist/utils/get-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.js +1 -2
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +1 -1
- package/dist/utils/get-relation-info.d.ts +1 -1
- package/dist/utils/get-relation-info.js +3 -5
- package/dist/utils/get-relation-type.d.ts +1 -1
- package/dist/utils/get-relation-type.js +3 -4
- package/dist/utils/get-schema.d.ts +2 -2
- package/dist/utils/get-schema.js +19 -21
- package/dist/utils/get-snapshot-diff.js +2 -3
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +6 -8
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.js +3 -4
- package/dist/utils/merge-permissions.d.ts +3 -3
- package/dist/utils/redact-header-cookies.d.ts +1 -0
- package/dist/utils/redact-header-cookies.js +11 -0
- package/dist/utils/redact-header-cookies.test.d.ts +1 -0
- package/dist/utils/reduce-schema.d.ts +1 -1
- package/dist/utils/reduce-schema.js +12 -12
- package/dist/utils/sanitize-query.d.ts +1 -1
- package/dist/utils/sanitize-query.js +1 -1
- package/dist/utils/sanitize-schema.d.ts +2 -2
- package/dist/utils/should-skip-cache.d.ts +7 -0
- package/dist/utils/should-skip-cache.js +21 -0
- package/dist/utils/should-skip-cache.test.d.ts +1 -0
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +7 -2
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.js +7 -8
- package/dist/utils/validate-keys.d.ts +2 -2
- package/dist/utils/validate-keys.js +1 -1
- package/dist/utils/validate-query.d.ts +1 -1
- package/dist/utils/validate-query.js +2 -2
- package/dist/webhooks.js +1 -1
- package/package.json +36 -37
- package/dist/utils/with-timeout.d.ts +0 -1
- package/dist/utils/with-timeout.js +0 -16
|
@@ -27,9 +27,8 @@ function getSnapshotDiff(current, after) {
|
|
|
27
27
|
].filter((obj) => Array.isArray(obj.diff)), 'collection'),
|
|
28
28
|
fields: (0, lodash_1.orderBy)([
|
|
29
29
|
...current.fields.map((currentField) => {
|
|
30
|
-
var _a, _b;
|
|
31
30
|
const afterField = after.fields.find((afterField) => afterField.collection === currentField.collection && afterField.field === currentField.field);
|
|
32
|
-
const isAutoIncrementPrimaryKey = !!
|
|
31
|
+
const isAutoIncrementPrimaryKey = !!currentField.schema?.is_primary_key && !!currentField.schema?.has_auto_increment;
|
|
33
32
|
return {
|
|
34
33
|
collection: currentField.collection,
|
|
35
34
|
field: currentField.field,
|
|
@@ -74,7 +73,7 @@ function getSnapshotDiff(current, after) {
|
|
|
74
73
|
* When you delete a collection, we don't have to individually drop all the fields/relations as well
|
|
75
74
|
*/
|
|
76
75
|
const deletedCollections = diffedSnapshot.collections
|
|
77
|
-
.filter((collection) =>
|
|
76
|
+
.filter((collection) => collection.diff?.[0].kind === types_1.DiffKind.DELETE)
|
|
78
77
|
.map(({ collection }) => collection);
|
|
79
78
|
diffedSnapshot.fields = diffedSnapshot.fields.filter((field) => deletedCollections.includes(field.collection) === false);
|
|
80
79
|
diffedSnapshot.relations = diffedSnapshot.relations.filter((relation) => deletedCollections.includes(relation.collection) === false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Knex } from 'knex';
|
|
3
|
-
import {
|
|
1
|
+
import type { SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { Snapshot } from '../types';
|
|
4
4
|
export declare function getSnapshot(options?: {
|
|
5
5
|
database?: Knex;
|
|
6
6
|
schema?: SchemaOverview;
|
|
@@ -24,17 +24,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getSnapshot = void 0;
|
|
27
|
+
const lodash_1 = require("lodash");
|
|
28
|
+
const package_json_1 = require("../../package.json");
|
|
27
29
|
const database_1 = __importStar(require("../database"));
|
|
28
|
-
const get_schema_1 = require("./get-schema");
|
|
29
30
|
const services_1 = require("../services");
|
|
30
|
-
const
|
|
31
|
-
const lodash_1 = require("lodash");
|
|
31
|
+
const get_schema_1 = require("./get-schema");
|
|
32
32
|
const sanitize_schema_1 = require("./sanitize-schema");
|
|
33
33
|
async function getSnapshot(options) {
|
|
34
|
-
|
|
35
|
-
const database = (_a = options === null || options === void 0 ? void 0 : options.database) !== null && _a !== void 0 ? _a : (0, database_1.default)();
|
|
34
|
+
const database = options?.database ?? (0, database_1.default)();
|
|
36
35
|
const vendor = (0, database_1.getDatabaseClient)(database);
|
|
37
|
-
const schema =
|
|
36
|
+
const schema = options?.schema ?? (await (0, get_schema_1.getSchema)({ database, bypassCache: true }));
|
|
38
37
|
const collectionsService = new services_1.CollectionsService({ knex: database, schema });
|
|
39
38
|
const fieldsService = new services_1.FieldsService({ knex: database, schema });
|
|
40
39
|
const relationsService = new services_1.RelationsService({ knex: database, schema });
|
|
@@ -60,8 +59,7 @@ async function getSnapshot(options) {
|
|
|
60
59
|
}
|
|
61
60
|
exports.getSnapshot = getSnapshot;
|
|
62
61
|
function excludeSystem(item) {
|
|
63
|
-
|
|
64
|
-
if (((_a = item === null || item === void 0 ? void 0 : item.meta) === null || _a === void 0 ? void 0 : _a.system) === true)
|
|
62
|
+
if (item?.meta?.system === true)
|
|
65
63
|
return false;
|
|
66
64
|
return true;
|
|
67
65
|
}
|
|
@@ -11,7 +11,7 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
|
11
11
|
function isDirectusJWT(string) {
|
|
12
12
|
try {
|
|
13
13
|
const payload = jsonwebtoken_1.default.decode(string, { json: true });
|
|
14
|
-
if (
|
|
14
|
+
if (payload?.iss !== 'directus')
|
|
15
15
|
return false;
|
|
16
16
|
return true;
|
|
17
17
|
}
|
package/dist/utils/job-queue.js
CHANGED
package/dist/utils/jwt.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DirectusTokenPayload } from '../types';
|
|
1
|
+
import type { DirectusTokenPayload } from '../types';
|
|
2
2
|
export declare function verifyAccessJWT(token: string, secret: string): DirectusTokenPayload;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Permission, Accountability, Filter, SchemaOverview } from '@directus/shared/types';
|
|
1
|
+
import type { Permission, Accountability, Filter, SchemaOverview } from '@directus/shared/types';
|
|
2
2
|
export declare function mergePermissionsForShare(currentPermissions: Permission[], accountability: Accountability, schema: SchemaOverview): Permission[];
|
|
3
3
|
export declare function traverse(schema: SchemaOverview, rootItemPrimaryKeyField: string, rootItemPrimaryKey: string, currentCollection: string, parentCollections?: string[], path?: string[]): Partial<Permission>[];
|
|
4
4
|
export declare function getFilterForPath(type: 'o2m' | 'm2o' | 'a2o', path: string[], rootPrimaryKeyField: string, rootPrimaryKey: string): Filter;
|
|
@@ -53,7 +53,6 @@ function mergePermissionsForShare(currentPermissions, accountability, schema) {
|
|
|
53
53
|
}
|
|
54
54
|
exports.mergePermissionsForShare = mergePermissionsForShare;
|
|
55
55
|
function traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, currentCollection, parentCollections = [], path = []) {
|
|
56
|
-
var _a, _b, _c;
|
|
57
56
|
const permissions = [];
|
|
58
57
|
// If there's already a permissions rule for the collection we're currently checking, we'll shortcircuit.
|
|
59
58
|
// This prevents infinite loop in recursive relationships, like articles->related_articles->articles, or
|
|
@@ -82,7 +81,7 @@ function traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, currentCo
|
|
|
82
81
|
});
|
|
83
82
|
permissions.push(...traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, relation.collection, [...parentCollections, currentCollection], [...path, relation.field]));
|
|
84
83
|
}
|
|
85
|
-
if (type === 'a2o' &&
|
|
84
|
+
if (type === 'a2o' && relation.meta?.one_allowed_collections) {
|
|
86
85
|
for (const collection of relation.meta.one_allowed_collections) {
|
|
87
86
|
permissions.push({
|
|
88
87
|
collection,
|
|
@@ -95,8 +94,8 @@ function traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, currentCo
|
|
|
95
94
|
collection: relation.related_collection,
|
|
96
95
|
permissions: getFilterForPath(type, [...path, `$FOLLOW(${relation.collection},${relation.field})`], rootItemPrimaryKeyField, rootItemPrimaryKey),
|
|
97
96
|
});
|
|
98
|
-
if (
|
|
99
|
-
permissions.push(...traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, relation.related_collection, [...parentCollections, currentCollection], [...path,
|
|
97
|
+
if (relation.meta?.one_field) {
|
|
98
|
+
permissions.push(...traverse(schema, rootItemPrimaryKeyField, rootItemPrimaryKey, relation.related_collection, [...parentCollections, currentCollection], [...path, relation.meta?.one_field]));
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
-
import { Permission } from '@directus/shared/types';
|
|
2
|
+
import type { Permission } from '@directus/shared/types';
|
|
3
3
|
export declare function mergePermissions(strategy: 'and' | 'or', ...permissions: Permission[][]): Permission[];
|
|
4
4
|
export declare function mergePermission(strategy: 'and' | 'or', currentPerm: Permission, newPerm: Permission): import("lodash").Omit<{
|
|
5
5
|
permissions: import("@directus/shared/types").Filter | null;
|
|
6
6
|
validation: import("@directus/shared/types").Filter | null;
|
|
7
7
|
fields: string[] | null;
|
|
8
8
|
presets: Record<string, any> | null;
|
|
9
|
-
id?: number
|
|
9
|
+
id?: number;
|
|
10
10
|
role: string | null;
|
|
11
11
|
collection: string;
|
|
12
12
|
action: import("@directus/shared/types").PermissionsAction;
|
|
13
|
-
system?: true
|
|
13
|
+
system?: true;
|
|
14
14
|
}, "id" | "system">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redactHeaderCookie(cookieHeader: string, cookieNames: string[]): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactHeaderCookie = void 0;
|
|
4
|
+
function redactHeaderCookie(cookieHeader, cookieNames) {
|
|
5
|
+
for (const cookieName of cookieNames) {
|
|
6
|
+
const re = new RegExp(`(${cookieName}=)([^;]+)`);
|
|
7
|
+
cookieHeader = cookieHeader.replace(re, `$1--redacted--`);
|
|
8
|
+
}
|
|
9
|
+
return cookieHeader;
|
|
10
|
+
}
|
|
11
|
+
exports.redactHeaderCookie = redactHeaderCookie;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Permission, PermissionsAction, SchemaOverview } from '@directus/shared/types';
|
|
1
|
+
import type { Permission, PermissionsAction, SchemaOverview } from '@directus/shared/types';
|
|
2
2
|
/**
|
|
3
3
|
* Reduces the schema based on the included permissions. The resulting object is the schema structure, but with only
|
|
4
4
|
* the allowed collections/fields/relations included based on the permissions.
|
|
@@ -10,12 +10,13 @@ const lodash_1 = require("lodash");
|
|
|
10
10
|
* @returns Reduced schema
|
|
11
11
|
*/
|
|
12
12
|
function reduceSchema(schema, permissions, actions = ['create', 'read', 'update', 'delete']) {
|
|
13
|
-
var _a, _b, _c;
|
|
14
13
|
const reduced = {
|
|
15
14
|
collections: {},
|
|
16
15
|
relations: [],
|
|
17
16
|
};
|
|
18
|
-
const allowedFieldsInCollection =
|
|
17
|
+
const allowedFieldsInCollection = permissions
|
|
18
|
+
?.filter((permission) => actions.includes(permission.action))
|
|
19
|
+
.reduce((acc, permission) => {
|
|
19
20
|
if (!acc[permission.collection]) {
|
|
20
21
|
acc[permission.collection] = [];
|
|
21
22
|
}
|
|
@@ -23,20 +24,20 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
23
24
|
acc[permission.collection] = (0, lodash_1.uniq)([...acc[permission.collection], ...permission.fields]);
|
|
24
25
|
}
|
|
25
26
|
return acc;
|
|
26
|
-
}, {})
|
|
27
|
+
}, {}) ?? {};
|
|
27
28
|
for (const [collectionName, collection] of Object.entries(schema.collections)) {
|
|
28
|
-
if (!
|
|
29
|
+
if (!permissions?.some((permission) => permission.collection === collectionName && actions.includes(permission.action))) {
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
31
32
|
const fields = {};
|
|
32
33
|
for (const [fieldName, field] of Object.entries(schema.collections[collectionName].fields)) {
|
|
33
|
-
if (!
|
|
34
|
-
!
|
|
34
|
+
if (!allowedFieldsInCollection[collectionName]?.includes('*') &&
|
|
35
|
+
!allowedFieldsInCollection[collectionName]?.includes(fieldName)) {
|
|
35
36
|
continue;
|
|
36
37
|
}
|
|
37
|
-
const o2mRelation = schema.relations.find((relation) =>
|
|
38
|
+
const o2mRelation = schema.relations.find((relation) => relation.related_collection === collectionName && relation.meta?.one_field === fieldName);
|
|
38
39
|
if (o2mRelation &&
|
|
39
|
-
!
|
|
40
|
+
!permissions?.some((permission) => permission.collection === o2mRelation.collection && actions.includes(permission.action))) {
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
43
|
fields[fieldName] = field;
|
|
@@ -47,7 +48,6 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
reduced.relations = schema.relations.filter((relation) => {
|
|
50
|
-
var _a, _b, _c;
|
|
51
51
|
let collectionsAllowed = true;
|
|
52
52
|
let fieldsAllowed = true;
|
|
53
53
|
if (Object.keys(allowedFieldsInCollection).includes(relation.collection) === false) {
|
|
@@ -59,7 +59,7 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
59
59
|
allowedFieldsInCollection[relation.related_collection].length === 0)) {
|
|
60
60
|
collectionsAllowed = false;
|
|
61
61
|
}
|
|
62
|
-
if (
|
|
62
|
+
if (relation.meta?.one_allowed_collections &&
|
|
63
63
|
relation.meta.one_allowed_collections.every((collection) => Object.keys(allowedFieldsInCollection).includes(collection)) === false) {
|
|
64
64
|
collectionsAllowed = false;
|
|
65
65
|
}
|
|
@@ -69,10 +69,10 @@ function reduceSchema(schema, permissions, actions = ['create', 'read', 'update'
|
|
|
69
69
|
fieldsAllowed = false;
|
|
70
70
|
}
|
|
71
71
|
if (relation.related_collection &&
|
|
72
|
-
|
|
72
|
+
relation.meta?.one_field &&
|
|
73
73
|
(!allowedFieldsInCollection[relation.related_collection] ||
|
|
74
74
|
(allowedFieldsInCollection[relation.related_collection].includes('*') === false &&
|
|
75
|
-
allowedFieldsInCollection[relation.related_collection].includes(
|
|
75
|
+
allowedFieldsInCollection[relation.related_collection].includes(relation.meta?.one_field) === false))) {
|
|
76
76
|
fieldsAllowed = false;
|
|
77
77
|
}
|
|
78
78
|
return collectionsAllowed && fieldsAllowed;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Accountability, Query } from '@directus/shared/types';
|
|
1
|
+
import type { Accountability, Query } from '@directus/shared/types';
|
|
2
2
|
export declare function sanitizeQuery(rawQuery: Record<string, any>, accountability?: Accountability | null): Query;
|
|
@@ -59,7 +59,7 @@ function sanitizeQuery(rawQuery, accountability) {
|
|
|
59
59
|
exports.sanitizeQuery = sanitizeQuery;
|
|
60
60
|
function sanitizeFields(rawFields) {
|
|
61
61
|
if (!rawFields)
|
|
62
|
-
return;
|
|
62
|
+
return null;
|
|
63
63
|
let fields = [];
|
|
64
64
|
if (typeof rawFields === 'string')
|
|
65
65
|
fields = rawFields.split(',');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Field, Relation } from '@directus/shared/types';
|
|
2
|
-
import { Collection } from '../types';
|
|
1
|
+
import type { Field, Relation } from '@directus/shared/types';
|
|
2
|
+
import type { Collection } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Pick certain database vendor specific collection properties that should be compared when performing diff
|
|
5
5
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldSkipCache = void 0;
|
|
4
|
+
const env_1 = require("../env");
|
|
5
|
+
const url_1 = require("./url");
|
|
6
|
+
/**
|
|
7
|
+
* Whether to skip caching for the current request
|
|
8
|
+
*
|
|
9
|
+
* @param req Express request object
|
|
10
|
+
*/
|
|
11
|
+
function shouldSkipCache(req) {
|
|
12
|
+
const env = (0, env_1.getEnv)();
|
|
13
|
+
// Always skip cache for requests coming from the data studio based on Referer header
|
|
14
|
+
const adminUrl = new url_1.Url(env.PUBLIC_URL).addPath('admin').toString();
|
|
15
|
+
if (req.get('Referer')?.startsWith(adminUrl))
|
|
16
|
+
return true;
|
|
17
|
+
if (env.CACHE_SKIP_ALLOWED && req.get('cache-control')?.includes('no-store'))
|
|
18
|
+
return true;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
exports.shouldSkipCache = shouldSkipCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { File, Transformation, TransformationParams, TransformationPreset } from '../types';
|
|
1
|
+
import type { File, Transformation, TransformationParams, TransformationPreset } from '../types';
|
|
2
2
|
export declare function resolvePreset(input: TransformationParams | TransformationPreset, file: File): Transformation[];
|
|
3
3
|
/**
|
|
4
4
|
* Try to extract a file format from an array of `Transformation`'s.
|
|
@@ -4,9 +4,8 @@ exports.maybeExtractFormat = exports.resolvePreset = void 0;
|
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
// Extract transforms from a preset
|
|
6
6
|
function resolvePreset(input, file) {
|
|
7
|
-
var _a;
|
|
8
7
|
// Do the format conversion last
|
|
9
|
-
return [extractResize(input), ...(
|
|
8
|
+
return [extractResize(input), ...(input.transforms ?? []), extractToFormat(input, file)].filter((transform) => transform !== undefined);
|
|
10
9
|
}
|
|
11
10
|
exports.resolvePreset = resolvePreset;
|
|
12
11
|
function extractOptions(keys, numberKeys = [], booleanKeys = []) {
|
|
@@ -49,9 +48,8 @@ function extractResize(input) {
|
|
|
49
48
|
* Try to extract a file format from an array of `Transformation`'s.
|
|
50
49
|
*/
|
|
51
50
|
function maybeExtractFormat(transforms) {
|
|
52
|
-
var _a;
|
|
53
51
|
const toFormats = transforms.filter((t) => t[0] === 'toFormat');
|
|
54
52
|
const lastToFormat = toFormats[toFormats.length - 1];
|
|
55
|
-
return lastToFormat ?
|
|
53
|
+
return lastToFormat ? lastToFormat[1]?.toString() : undefined;
|
|
56
54
|
}
|
|
57
55
|
exports.maybeExtractFormat = maybeExtractFormat;
|
package/dist/utils/url.js
CHANGED
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Url = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
class Url {
|
|
6
|
+
protocol;
|
|
7
|
+
host;
|
|
8
|
+
port;
|
|
9
|
+
path;
|
|
10
|
+
query;
|
|
11
|
+
hash;
|
|
6
12
|
constructor(url) {
|
|
7
13
|
const parsedUrl = new url_1.URL(url, 'http://localhost');
|
|
8
14
|
const isProtocolRelative = /^\/\//.test(url);
|
|
@@ -44,9 +50,8 @@ class Url {
|
|
|
44
50
|
return this;
|
|
45
51
|
}
|
|
46
52
|
toString({ rootRelative } = { rootRelative: false }) {
|
|
47
|
-
var _a;
|
|
48
53
|
const protocol = this.protocol !== null ? `${this.protocol}:` : '';
|
|
49
|
-
const host =
|
|
54
|
+
const host = this.host ?? '';
|
|
50
55
|
const port = this.port !== null ? `:${this.port}` : '';
|
|
51
56
|
const origin = `${this.host !== null ? `${protocol}//` : ''}${host}${port}`;
|
|
52
57
|
const path = this.path.length ? `/${this.path.join('/')}` : '';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { User } from '@directus/shared/types';
|
|
1
|
+
import type { User } from '@directus/shared/types';
|
|
2
2
|
export declare function userName(user: Partial<User>): string;
|
|
@@ -37,7 +37,7 @@ const applyJoiSchema = joi_1.default.object({
|
|
|
37
37
|
.items(joi_1.default.object({
|
|
38
38
|
collection: joi_1.default.string().required(),
|
|
39
39
|
field: joi_1.default.string().required(),
|
|
40
|
-
related_collection: joi_1.default.string(),
|
|
40
|
+
related_collection: joi_1.default.string().allow(null),
|
|
41
41
|
diff: joi_1.default.array().items(deepDiffSchema).required(),
|
|
42
42
|
}))
|
|
43
43
|
.required(),
|
|
@@ -49,7 +49,6 @@ const applyJoiSchema = joi_1.default.object({
|
|
|
49
49
|
* @returns True if the diff can be applied (valid & not empty).
|
|
50
50
|
*/
|
|
51
51
|
function validateApplyDiff(applyDiff, currentSnapshotWithHash) {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f;
|
|
53
52
|
const { error } = applyJoiSchema.validate(applyDiff);
|
|
54
53
|
if (error)
|
|
55
54
|
throw new index_1.InvalidPayloadException(error.message);
|
|
@@ -64,13 +63,13 @@ function validateApplyDiff(applyDiff, currentSnapshotWithHash) {
|
|
|
64
63
|
return true;
|
|
65
64
|
for (const diffCollection of applyDiff.diff.collections) {
|
|
66
65
|
const collection = diffCollection.collection;
|
|
67
|
-
if (
|
|
66
|
+
if (diffCollection.diff[0]?.kind === snapshot_1.DiffKind.NEW) {
|
|
68
67
|
const existingCollection = currentSnapshotWithHash.collections.find((c) => c.collection === diffCollection.collection);
|
|
69
68
|
if (existingCollection) {
|
|
70
69
|
throw new index_1.InvalidPayloadException(`Provided diff is trying to create collection "${collection}" but it already exists. Please generate a new diff and try again.`);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
|
-
else if (
|
|
72
|
+
else if (diffCollection.diff[0]?.kind === snapshot_1.DiffKind.DELETE) {
|
|
74
73
|
const existingCollection = currentSnapshotWithHash.collections.find((c) => c.collection === diffCollection.collection);
|
|
75
74
|
if (!existingCollection) {
|
|
76
75
|
throw new index_1.InvalidPayloadException(`Provided diff is trying to delete collection "${collection}" but it does not exist. Please generate a new diff and try again.`);
|
|
@@ -79,13 +78,13 @@ function validateApplyDiff(applyDiff, currentSnapshotWithHash) {
|
|
|
79
78
|
}
|
|
80
79
|
for (const diffField of applyDiff.diff.fields) {
|
|
81
80
|
const field = `${diffField.collection}.${diffField.field}`;
|
|
82
|
-
if (
|
|
81
|
+
if (diffField.diff[0]?.kind === snapshot_1.DiffKind.NEW) {
|
|
83
82
|
const existingField = currentSnapshotWithHash.fields.find((f) => f.collection === diffField.collection && f.field === diffField.field);
|
|
84
83
|
if (existingField) {
|
|
85
84
|
throw new index_1.InvalidPayloadException(`Provided diff is trying to create field "${field}" but it already exists. Please generate a new diff and try again.`);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
|
-
else if (
|
|
87
|
+
else if (diffField.diff[0]?.kind === snapshot_1.DiffKind.DELETE) {
|
|
89
88
|
const existingField = currentSnapshotWithHash.fields.find((f) => f.collection === diffField.collection && f.field === diffField.field);
|
|
90
89
|
if (!existingField) {
|
|
91
90
|
throw new index_1.InvalidPayloadException(`Provided diff is trying to delete field "${field}" but it does not exist. Please generate a new diff and try again.`);
|
|
@@ -96,13 +95,13 @@ function validateApplyDiff(applyDiff, currentSnapshotWithHash) {
|
|
|
96
95
|
let relation = `${diffRelation.collection}.${diffRelation.field}`;
|
|
97
96
|
if (diffRelation.related_collection)
|
|
98
97
|
relation += `-> ${diffRelation.related_collection}`;
|
|
99
|
-
if (
|
|
98
|
+
if (diffRelation.diff[0]?.kind === snapshot_1.DiffKind.NEW) {
|
|
100
99
|
const existingRelation = currentSnapshotWithHash.relations.find((r) => r.collection === diffRelation.collection && r.field === diffRelation.field);
|
|
101
100
|
if (existingRelation) {
|
|
102
101
|
throw new index_1.InvalidPayloadException(`Provided diff is trying to create relation "${relation}" but it already exists. Please generate a new diff and try again.`);
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
|
-
else if (
|
|
104
|
+
else if (diffRelation.diff[0]?.kind === snapshot_1.DiffKind.DELETE) {
|
|
106
105
|
const existingRelation = currentSnapshotWithHash.relations.find((r) => r.collection === diffRelation.collection && r.field === diffRelation.field);
|
|
107
106
|
if (!existingRelation) {
|
|
108
107
|
throw new index_1.InvalidPayloadException(`Provided diff is trying to delete relation "${relation}" but it does not exist. Please generate a new diff and try again.`);
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateKeys = void 0;
|
|
7
|
-
const exceptions_1 = require("../exceptions");
|
|
8
7
|
const uuid_validate_1 = __importDefault(require("uuid-validate"));
|
|
8
|
+
const exceptions_1 = require("../exceptions");
|
|
9
9
|
/**
|
|
10
10
|
* Validate keys based on its type
|
|
11
11
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Query } from '@directus/shared/types';
|
|
1
|
+
import type { Query } from '@directus/shared/types';
|
|
2
2
|
export declare function validateQuery(query: Query): Query;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.validateQuery = void 0;
|
|
7
7
|
const joi_1 = __importDefault(require("joi"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
|
-
const exceptions_1 = require("../exceptions");
|
|
10
9
|
const wellknown_1 = require("wellknown");
|
|
11
|
-
const calculate_field_depth_1 = require("./calculate-field-depth");
|
|
12
10
|
const env_1 = __importDefault(require("../env"));
|
|
11
|
+
const exceptions_1 = require("../exceptions");
|
|
12
|
+
const calculate_field_depth_1 = require("./calculate-field-depth");
|
|
13
13
|
const querySchema = joi_1.default.object({
|
|
14
14
|
fields: joi_1.default.array().items(joi_1.default.string()),
|
|
15
15
|
group: joi_1.default.array().items(joi_1.default.string()),
|
package/dist/webhooks.js
CHANGED
|
@@ -82,7 +82,7 @@ function createHandler(webhook, event) {
|
|
|
82
82
|
}
|
|
83
83
|
function mergeHeaders(headerArray) {
|
|
84
84
|
const headers = {};
|
|
85
|
-
for (const { header, value } of headerArray
|
|
85
|
+
for (const { header, value } of headerArray ?? []) {
|
|
86
86
|
headers[header] = value;
|
|
87
87
|
}
|
|
88
88
|
return headers;
|