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
package/dist/cache.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import Keyv from 'keyv';
|
|
2
|
+
import type { SchemaOverview } from '@directus/shared/types';
|
|
2
3
|
export declare function getCache(): {
|
|
3
4
|
cache: Keyv | null;
|
|
4
5
|
systemCache: Keyv;
|
|
6
|
+
sharedSchemaCache: Keyv;
|
|
7
|
+
localSchemaCache: Keyv;
|
|
5
8
|
lockCache: Keyv;
|
|
6
9
|
};
|
|
7
10
|
export declare function flushCaches(forced?: boolean): Promise<void>;
|
|
8
|
-
export declare function clearSystemCache(
|
|
11
|
+
export declare function clearSystemCache(opts?: {
|
|
12
|
+
forced?: boolean | undefined;
|
|
13
|
+
autoPurgeCache?: false | undefined;
|
|
14
|
+
}): Promise<void>;
|
|
9
15
|
export declare function setSystemCache(key: string, value: any, ttl?: number): Promise<void>;
|
|
10
16
|
export declare function getSystemCache(key: string): Promise<Record<string, any>>;
|
|
17
|
+
export declare function setSchemaCache(schema: SchemaOverview): Promise<void>;
|
|
18
|
+
export declare function getSchemaCache(): Promise<SchemaOverview | undefined>;
|
|
11
19
|
export declare function setCacheValue(cache: Keyv, key: string, value: Record<string, any> | Record<string, any>[], ttl?: number): Promise<void>;
|
|
12
20
|
export declare function getCacheValue(cache: Keyv, key: string): Promise<any>;
|
package/dist/cache.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getCacheValue = exports.setCacheValue = exports.getSystemCache = exports.setSystemCache = exports.clearSystemCache = exports.flushCaches = exports.getCache = void 0;
|
|
6
|
+
exports.getCacheValue = exports.setCacheValue = exports.getSchemaCache = exports.setSchemaCache = exports.getSystemCache = exports.setSystemCache = exports.clearSystemCache = exports.flushCaches = exports.getCache = void 0;
|
|
7
7
|
const keyv_1 = __importDefault(require("keyv"));
|
|
8
8
|
const env_1 = __importDefault(require("./env"));
|
|
9
9
|
const logger_1 = __importDefault(require("./logger"));
|
|
@@ -11,40 +11,64 @@ const compress_1 = require("./utils/compress");
|
|
|
11
11
|
const get_config_from_env_1 = require("./utils/get-config-from-env");
|
|
12
12
|
const get_milliseconds_1 = require("./utils/get-milliseconds");
|
|
13
13
|
const validate_env_1 = require("./utils/validate-env");
|
|
14
|
+
const messenger_1 = require("./messenger");
|
|
15
|
+
const utils_1 = require("@directus/shared/utils");
|
|
14
16
|
let cache = null;
|
|
15
17
|
let systemCache = null;
|
|
18
|
+
let localSchemaCache = null;
|
|
19
|
+
let sharedSchemaCache = null;
|
|
16
20
|
let lockCache = null;
|
|
21
|
+
let messengerSubscribed = false;
|
|
22
|
+
const messenger = (0, messenger_1.getMessenger)();
|
|
23
|
+
if (env_1.default.MESSENGER_STORE === 'redis' && env_1.default.CACHE_STORE === 'memory' && env_1.default.CACHE_AUTO_PURGE && !messengerSubscribed) {
|
|
24
|
+
messengerSubscribed = true;
|
|
25
|
+
messenger.subscribe('schemaChanged', async (opts) => {
|
|
26
|
+
if (cache && opts?.autoPurgeCache !== false) {
|
|
27
|
+
await cache.clear();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
17
31
|
function getCache() {
|
|
18
32
|
if (env_1.default.CACHE_ENABLED === true && cache === null) {
|
|
19
33
|
(0, validate_env_1.validateEnv)(['CACHE_NAMESPACE', 'CACHE_TTL', 'CACHE_STORE']);
|
|
20
|
-
cache = getKeyvInstance((0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_TTL));
|
|
34
|
+
cache = getKeyvInstance(env_1.default.CACHE_STORE, (0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_TTL));
|
|
21
35
|
cache.on('error', (err) => logger_1.default.warn(err, `[cache] ${err}`));
|
|
22
36
|
}
|
|
23
37
|
if (systemCache === null) {
|
|
24
|
-
systemCache = getKeyvInstance((0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_SYSTEM_TTL), '_system');
|
|
25
|
-
systemCache.on('error', (err) => logger_1.default.warn(err, `[cache] ${err}`));
|
|
38
|
+
systemCache = getKeyvInstance(env_1.default.CACHE_STORE, (0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_SYSTEM_TTL), '_system');
|
|
39
|
+
systemCache.on('error', (err) => logger_1.default.warn(err, `[system-cache] ${err}`));
|
|
40
|
+
}
|
|
41
|
+
if (sharedSchemaCache === null) {
|
|
42
|
+
sharedSchemaCache = getKeyvInstance(env_1.default.CACHE_STORE, (0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_SYSTEM_TTL), '_schema_shared');
|
|
43
|
+
sharedSchemaCache.on('error', (err) => logger_1.default.warn(err, `[shared-schema-cache] ${err}`));
|
|
44
|
+
}
|
|
45
|
+
if (localSchemaCache === null) {
|
|
46
|
+
localSchemaCache = getKeyvInstance('memory', (0, get_milliseconds_1.getMilliseconds)(env_1.default.CACHE_SYSTEM_TTL), '_schema');
|
|
47
|
+
localSchemaCache.on('error', (err) => logger_1.default.warn(err, `[schema-cache] ${err}`));
|
|
26
48
|
}
|
|
27
49
|
if (lockCache === null) {
|
|
28
|
-
lockCache = getKeyvInstance(undefined, '_lock');
|
|
29
|
-
lockCache.on('error', (err) => logger_1.default.warn(err, `[cache] ${err}`));
|
|
50
|
+
lockCache = getKeyvInstance(env_1.default.CACHE_STORE, undefined, '_lock');
|
|
51
|
+
lockCache.on('error', (err) => logger_1.default.warn(err, `[lock-cache] ${err}`));
|
|
30
52
|
}
|
|
31
|
-
return { cache, systemCache, lockCache };
|
|
53
|
+
return { cache, systemCache, sharedSchemaCache, localSchemaCache, lockCache };
|
|
32
54
|
}
|
|
33
55
|
exports.getCache = getCache;
|
|
34
56
|
async function flushCaches(forced) {
|
|
35
57
|
const { cache } = getCache();
|
|
36
|
-
await clearSystemCache(forced);
|
|
37
|
-
await
|
|
58
|
+
await clearSystemCache({ forced });
|
|
59
|
+
await cache?.clear();
|
|
38
60
|
}
|
|
39
61
|
exports.flushCaches = flushCaches;
|
|
40
|
-
async function clearSystemCache(
|
|
41
|
-
const { systemCache, lockCache } = getCache();
|
|
62
|
+
async function clearSystemCache(opts) {
|
|
63
|
+
const { systemCache, localSchemaCache, lockCache } = getCache();
|
|
42
64
|
// Flush system cache when forced or when system cache lock not set
|
|
43
|
-
if (forced || !(await lockCache.get('system-cache-lock'))) {
|
|
65
|
+
if (opts?.forced || !(await lockCache.get('system-cache-lock'))) {
|
|
44
66
|
await lockCache.set('system-cache-lock', true, 10000);
|
|
45
67
|
await systemCache.clear();
|
|
46
68
|
await lockCache.delete('system-cache-lock');
|
|
47
69
|
}
|
|
70
|
+
await localSchemaCache.clear();
|
|
71
|
+
messenger.publish('schemaChanged', { autoPurgeCache: opts?.autoPurgeCache });
|
|
48
72
|
}
|
|
49
73
|
exports.clearSystemCache = clearSystemCache;
|
|
50
74
|
async function setSystemCache(key, value, ttl) {
|
|
@@ -59,6 +83,25 @@ async function getSystemCache(key) {
|
|
|
59
83
|
return await getCacheValue(systemCache, key);
|
|
60
84
|
}
|
|
61
85
|
exports.getSystemCache = getSystemCache;
|
|
86
|
+
async function setSchemaCache(schema) {
|
|
87
|
+
const { localSchemaCache, sharedSchemaCache } = getCache();
|
|
88
|
+
const schemaHash = await (0, utils_1.getSimpleHash)(JSON.stringify(schema));
|
|
89
|
+
await sharedSchemaCache.set('hash', schemaHash);
|
|
90
|
+
await localSchemaCache.set('schema', schema);
|
|
91
|
+
await localSchemaCache.set('hash', schemaHash);
|
|
92
|
+
}
|
|
93
|
+
exports.setSchemaCache = setSchemaCache;
|
|
94
|
+
async function getSchemaCache() {
|
|
95
|
+
const { localSchemaCache, sharedSchemaCache } = getCache();
|
|
96
|
+
const sharedSchemaHash = await sharedSchemaCache.get('hash');
|
|
97
|
+
if (!sharedSchemaHash)
|
|
98
|
+
return;
|
|
99
|
+
const localSchemaHash = await localSchemaCache.get('hash');
|
|
100
|
+
if (!localSchemaHash || localSchemaHash !== sharedSchemaHash)
|
|
101
|
+
return;
|
|
102
|
+
return await localSchemaCache.get('schema');
|
|
103
|
+
}
|
|
104
|
+
exports.getSchemaCache = getSchemaCache;
|
|
62
105
|
async function setCacheValue(cache, key, value, ttl) {
|
|
63
106
|
const compressed = await (0, compress_1.compress)(value);
|
|
64
107
|
await cache.set(key, compressed, ttl);
|
|
@@ -72,8 +115,8 @@ async function getCacheValue(cache, key) {
|
|
|
72
115
|
return decompressed;
|
|
73
116
|
}
|
|
74
117
|
exports.getCacheValue = getCacheValue;
|
|
75
|
-
function getKeyvInstance(ttl, namespaceSuffix) {
|
|
76
|
-
switch (
|
|
118
|
+
function getKeyvInstance(store, ttl, namespaceSuffix) {
|
|
119
|
+
switch (store) {
|
|
77
120
|
case 'redis':
|
|
78
121
|
return new keyv_1.default(getConfig('redis', ttl, namespaceSuffix));
|
|
79
122
|
case 'memcache':
|
|
@@ -26,13 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const database_1 = __importStar(require("../../../database"));
|
|
29
30
|
const run_1 = __importDefault(require("../../../database/migrations/run"));
|
|
30
31
|
const run_2 = __importDefault(require("../../../database/seeds/run"));
|
|
31
32
|
const env_1 = __importDefault(require("../../../env"));
|
|
32
33
|
const logger_1 = __importDefault(require("../../../logger"));
|
|
33
|
-
const get_schema_1 = require("../../../utils/get-schema");
|
|
34
34
|
const services_1 = require("../../../services");
|
|
35
|
-
const
|
|
35
|
+
const get_schema_1 = require("../../../utils/get-schema");
|
|
36
36
|
const defaults_1 = require("../../utils/defaults");
|
|
37
37
|
async function bootstrap({ skipAdminInit }) {
|
|
38
38
|
logger_1.default.info('Initializing bootstrap...');
|
|
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const chalk_1 = __importDefault(require("chalk"));
|
|
7
7
|
const execa_1 = __importDefault(require("execa"));
|
|
8
8
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
9
|
+
const joi_1 = __importDefault(require("joi"));
|
|
9
10
|
const ora_1 = __importDefault(require("ora"));
|
|
10
11
|
const uuid_1 = require("uuid");
|
|
11
|
-
const joi_1 = __importDefault(require("joi"));
|
|
12
12
|
const run_1 = __importDefault(require("../../../database/migrations/run"));
|
|
13
13
|
const run_2 = __importDefault(require("../../../database/seeds/run"));
|
|
14
|
+
const generate_hash_1 = require("../../../utils/generate-hash");
|
|
14
15
|
const create_db_connection_1 = __importDefault(require("../../utils/create-db-connection"));
|
|
15
16
|
const create_env_1 = __importDefault(require("../../utils/create-env"));
|
|
17
|
+
const defaults_1 = require("../../utils/defaults");
|
|
16
18
|
const drivers_1 = require("../../utils/drivers");
|
|
17
19
|
const questions_1 = require("./questions");
|
|
18
|
-
const generate_hash_1 = require("../../../utils/generate-hash");
|
|
19
|
-
const defaults_1 = require("../../utils/defaults");
|
|
20
20
|
async function init() {
|
|
21
21
|
const rootPath = process.cwd();
|
|
22
22
|
const { client } = await inquirer_1.default.prompt([
|
|
@@ -41,7 +41,6 @@ const apply_snapshot_1 = require("../../../utils/apply-snapshot");
|
|
|
41
41
|
const get_snapshot_1 = require("../../../utils/get-snapshot");
|
|
42
42
|
const get_snapshot_diff_1 = require("../../../utils/get-snapshot-diff");
|
|
43
43
|
async function apply(snapshotPath, options) {
|
|
44
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
45
44
|
const filename = path_1.default.resolve(process.cwd(), snapshotPath);
|
|
46
45
|
const database = (0, database_1.default)();
|
|
47
46
|
await (0, database_1.validateDatabaseConnection)(database);
|
|
@@ -68,14 +67,14 @@ async function apply(snapshotPath, options) {
|
|
|
68
67
|
database.destroy();
|
|
69
68
|
process.exit(0);
|
|
70
69
|
}
|
|
71
|
-
const dryRun =
|
|
72
|
-
const promptForChanges = !dryRun &&
|
|
70
|
+
const dryRun = options?.dryRun === true;
|
|
71
|
+
const promptForChanges = !dryRun && options?.yes !== true;
|
|
73
72
|
if (dryRun || promptForChanges) {
|
|
74
73
|
let message = '';
|
|
75
74
|
if (snapshotDiff.collections.length > 0) {
|
|
76
75
|
message += chalk_1.default.black.underline.bold('Collections:');
|
|
77
76
|
for (const { collection, diff } of snapshotDiff.collections) {
|
|
78
|
-
if (
|
|
77
|
+
if (diff[0]?.kind === types_1.DiffKind.EDIT) {
|
|
79
78
|
message += `\n - ${chalk_1.default.blue('Update')} ${collection}`;
|
|
80
79
|
for (const change of diff) {
|
|
81
80
|
if (change.kind === types_1.DiffKind.EDIT) {
|
|
@@ -84,13 +83,13 @@ async function apply(snapshotPath, options) {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
else if (
|
|
86
|
+
else if (diff[0]?.kind === types_1.DiffKind.DELETE) {
|
|
88
87
|
message += `\n - ${chalk_1.default.red('Delete')} ${collection}`;
|
|
89
88
|
}
|
|
90
|
-
else if (
|
|
89
|
+
else if (diff[0]?.kind === types_1.DiffKind.NEW) {
|
|
91
90
|
message += `\n - ${chalk_1.default.green('Create')} ${collection}`;
|
|
92
91
|
}
|
|
93
|
-
else if (
|
|
92
|
+
else if (diff[0]?.kind === types_1.DiffKind.ARRAY) {
|
|
94
93
|
message += `\n - ${chalk_1.default.blue('Update')} ${collection}`;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
@@ -98,7 +97,7 @@ async function apply(snapshotPath, options) {
|
|
|
98
97
|
if (snapshotDiff.fields.length > 0) {
|
|
99
98
|
message += '\n\n' + chalk_1.default.black.underline.bold('Fields:');
|
|
100
99
|
for (const { collection, field, diff } of snapshotDiff.fields) {
|
|
101
|
-
if (
|
|
100
|
+
if (diff[0]?.kind === types_1.DiffKind.EDIT || (0, apply_diff_1.isNestedMetaUpdate)(diff[0])) {
|
|
102
101
|
message += `\n - ${chalk_1.default.blue('Update')} ${collection}.${field}`;
|
|
103
102
|
for (const change of diff) {
|
|
104
103
|
const path = change.path.slice(1).join('.');
|
|
@@ -113,13 +112,13 @@ async function apply(snapshotPath, options) {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
|
-
else if (
|
|
115
|
+
else if (diff[0]?.kind === types_1.DiffKind.DELETE) {
|
|
117
116
|
message += `\n - ${chalk_1.default.red('Delete')} ${collection}.${field}`;
|
|
118
117
|
}
|
|
119
|
-
else if (
|
|
118
|
+
else if (diff[0]?.kind === types_1.DiffKind.NEW) {
|
|
120
119
|
message += `\n - ${chalk_1.default.green('Create')} ${collection}.${field}`;
|
|
121
120
|
}
|
|
122
|
-
else if (
|
|
121
|
+
else if (diff[0]?.kind === types_1.DiffKind.ARRAY) {
|
|
123
122
|
message += `\n - ${chalk_1.default.blue('Update')} ${collection}.${field}`;
|
|
124
123
|
}
|
|
125
124
|
}
|
|
@@ -127,7 +126,7 @@ async function apply(snapshotPath, options) {
|
|
|
127
126
|
if (snapshotDiff.relations.length > 0) {
|
|
128
127
|
message += '\n\n' + chalk_1.default.black.underline.bold('Relations:');
|
|
129
128
|
for (const { collection, field, related_collection, diff } of snapshotDiff.relations) {
|
|
130
|
-
if (
|
|
129
|
+
if (diff[0]?.kind === types_1.DiffKind.EDIT) {
|
|
131
130
|
message += `\n - ${chalk_1.default.blue('Update')} ${collection}.${field}`;
|
|
132
131
|
for (const change of diff) {
|
|
133
132
|
if (change.kind === types_1.DiffKind.EDIT) {
|
|
@@ -136,13 +135,13 @@ async function apply(snapshotPath, options) {
|
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
|
-
else if (
|
|
138
|
+
else if (diff[0]?.kind === types_1.DiffKind.DELETE) {
|
|
140
139
|
message += `\n - ${chalk_1.default.red('Delete')} ${collection}.${field}`;
|
|
141
140
|
}
|
|
142
|
-
else if (
|
|
141
|
+
else if (diff[0]?.kind === types_1.DiffKind.NEW) {
|
|
143
142
|
message += `\n - ${chalk_1.default.green('Create')} ${collection}.${field}`;
|
|
144
143
|
}
|
|
145
|
-
else if (
|
|
144
|
+
else if (diff[0]?.kind === types_1.DiffKind.ARRAY) {
|
|
146
145
|
message += `\n - ${chalk_1.default.blue('Update')} ${collection}.${field}`;
|
|
147
146
|
}
|
|
148
147
|
else {
|
|
@@ -16,7 +16,7 @@ async function snapshot(snapshotPath, options) {
|
|
|
16
16
|
try {
|
|
17
17
|
const snapshot = await (0, get_snapshot_1.getSnapshot)({ database });
|
|
18
18
|
let snapshotString;
|
|
19
|
-
if (
|
|
19
|
+
if (options?.format === 'yaml') {
|
|
20
20
|
snapshotString = (0, js_yaml_1.dump)(snapshot);
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
@@ -32,7 +32,7 @@ async function snapshot(snapshotPath, options) {
|
|
|
32
32
|
catch {
|
|
33
33
|
snapshotExists = false;
|
|
34
34
|
}
|
|
35
|
-
if (snapshotExists &&
|
|
35
|
+
if (snapshotExists && options?.yes === false) {
|
|
36
36
|
const { overwrite } = await inquirer_1.default.prompt([
|
|
37
37
|
{
|
|
38
38
|
type: 'confirm',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Credentials } from '../create-db-connection';
|
|
2
|
-
import { drivers } from '../drivers';
|
|
1
|
+
import type { Credentials } from '../create-db-connection';
|
|
2
|
+
import type { drivers } from '../drivers';
|
|
3
3
|
export default function createEnv(client: keyof typeof drivers, credentials: Credentials, directory: string): Promise<void>;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CookieOptions } from 'express';
|
|
2
|
-
import { TransformationParams } from './types';
|
|
1
|
+
import type { CookieOptions } from 'express';
|
|
2
|
+
import type { TransformationParams } from './types';
|
|
3
3
|
export declare const SYSTEM_ASSET_ALLOW_LIST: TransformationParams[];
|
|
4
4
|
export declare const ASSET_TRANSFORM_QUERY_KEYS: string[];
|
|
5
5
|
export declare const FILTER_VARIABLES: string[];
|
package/dist/constants.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.OAS_REQUIRED_SCHEMAS = exports.COOKIE_OPTIONS = exports.UUID_REGEX = exports.GENERATE_SPECIAL = exports.COLUMN_TRANSFORMS = exports.DEFAULT_AUTH_PROVIDER = exports.ALIAS_TYPES = exports.FILTER_VARIABLES = exports.ASSET_TRANSFORM_QUERY_KEYS = exports.SYSTEM_ASSET_ALLOW_LIST = void 0;
|
|
8
7
|
const env_1 = __importDefault(require("./env"));
|
|
@@ -53,7 +52,7 @@ exports.COOKIE_OPTIONS = {
|
|
|
53
52
|
httpOnly: true,
|
|
54
53
|
domain: env_1.default.REFRESH_TOKEN_COOKIE_DOMAIN,
|
|
55
54
|
maxAge: (0, get_milliseconds_1.getMilliseconds)(env_1.default.REFRESH_TOKEN_TTL),
|
|
56
|
-
secure:
|
|
55
|
+
secure: env_1.default.REFRESH_TOKEN_COOKIE_SECURE ?? false,
|
|
57
56
|
sameSite: env_1.default.REFRESH_TOKEN_COOKIE_SAME_SITE || 'strict',
|
|
58
57
|
};
|
|
59
|
-
exports.OAS_REQUIRED_SCHEMAS = ['Query', 'x-metadata'];
|
|
58
|
+
exports.OAS_REQUIRED_SCHEMAS = ['Diff', 'Schema', 'Query', 'x-metadata'];
|
|
@@ -60,7 +60,6 @@ const createCommentSchema = joi_1.default.object({
|
|
|
60
60
|
item: [joi_1.default.number().required(), joi_1.default.string().required()],
|
|
61
61
|
});
|
|
62
62
|
router.post('/comment', (0, async_handler_1.default)(async (req, res, next) => {
|
|
63
|
-
var _a;
|
|
64
63
|
const service = new services_1.ActivityService({
|
|
65
64
|
accountability: req.accountability,
|
|
66
65
|
schema: req.schema,
|
|
@@ -72,7 +71,7 @@ router.post('/comment', (0, async_handler_1.default)(async (req, res, next) => {
|
|
|
72
71
|
const primaryKey = await service.createOne({
|
|
73
72
|
...req.body,
|
|
74
73
|
action: types_1.Action.COMMENT,
|
|
75
|
-
user:
|
|
74
|
+
user: req.accountability?.user,
|
|
76
75
|
ip: (0, get_ip_from_req_1.getIPFromReq)(req),
|
|
77
76
|
user_agent: req.get('user-agent'),
|
|
78
77
|
origin: req.get('origin'),
|
|
@@ -103,8 +103,7 @@ router.get('/:pk/:filename?',
|
|
|
103
103
|
}),
|
|
104
104
|
// Return file
|
|
105
105
|
(0, async_handler_1.default)(async (req, res) => {
|
|
106
|
-
|
|
107
|
-
const id = (_a = req.params.pk) === null || _a === void 0 ? void 0 : _a.substring(0, 36);
|
|
106
|
+
const id = req.params.pk?.substring(0, 36);
|
|
108
107
|
const service = new services_1.AssetsService({
|
|
109
108
|
accountability: req.accountability,
|
|
110
109
|
schema: req.schema,
|
|
@@ -115,16 +114,22 @@ router.get('/:pk/:filename?',
|
|
|
115
114
|
let range = undefined;
|
|
116
115
|
if (req.headers.range) {
|
|
117
116
|
const rangeParts = /bytes=([0-9]*)-([0-9]*)/.exec(req.headers.range);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
if (rangeParts && rangeParts.length > 1) {
|
|
118
|
+
range = {};
|
|
119
|
+
if (rangeParts[1]) {
|
|
120
|
+
range.start = Number(rangeParts[1]);
|
|
121
|
+
if (Number.isNaN(range.start))
|
|
122
|
+
throw new exceptions_1.RangeNotSatisfiableException(range);
|
|
123
|
+
}
|
|
124
|
+
if (rangeParts[2]) {
|
|
125
|
+
range.end = Number(rangeParts[2]);
|
|
126
|
+
if (Number.isNaN(range.end))
|
|
127
|
+
throw new exceptions_1.RangeNotSatisfiableException(range);
|
|
128
|
+
}
|
|
124
129
|
}
|
|
125
130
|
}
|
|
126
131
|
const { stream, file, stat } = await service.getAsset(id, transformation, range);
|
|
127
|
-
res.attachment(
|
|
132
|
+
res.attachment(req.params.filename ?? file.filename_download);
|
|
128
133
|
res.setHeader('Content-Type', file.type);
|
|
129
134
|
res.setHeader('Accept-Ranges', 'bytes');
|
|
130
135
|
res.setHeader('Cache-Control', (0, get_cache_headers_1.getCacheControlHeader)(req, (0, get_milliseconds_1.getMilliseconds)(env_1.default.ASSETS_CACHE_TTL), false, true));
|
package/dist/controllers/auth.js
CHANGED
|
@@ -4,17 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const express_1 = require("express");
|
|
7
|
+
const drivers_1 = require("../auth/drivers");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
7
9
|
const env_1 = __importDefault(require("../env"));
|
|
8
10
|
const exceptions_1 = require("../exceptions");
|
|
11
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
9
12
|
const respond_1 = require("../middleware/respond");
|
|
10
13
|
const services_1 = require("../services");
|
|
11
14
|
const async_handler_1 = __importDefault(require("../utils/async-handler"));
|
|
12
15
|
const get_auth_providers_1 = require("../utils/get-auth-providers");
|
|
13
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
14
|
-
const drivers_1 = require("../auth/drivers");
|
|
15
|
-
const constants_1 = require("../constants");
|
|
16
16
|
const get_ip_from_req_1 = require("../utils/get-ip-from-req");
|
|
17
|
-
const constants_2 = require("../constants");
|
|
18
17
|
const router = (0, express_1.Router)();
|
|
19
18
|
const authProviders = (0, get_auth_providers_1.getAuthProviders)();
|
|
20
19
|
for (const authProvider of authProviders) {
|
|
@@ -48,10 +47,14 @@ if (!env_1.default.AUTH_DISABLE_DEFAULT) {
|
|
|
48
47
|
router.post('/refresh', (0, async_handler_1.default)(async (req, res, next) => {
|
|
49
48
|
const accountability = {
|
|
50
49
|
ip: (0, get_ip_from_req_1.getIPFromReq)(req),
|
|
51
|
-
userAgent: req.get('user-agent'),
|
|
52
|
-
origin: req.get('origin'),
|
|
53
50
|
role: null,
|
|
54
51
|
};
|
|
52
|
+
const userAgent = req.get('user-agent');
|
|
53
|
+
if (userAgent)
|
|
54
|
+
accountability.userAgent = userAgent;
|
|
55
|
+
const origin = req.get('origin');
|
|
56
|
+
if (origin)
|
|
57
|
+
accountability.origin = origin;
|
|
55
58
|
const authenticationService = new services_1.AuthenticationService({
|
|
56
59
|
accountability: accountability,
|
|
57
60
|
schema: req.schema,
|
|
@@ -69,19 +72,22 @@ router.post('/refresh', (0, async_handler_1.default)(async (req, res, next) => {
|
|
|
69
72
|
payload.data.refresh_token = refreshToken;
|
|
70
73
|
}
|
|
71
74
|
if (mode === 'cookie') {
|
|
72
|
-
res.cookie(env_1.default.REFRESH_TOKEN_COOKIE_NAME, refreshToken,
|
|
75
|
+
res.cookie(env_1.default.REFRESH_TOKEN_COOKIE_NAME, refreshToken, constants_1.COOKIE_OPTIONS);
|
|
73
76
|
}
|
|
74
77
|
res.locals.payload = payload;
|
|
75
78
|
return next();
|
|
76
79
|
}), respond_1.respond);
|
|
77
80
|
router.post('/logout', (0, async_handler_1.default)(async (req, res, next) => {
|
|
78
|
-
var _a;
|
|
79
81
|
const accountability = {
|
|
80
82
|
ip: (0, get_ip_from_req_1.getIPFromReq)(req),
|
|
81
|
-
userAgent: req.get('user-agent'),
|
|
82
|
-
origin: req.get('origin'),
|
|
83
83
|
role: null,
|
|
84
84
|
};
|
|
85
|
+
const userAgent = req.get('user-agent');
|
|
86
|
+
if (userAgent)
|
|
87
|
+
accountability.userAgent = userAgent;
|
|
88
|
+
const origin = req.get('origin');
|
|
89
|
+
if (origin)
|
|
90
|
+
accountability.origin = origin;
|
|
85
91
|
const authenticationService = new services_1.AuthenticationService({
|
|
86
92
|
accountability: accountability,
|
|
87
93
|
schema: req.schema,
|
|
@@ -95,7 +101,7 @@ router.post('/logout', (0, async_handler_1.default)(async (req, res, next) => {
|
|
|
95
101
|
res.clearCookie(env_1.default.REFRESH_TOKEN_COOKIE_NAME, {
|
|
96
102
|
httpOnly: true,
|
|
97
103
|
domain: env_1.default.REFRESH_TOKEN_COOKIE_DOMAIN,
|
|
98
|
-
secure:
|
|
104
|
+
secure: env_1.default.REFRESH_TOKEN_COOKIE_SECURE ?? false,
|
|
99
105
|
sameSite: env_1.default.REFRESH_TOKEN_COOKIE_SAME_SITE || 'strict',
|
|
100
106
|
});
|
|
101
107
|
}
|
|
@@ -107,10 +113,14 @@ router.post('/password/request', (0, async_handler_1.default)(async (req, res, n
|
|
|
107
113
|
}
|
|
108
114
|
const accountability = {
|
|
109
115
|
ip: (0, get_ip_from_req_1.getIPFromReq)(req),
|
|
110
|
-
userAgent: req.get('user-agent'),
|
|
111
|
-
origin: req.get('origin'),
|
|
112
116
|
role: null,
|
|
113
117
|
};
|
|
118
|
+
const userAgent = req.get('user-agent');
|
|
119
|
+
if (userAgent)
|
|
120
|
+
accountability.userAgent = userAgent;
|
|
121
|
+
const origin = req.get('origin');
|
|
122
|
+
if (origin)
|
|
123
|
+
accountability.origin = origin;
|
|
114
124
|
const service = new services_1.UsersService({ accountability, schema: req.schema });
|
|
115
125
|
try {
|
|
116
126
|
await service.requestPasswordReset(req.body.email, req.body.reset_url || null);
|
|
@@ -135,10 +145,14 @@ router.post('/password/reset', (0, async_handler_1.default)(async (req, res, nex
|
|
|
135
145
|
}
|
|
136
146
|
const accountability = {
|
|
137
147
|
ip: (0, get_ip_from_req_1.getIPFromReq)(req),
|
|
138
|
-
userAgent: req.get('user-agent'),
|
|
139
|
-
origin: req.get('origin'),
|
|
140
148
|
role: null,
|
|
141
149
|
};
|
|
150
|
+
const userAgent = req.get('user-agent');
|
|
151
|
+
if (userAgent)
|
|
152
|
+
accountability.userAgent = userAgent;
|
|
153
|
+
const origin = req.get('origin');
|
|
154
|
+
if (origin)
|
|
155
|
+
accountability.origin = origin;
|
|
142
156
|
const service = new services_1.UsersService({ accountability, schema: req.schema });
|
|
143
157
|
await service.resetPassword(req.body.token, req.body.password);
|
|
144
158
|
return next();
|
|
@@ -10,6 +10,7 @@ const use_collection_1 = __importDefault(require("../middleware/use-collection")
|
|
|
10
10
|
const validate_batch_1 = require("../middleware/validate-batch");
|
|
11
11
|
const services_1 = require("../services");
|
|
12
12
|
const async_handler_1 = __importDefault(require("../utils/async-handler"));
|
|
13
|
+
const sanitize_query_1 = require("../utils/sanitize-query");
|
|
13
14
|
const router = express_1.default.Router();
|
|
14
15
|
router.use((0, use_collection_1.default)('directus_dashboards'));
|
|
15
16
|
router.post('/', (0, async_handler_1.default)(async (req, res, next) => {
|
|
@@ -82,7 +83,8 @@ router.patch('/', (0, validate_batch_1.validateBatch)('update'), (0, async_handl
|
|
|
82
83
|
keys = await service.updateMany(req.body.keys, req.body.data);
|
|
83
84
|
}
|
|
84
85
|
else {
|
|
85
|
-
|
|
86
|
+
const sanitizedQuery = (0, sanitize_query_1.sanitizeQuery)(req.body.query, req.accountability);
|
|
87
|
+
keys = await service.updateByQuery(sanitizedQuery, req.body.data);
|
|
86
88
|
}
|
|
87
89
|
try {
|
|
88
90
|
const result = await service.readMany(keys, req.sanitizedQuery);
|
|
@@ -126,7 +128,8 @@ router.delete('/', (0, async_handler_1.default)(async (req, res, next) => {
|
|
|
126
128
|
await service.deleteMany(req.body.keys);
|
|
127
129
|
}
|
|
128
130
|
else {
|
|
129
|
-
|
|
131
|
+
const sanitizedQuery = (0, sanitize_query_1.sanitizeQuery)(req.body.query, req.accountability);
|
|
132
|
+
await service.deleteByQuery(sanitizedQuery);
|
|
130
133
|
}
|
|
131
134
|
return next();
|
|
132
135
|
}), respond_1.respond);
|
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const constants_1 = require("@directus/shared/constants");
|
|
6
7
|
const express_1 = require("express");
|
|
7
8
|
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const
|
|
9
|
+
const constants_2 = require("../constants");
|
|
9
10
|
const exceptions_1 = require("../exceptions");
|
|
10
11
|
const collection_exists_1 = __importDefault(require("../middleware/collection-exists"));
|
|
11
12
|
const respond_1 = require("../middleware/respond");
|
|
12
13
|
const use_collection_1 = __importDefault(require("../middleware/use-collection"));
|
|
13
14
|
const fields_1 = require("../services/fields");
|
|
14
|
-
const constants_2 = require("@directus/shared/constants");
|
|
15
15
|
const async_handler_1 = __importDefault(require("../utils/async-handler"));
|
|
16
16
|
const router = (0, express_1.Router)();
|
|
17
17
|
router.use((0, use_collection_1.default)('directus_fields'));
|
|
@@ -46,7 +46,7 @@ const newFieldSchema = joi_1.default.object({
|
|
|
46
46
|
collection: joi_1.default.string().optional(),
|
|
47
47
|
field: joi_1.default.string().required(),
|
|
48
48
|
type: joi_1.default.string()
|
|
49
|
-
.valid(...
|
|
49
|
+
.valid(...constants_1.TYPES, ...constants_2.ALIAS_TYPES)
|
|
50
50
|
.allow(null)
|
|
51
51
|
.optional(),
|
|
52
52
|
schema: joi_1.default.object({
|
|
@@ -110,7 +110,7 @@ router.patch('/:collection', collection_exists_1.default, (0, async_handler_1.de
|
|
|
110
110
|
}), respond_1.respond);
|
|
111
111
|
const updateSchema = joi_1.default.object({
|
|
112
112
|
type: joi_1.default.string()
|
|
113
|
-
.valid(...
|
|
113
|
+
.valid(...constants_1.TYPES, ...constants_2.ALIAS_TYPES)
|
|
114
114
|
.allow(null),
|
|
115
115
|
schema: joi_1.default.object({
|
|
116
116
|
default_value: joi_1.default.any(),
|
|
@@ -18,6 +18,7 @@ const services_1 = require("../services");
|
|
|
18
18
|
const async_handler_1 = __importDefault(require("../utils/async-handler"));
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
const format_title_1 = __importDefault(require("@directus/format-title"));
|
|
21
|
+
const sanitize_query_1 = require("../utils/sanitize-query");
|
|
21
22
|
const router = express_1.default.Router();
|
|
22
23
|
router.use((0, use_collection_1.default)('directus_files'));
|
|
23
24
|
const multipartHandler = (req, res, next) => {
|
|
@@ -63,12 +64,14 @@ const multipartHandler = (req, res, next) => {
|
|
|
63
64
|
return busboy.emit('error', new exceptions_1.InvalidPayloadException(`File is missing filename`));
|
|
64
65
|
}
|
|
65
66
|
fileCount++;
|
|
66
|
-
if (!
|
|
67
|
-
payload.title
|
|
67
|
+
if (!existingPrimaryKey) {
|
|
68
|
+
if (!payload.title) {
|
|
69
|
+
payload.title = (0, format_title_1.default)(path_1.default.parse(filename).name);
|
|
70
|
+
}
|
|
71
|
+
payload.filename_download = filename;
|
|
68
72
|
}
|
|
69
73
|
const payloadWithRequiredFields = {
|
|
70
74
|
...payload,
|
|
71
|
-
filename_download: filename,
|
|
72
75
|
type: mimeType,
|
|
73
76
|
storage: payload.storage || disk,
|
|
74
77
|
};
|
|
@@ -209,7 +212,8 @@ router.patch('/', (0, validate_batch_1.validateBatch)('update'), (0, async_handl
|
|
|
209
212
|
keys = await service.updateMany(req.body.keys, req.body.data);
|
|
210
213
|
}
|
|
211
214
|
else {
|
|
212
|
-
|
|
215
|
+
const sanitizedQuery = (0, sanitize_query_1.sanitizeQuery)(req.body.query, req.accountability);
|
|
216
|
+
keys = await service.updateByQuery(sanitizedQuery, req.body.data);
|
|
213
217
|
}
|
|
214
218
|
try {
|
|
215
219
|
const result = await service.readMany(keys, req.sanitizedQuery);
|
|
@@ -253,7 +257,8 @@ router.delete('/', (0, validate_batch_1.validateBatch)('delete'), (0, async_hand
|
|
|
253
257
|
await service.deleteMany(req.body.keys);
|
|
254
258
|
}
|
|
255
259
|
else {
|
|
256
|
-
|
|
260
|
+
const sanitizedQuery = (0, sanitize_query_1.sanitizeQuery)(req.body.query, req.accountability);
|
|
261
|
+
await service.deleteByQuery(sanitizedQuery);
|
|
257
262
|
}
|
|
258
263
|
return next();
|
|
259
264
|
}), respond_1.respond);
|