@directus/api 11.0.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +3 -4
- package/dist/auth/auth.d.ts +4 -4
- package/dist/auth/auth.js +2 -2
- package/dist/auth/drivers/ldap.js +20 -17
- package/dist/auth/drivers/local.js +5 -5
- package/dist/auth/drivers/oauth2.js +16 -16
- package/dist/auth/drivers/openid.js +18 -17
- package/dist/auth/drivers/saml.js +6 -7
- package/dist/auth.js +3 -2
- package/dist/cache.js +3 -13
- package/dist/cli/utils/create-env/env-stub.liquid +5 -7
- package/dist/controllers/activity.js +7 -6
- package/dist/controllers/assets.js +25 -12
- package/dist/controllers/auth.js +8 -7
- package/dist/controllers/collections.js +4 -3
- package/dist/controllers/dashboards.js +5 -4
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +9 -8
- package/dist/controllers/files.js +11 -11
- package/dist/controllers/flows.js +5 -4
- package/dist/controllers/folders.js +5 -4
- package/dist/controllers/items.js +14 -13
- package/dist/controllers/not-found.js +2 -2
- package/dist/controllers/notifications.js +5 -4
- package/dist/controllers/operations.js +5 -4
- package/dist/controllers/panels.js +5 -4
- package/dist/controllers/permissions.js +5 -4
- package/dist/controllers/presets.js +5 -4
- package/dist/controllers/relations.js +6 -5
- package/dist/controllers/roles.js +5 -4
- package/dist/controllers/schema.js +8 -8
- package/dist/controllers/server.js +2 -2
- package/dist/controllers/settings.js +3 -2
- package/dist/controllers/shares.js +7 -6
- package/dist/controllers/translations.js +6 -5
- package/dist/controllers/users.js +22 -21
- package/dist/controllers/utils.js +10 -10
- package/dist/controllers/webhooks.js +5 -4
- package/dist/{exceptions/database → database/errors}/dialects/mssql.js +8 -18
- package/dist/{exceptions/database → database/errors}/dialects/mysql.js +9 -19
- package/dist/{exceptions/database → database/errors}/dialects/oracle.js +2 -2
- package/dist/{exceptions/database → database/errors}/dialects/postgres.js +7 -18
- package/dist/{exceptions/database → database/errors}/dialects/sqlite.js +7 -10
- package/dist/{exceptions/database → database/errors}/translate.js +1 -1
- package/dist/database/migrations/run.js +10 -1
- package/dist/emitter.d.ts +3 -2
- package/dist/emitter.js +12 -4
- package/dist/env.js +21 -17
- package/dist/errors/codes.d.ts +29 -0
- package/dist/errors/codes.js +30 -0
- package/dist/errors/contains-null-values.d.ts +7 -0
- package/dist/errors/contains-null-values.js +4 -0
- package/dist/errors/content-too-large.d.ts +1 -0
- package/dist/errors/content-too-large.js +3 -0
- package/dist/errors/forbidden.d.ts +1 -0
- package/dist/errors/forbidden.js +3 -0
- package/dist/errors/hit-rate-limit.d.ts +6 -0
- package/dist/errors/hit-rate-limit.js +8 -0
- package/dist/errors/illegal-asset-transformation.d.ts +4 -0
- package/dist/errors/illegal-asset-transformation.js +3 -0
- package/dist/errors/index.d.ts +28 -0
- package/dist/errors/index.js +28 -0
- package/dist/errors/invalid-credentials.d.ts +1 -0
- package/dist/errors/invalid-credentials.js +3 -0
- package/dist/errors/invalid-foreign-key.d.ts +6 -0
- package/dist/errors/invalid-foreign-key.js +14 -0
- package/dist/errors/invalid-ip.d.ts +1 -0
- package/dist/errors/invalid-ip.js +3 -0
- package/dist/errors/invalid-otp.d.ts +1 -0
- package/dist/errors/invalid-otp.js +3 -0
- package/dist/errors/invalid-payload.d.ts +5 -0
- package/dist/errors/invalid-payload.js +4 -0
- package/dist/errors/invalid-provider-config.d.ts +5 -0
- package/dist/errors/invalid-provider-config.js +3 -0
- package/dist/errors/invalid-provider.d.ts +1 -0
- package/dist/errors/invalid-provider.js +3 -0
- package/dist/errors/invalid-query.d.ts +5 -0
- package/dist/errors/invalid-query.js +4 -0
- package/dist/errors/invalid-token.d.ts +1 -0
- package/dist/errors/invalid-token.js +3 -0
- package/dist/errors/method-not-allowed.d.ts +6 -0
- package/dist/errors/method-not-allowed.js +6 -0
- package/dist/errors/not-null-violation.d.ts +6 -0
- package/dist/errors/not-null-violation.js +14 -0
- package/dist/errors/range-not-satisfiable.d.ts +7 -0
- package/dist/errors/range-not-satisfiable.js +7 -0
- package/dist/errors/record-not-unique.d.ts +6 -0
- package/dist/errors/record-not-unique.js +14 -0
- package/dist/errors/route-not-found.d.ts +5 -0
- package/dist/errors/route-not-found.js +4 -0
- package/dist/errors/service-unavailable.d.ts +7 -0
- package/dist/errors/service-unavailable.js +4 -0
- package/dist/errors/token-expired.d.ts +1 -0
- package/dist/errors/token-expired.js +3 -0
- package/dist/errors/unexpected-response.d.ts +1 -0
- package/dist/errors/unexpected-response.js +3 -0
- package/dist/errors/unprocessable-content.d.ts +5 -0
- package/dist/errors/unprocessable-content.js +4 -0
- package/dist/errors/unsupported-media-type.d.ts +6 -0
- package/dist/errors/unsupported-media-type.js +4 -0
- package/dist/errors/user-suspended.d.ts +1 -0
- package/dist/errors/user-suspended.js +3 -0
- package/dist/errors/value-out-of-range.d.ts +6 -0
- package/dist/errors/value-out-of-range.js +14 -0
- package/dist/errors/value-too-long.d.ts +6 -0
- package/dist/errors/value-too-long.js +14 -0
- package/dist/extensions.js +0 -4
- package/dist/flows.js +6 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/messenger.d.ts +3 -3
- package/dist/messenger.js +18 -9
- package/dist/middleware/authenticate.js +2 -38
- package/dist/middleware/check-ip.js +2 -2
- package/dist/middleware/collection-exists.js +2 -2
- package/dist/middleware/error-handler.js +7 -7
- package/dist/middleware/graphql.js +11 -9
- package/dist/middleware/rate-limiter-global.d.ts +2 -2
- package/dist/middleware/rate-limiter-global.js +2 -3
- package/dist/middleware/rate-limiter-ip.d.ts +2 -2
- package/dist/middleware/rate-limiter-ip.js +2 -3
- package/dist/middleware/validate-batch.js +3 -4
- package/dist/rate-limiter.js +2 -9
- package/dist/server.js +10 -0
- package/dist/services/activity.js +3 -2
- package/dist/services/assets.js +9 -10
- package/dist/services/authentication.js +12 -11
- package/dist/services/authorization.d.ts +1 -1
- package/dist/services/authorization.js +16 -16
- package/dist/services/collections.js +17 -16
- package/dist/services/fields.js +16 -14
- package/dist/services/files.js +7 -6
- package/dist/services/graphql/errors/execution.d.ts +6 -0
- package/dist/services/graphql/errors/execution.js +2 -0
- package/dist/services/graphql/errors/index.d.ts +2 -0
- package/dist/services/graphql/errors/index.js +2 -0
- package/dist/services/graphql/errors/validation.d.ts +6 -0
- package/dist/services/graphql/errors/validation.js +2 -0
- package/dist/services/graphql/index.d.ts +2 -8
- package/dist/services/graphql/index.js +125 -66
- package/dist/services/graphql/subscription.d.ts +16 -0
- package/dist/services/graphql/subscription.js +77 -0
- package/dist/services/graphql/utils/process-error.js +3 -3
- package/dist/services/import-export.js +7 -7
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/items.js +14 -13
- package/dist/services/mail/index.js +3 -3
- package/dist/services/meta.js +3 -3
- package/dist/services/payload.js +11 -7
- package/dist/services/relations.js +32 -22
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.js +10 -9
- package/dist/services/schema.js +5 -5
- package/dist/services/server.js +24 -0
- package/dist/services/shares.js +4 -4
- package/dist/services/tfa.js +6 -6
- package/dist/services/translations.d.ts +2 -2
- package/dist/services/translations.js +4 -4
- package/dist/services/users.js +26 -29
- package/dist/services/utils.js +4 -4
- package/dist/services/websocket.d.ts +14 -0
- package/dist/services/websocket.js +26 -0
- package/dist/synchronization.js +3 -3
- package/dist/types/items.d.ts +2 -2
- package/dist/utils/apply-diff.js +13 -4
- package/dist/utils/apply-query.js +22 -13
- package/dist/utils/get-accountability-for-role.js +1 -2
- package/dist/utils/get-accountability-for-token.d.ts +2 -0
- package/dist/utils/get-accountability-for-token.js +50 -0
- package/dist/utils/get-column-path.js +5 -3
- package/dist/utils/get-column.js +3 -3
- package/dist/utils/get-service.d.ts +7 -0
- package/dist/utils/get-service.js +49 -0
- package/dist/utils/jwt.js +5 -5
- package/dist/utils/redact.d.ts +4 -0
- package/dist/utils/redact.js +15 -1
- package/dist/utils/to-boolean.d.ts +4 -0
- package/dist/utils/to-boolean.js +6 -0
- package/dist/utils/validate-diff.js +23 -9
- package/dist/utils/validate-keys.js +3 -3
- package/dist/utils/validate-query.d.ts +2 -0
- package/dist/utils/validate-query.js +27 -21
- package/dist/utils/validate-snapshot.js +11 -5
- package/dist/websocket/authenticate.d.ts +6 -0
- package/dist/websocket/authenticate.js +59 -0
- package/dist/websocket/controllers/base.d.ts +42 -0
- package/dist/websocket/controllers/base.js +279 -0
- package/dist/websocket/controllers/graphql.d.ts +12 -0
- package/dist/websocket/controllers/graphql.js +102 -0
- package/dist/websocket/controllers/hooks.d.ts +1 -0
- package/dist/websocket/controllers/hooks.js +122 -0
- package/dist/websocket/controllers/index.d.ts +10 -0
- package/dist/websocket/controllers/index.js +31 -0
- package/dist/websocket/controllers/rest.d.ts +9 -0
- package/dist/websocket/controllers/rest.js +47 -0
- package/dist/websocket/errors.d.ts +16 -0
- package/dist/websocket/errors.js +55 -0
- package/dist/websocket/handlers/heartbeat.d.ts +11 -0
- package/dist/websocket/handlers/heartbeat.js +72 -0
- package/dist/websocket/handlers/index.d.ts +4 -0
- package/dist/websocket/handlers/index.js +11 -0
- package/dist/websocket/handlers/items.d.ts +6 -0
- package/dist/websocket/handlers/items.js +103 -0
- package/dist/websocket/handlers/subscribe.d.ts +43 -0
- package/dist/websocket/handlers/subscribe.js +278 -0
- package/dist/websocket/messages.d.ts +311 -0
- package/dist/websocket/messages.js +96 -0
- package/dist/websocket/types.d.ts +34 -0
- package/dist/websocket/types.js +1 -0
- package/dist/websocket/utils/get-expires-at-for-token.d.ts +1 -0
- package/dist/websocket/utils/get-expires-at-for-token.js +8 -0
- package/dist/websocket/utils/message.d.ts +4 -0
- package/dist/websocket/utils/message.js +27 -0
- package/dist/websocket/utils/wait-for-message.d.ts +4 -0
- package/dist/websocket/utils/wait-for-message.js +45 -0
- package/package.json +21 -16
- package/dist/exceptions/content-too-large.d.ts +0 -4
- package/dist/exceptions/content-too-large.js +0 -6
- package/dist/exceptions/database/contains-null-values.d.ts +0 -9
- package/dist/exceptions/database/contains-null-values.js +0 -6
- package/dist/exceptions/database/invalid-foreign-key.d.ts +0 -10
- package/dist/exceptions/database/invalid-foreign-key.js +0 -11
- package/dist/exceptions/database/not-null-violation.d.ts +0 -9
- package/dist/exceptions/database/not-null-violation.js +0 -6
- package/dist/exceptions/database/record-not-unique.d.ts +0 -10
- package/dist/exceptions/database/record-not-unique.js +0 -11
- package/dist/exceptions/database/value-out-of-range.d.ts +0 -10
- package/dist/exceptions/database/value-out-of-range.js +0 -11
- package/dist/exceptions/database/value-too-long.d.ts +0 -9
- package/dist/exceptions/database/value-too-long.js +0 -11
- package/dist/exceptions/forbidden.d.ts +0 -6
- package/dist/exceptions/forbidden.js +0 -13
- package/dist/exceptions/graphql-validation.d.ts +0 -4
- package/dist/exceptions/graphql-validation.js +0 -6
- package/dist/exceptions/hit-rate-limit.d.ts +0 -9
- package/dist/exceptions/hit-rate-limit.js +0 -6
- package/dist/exceptions/illegal-asset-transformation.d.ts +0 -4
- package/dist/exceptions/illegal-asset-transformation.js +0 -6
- package/dist/exceptions/index.d.ts +0 -21
- package/dist/exceptions/index.js +0 -21
- package/dist/exceptions/invalid-config.d.ts +0 -4
- package/dist/exceptions/invalid-config.js +0 -6
- package/dist/exceptions/invalid-credentials.d.ts +0 -4
- package/dist/exceptions/invalid-credentials.js +0 -6
- package/dist/exceptions/invalid-ip.d.ts +0 -4
- package/dist/exceptions/invalid-ip.js +0 -6
- package/dist/exceptions/invalid-otp.d.ts +0 -4
- package/dist/exceptions/invalid-otp.js +0 -6
- package/dist/exceptions/invalid-payload.d.ts +0 -4
- package/dist/exceptions/invalid-payload.js +0 -6
- package/dist/exceptions/invalid-provider.d.ts +0 -4
- package/dist/exceptions/invalid-provider.js +0 -6
- package/dist/exceptions/invalid-query.d.ts +0 -4
- package/dist/exceptions/invalid-query.js +0 -6
- package/dist/exceptions/invalid-token.d.ts +0 -4
- package/dist/exceptions/invalid-token.js +0 -6
- package/dist/exceptions/method-not-allowed.d.ts +0 -8
- package/dist/exceptions/method-not-allowed.js +0 -6
- package/dist/exceptions/range-not-satisfiable.d.ts +0 -5
- package/dist/exceptions/range-not-satisfiable.js +0 -9
- package/dist/exceptions/route-not-found.d.ts +0 -4
- package/dist/exceptions/route-not-found.js +0 -6
- package/dist/exceptions/service-unavailable.d.ts +0 -9
- package/dist/exceptions/service-unavailable.js +0 -6
- package/dist/exceptions/token-expired.d.ts +0 -4
- package/dist/exceptions/token-expired.js +0 -6
- package/dist/exceptions/unexpected-response.d.ts +0 -4
- package/dist/exceptions/unexpected-response.js +0 -6
- package/dist/exceptions/unprocessable-entity.d.ts +0 -4
- package/dist/exceptions/unprocessable-entity.js +0 -6
- package/dist/exceptions/unsupported-media-type.d.ts +0 -4
- package/dist/exceptions/unsupported-media-type.js +0 -6
- package/dist/exceptions/user-suspended.d.ts +0 -4
- package/dist/exceptions/user-suspended.js +0 -6
- /package/dist/{exceptions/database → database/errors}/dialects/mssql.d.ts +0 -0
- /package/dist/{exceptions/database → database/errors}/dialects/mysql.d.ts +0 -0
- /package/dist/{exceptions/database → database/errors}/dialects/oracle.d.ts +0 -0
- /package/dist/{exceptions/database → database/errors}/dialects/postgres.d.ts +0 -0
- /package/dist/{exceptions/database → database/errors}/dialects/sqlite.d.ts +0 -0
- /package/dist/{exceptions/database → database/errors}/dialects/types.d.ts +0 -0
- /package/dist/{exceptions/database → database/errors}/dialects/types.js +0 -0
- /package/dist/{exceptions/database → database/errors}/translate.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ContentTooLargeError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ForbiddenError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface HitRateLimitErrorExtensions {
|
|
2
|
+
limit: number;
|
|
3
|
+
reset: Date;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: (extensions: HitRateLimitErrorExtensions) => string;
|
|
6
|
+
export declare const HitRateLimitError: import("@directus/errors").DirectusErrorConstructor<HitRateLimitErrorExtensions>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import ms from 'ms';
|
|
3
|
+
import { ErrorCode } from './codes.js';
|
|
4
|
+
export const messageConstructor = (extensions) => {
|
|
5
|
+
const msBeforeNext = extensions.reset.getTime() - Date.now();
|
|
6
|
+
return `Too many requests, retry after ${ms(msBeforeNext)}.`;
|
|
7
|
+
};
|
|
8
|
+
export const HitRateLimitError = createError(ErrorCode.RequestsExceeded, messageConstructor, 429);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { ErrorCode } from './codes.js';
|
|
2
|
+
export { ContainsNullValuesError } from './contains-null-values.js';
|
|
3
|
+
export { ContentTooLargeError } from './content-too-large.js';
|
|
4
|
+
export { ForbiddenError } from './forbidden.js';
|
|
5
|
+
export { HitRateLimitError } from './hit-rate-limit.js';
|
|
6
|
+
export { IllegalAssetTransformationError } from './illegal-asset-transformation.js';
|
|
7
|
+
export { InvalidCredentialsError } from './invalid-credentials.js';
|
|
8
|
+
export { InvalidForeignKeyError } from './invalid-foreign-key.js';
|
|
9
|
+
export { InvalidIpError } from './invalid-ip.js';
|
|
10
|
+
export { InvalidOtpError } from './invalid-otp.js';
|
|
11
|
+
export { InvalidPayloadError } from './invalid-payload.js';
|
|
12
|
+
export { InvalidProviderError } from './invalid-provider.js';
|
|
13
|
+
export { InvalidProviderConfigError } from './invalid-provider-config.js';
|
|
14
|
+
export { InvalidQueryError } from './invalid-query.js';
|
|
15
|
+
export { InvalidTokenError } from './invalid-token.js';
|
|
16
|
+
export { MethodNotAllowedError } from './method-not-allowed.js';
|
|
17
|
+
export { NotNullViolationError } from './not-null-violation.js';
|
|
18
|
+
export { RangeNotSatisfiableError } from './range-not-satisfiable.js';
|
|
19
|
+
export { RecordNotUniqueError } from './record-not-unique.js';
|
|
20
|
+
export { RouteNotFoundError } from './route-not-found.js';
|
|
21
|
+
export { ServiceUnavailableError } from './service-unavailable.js';
|
|
22
|
+
export { TokenExpiredError } from './token-expired.js';
|
|
23
|
+
export { UnexpectedResponseError } from './unexpected-response.js';
|
|
24
|
+
export { UnprocessableContentError } from './unprocessable-content.js';
|
|
25
|
+
export { UnsupportedMediaTypeError } from './unsupported-media-type.js';
|
|
26
|
+
export { UserSuspendedError } from './user-suspended.js';
|
|
27
|
+
export { ValueOutOfRangeError } from './value-out-of-range.js';
|
|
28
|
+
export { ValueTooLongError } from './value-too-long.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { ErrorCode } from './codes.js';
|
|
2
|
+
export { ContainsNullValuesError } from './contains-null-values.js';
|
|
3
|
+
export { ContentTooLargeError } from './content-too-large.js';
|
|
4
|
+
export { ForbiddenError } from './forbidden.js';
|
|
5
|
+
export { HitRateLimitError } from './hit-rate-limit.js';
|
|
6
|
+
export { IllegalAssetTransformationError } from './illegal-asset-transformation.js';
|
|
7
|
+
export { InvalidCredentialsError } from './invalid-credentials.js';
|
|
8
|
+
export { InvalidForeignKeyError } from './invalid-foreign-key.js';
|
|
9
|
+
export { InvalidIpError } from './invalid-ip.js';
|
|
10
|
+
export { InvalidOtpError } from './invalid-otp.js';
|
|
11
|
+
export { InvalidPayloadError } from './invalid-payload.js';
|
|
12
|
+
export { InvalidProviderError } from './invalid-provider.js';
|
|
13
|
+
export { InvalidProviderConfigError } from './invalid-provider-config.js';
|
|
14
|
+
export { InvalidQueryError } from './invalid-query.js';
|
|
15
|
+
export { InvalidTokenError } from './invalid-token.js';
|
|
16
|
+
export { MethodNotAllowedError } from './method-not-allowed.js';
|
|
17
|
+
export { NotNullViolationError } from './not-null-violation.js';
|
|
18
|
+
export { RangeNotSatisfiableError } from './range-not-satisfiable.js';
|
|
19
|
+
export { RecordNotUniqueError } from './record-not-unique.js';
|
|
20
|
+
export { RouteNotFoundError } from './route-not-found.js';
|
|
21
|
+
export { ServiceUnavailableError } from './service-unavailable.js';
|
|
22
|
+
export { TokenExpiredError } from './token-expired.js';
|
|
23
|
+
export { UnexpectedResponseError } from './unexpected-response.js';
|
|
24
|
+
export { UnprocessableContentError } from './unprocessable-content.js';
|
|
25
|
+
export { UnsupportedMediaTypeError } from './unsupported-media-type.js';
|
|
26
|
+
export { UserSuspendedError } from './user-suspended.js';
|
|
27
|
+
export { ValueOutOfRangeError } from './value-out-of-range.js';
|
|
28
|
+
export { ValueTooLongError } from './value-too-long.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InvalidCredentialsError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface InvalidForeignKeyErrorExtensions {
|
|
2
|
+
collection: string | null;
|
|
3
|
+
field: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ collection, field }: InvalidForeignKeyErrorExtensions) => string;
|
|
6
|
+
export declare const InvalidForeignKeyError: import("@directus/errors").DirectusErrorConstructor<InvalidForeignKeyErrorExtensions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ collection, field }) => {
|
|
4
|
+
let message = 'Invalid foreign key';
|
|
5
|
+
if (field) {
|
|
6
|
+
message += ` for field "${field}"`;
|
|
7
|
+
}
|
|
8
|
+
if (collection) {
|
|
9
|
+
message += ` in collection "${collection}"`;
|
|
10
|
+
}
|
|
11
|
+
message += `.`;
|
|
12
|
+
return message;
|
|
13
|
+
};
|
|
14
|
+
export const InvalidForeignKeyError = createError(ErrorCode.InvalidForeignKey, messageConstructor, 400);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InvalidIpError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InvalidOtpError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface InvalidPayloadErrorExtensions {
|
|
2
|
+
reason: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const messageConstructor: ({ reason }: InvalidPayloadErrorExtensions) => string;
|
|
5
|
+
export declare const InvalidPayloadError: import("@directus/errors").DirectusErrorConstructor<InvalidPayloadErrorExtensions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InvalidProviderError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface InvalidQueryErrorExtensions {
|
|
2
|
+
reason: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const messageConstructor: ({ reason }: InvalidQueryErrorExtensions) => string;
|
|
5
|
+
export declare const InvalidQueryError: import("@directus/errors").DirectusErrorConstructor<InvalidQueryErrorExtensions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InvalidTokenError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface MethodNotAllowedErrorExtensions {
|
|
2
|
+
allowed: string[];
|
|
3
|
+
current: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: (extensions: MethodNotAllowedErrorExtensions) => string;
|
|
6
|
+
export declare const MethodNotAllowedError: import("@directus/errors").DirectusErrorConstructor<MethodNotAllowedErrorExtensions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = (extensions) => `Invalid method "${extensions.current}" used. Should be one of ${extensions.allowed
|
|
4
|
+
.map((method) => `"${method}"`)
|
|
5
|
+
.join(', ')}.`;
|
|
6
|
+
export const MethodNotAllowedError = createError(ErrorCode.MethodNotAllowed, messageConstructor, 405);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface NotNullViolationErrorExtensions {
|
|
2
|
+
collection: string | null;
|
|
3
|
+
field: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ collection, field }: NotNullViolationErrorExtensions) => string;
|
|
6
|
+
export declare const NotNullViolationError: import("@directus/errors").DirectusErrorConstructor<NotNullViolationErrorExtensions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ collection, field }) => {
|
|
4
|
+
let message = 'Value ';
|
|
5
|
+
if (field) {
|
|
6
|
+
message += `for field "${field}" `;
|
|
7
|
+
}
|
|
8
|
+
if (collection) {
|
|
9
|
+
message += `in collection "${collection}" `;
|
|
10
|
+
}
|
|
11
|
+
message += `can't be null.`;
|
|
12
|
+
return message;
|
|
13
|
+
};
|
|
14
|
+
export const NotNullViolationError = createError(ErrorCode.NotNullViolation, messageConstructor, 400);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Range } from '@directus/storage';
|
|
2
|
+
interface RangeNotSatisfiableErrorExtensions {
|
|
3
|
+
range: Range;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ range }: RangeNotSatisfiableErrorExtensions) => string;
|
|
6
|
+
export declare const RangeNotSatisfiableError: import("@directus/errors").DirectusErrorConstructor<RangeNotSatisfiableErrorExtensions>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ range }) => {
|
|
4
|
+
const rangeString = `"${range.start ?? ''}-${range.end ?? ''}"`;
|
|
5
|
+
return `Range ${rangeString} is invalid or the file's size doesn't match the requested range.`;
|
|
6
|
+
};
|
|
7
|
+
export const RangeNotSatisfiableError = createError(ErrorCode.RangeNotSatisfiable, messageConstructor, 416);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface RecordNotUniqueErrorExtensions {
|
|
2
|
+
collection: string | null;
|
|
3
|
+
field: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ collection, field }: RecordNotUniqueErrorExtensions) => string;
|
|
6
|
+
export declare const RecordNotUniqueError: import("@directus/errors").DirectusErrorConstructor<RecordNotUniqueErrorExtensions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ collection, field }) => {
|
|
4
|
+
let message = 'Value ';
|
|
5
|
+
if (field) {
|
|
6
|
+
message += `for field "${field}" `;
|
|
7
|
+
}
|
|
8
|
+
if (collection) {
|
|
9
|
+
message += `in collection "${collection}" `;
|
|
10
|
+
}
|
|
11
|
+
message += `has to be unique.`;
|
|
12
|
+
return message;
|
|
13
|
+
};
|
|
14
|
+
export const RecordNotUniqueError = createError(ErrorCode.RecordNotUnique, messageConstructor, 400);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface RouteNotFoundErrorExtensions {
|
|
2
|
+
path: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const messageConstructor: ({ path }: RouteNotFoundErrorExtensions) => string;
|
|
5
|
+
export declare const RouteNotFoundError: import("@directus/errors").DirectusErrorConstructor<RouteNotFoundErrorExtensions>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface ServiceUnavailableErrorExtensions {
|
|
2
|
+
service: string;
|
|
3
|
+
reason: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ service, reason }: ServiceUnavailableErrorExtensions) => string;
|
|
6
|
+
export declare const ServiceUnavailableError: import("@directus/errors").DirectusErrorConstructor<ServiceUnavailableErrorExtensions>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ service, reason }) => `Service "${service}" is unavailable. ${reason}.`;
|
|
4
|
+
export const ServiceUnavailableError = createError(ErrorCode.ServiceUnavailable, messageConstructor, 503);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TokenExpiredError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UnexpectedResponseError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
const messageConstructor = (extensions) => `Can't process content. ${extensions.reason}.`;
|
|
4
|
+
export const UnprocessableContentError = createError(ErrorCode.UnprocessableContent, messageConstructor, 422);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface UnsupportedMediaTypeErrorExtensions {
|
|
2
|
+
mediaType: string;
|
|
3
|
+
where: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: (extensions: UnsupportedMediaTypeErrorExtensions) => string;
|
|
6
|
+
export declare const UnsupportedMediaTypeError: import("@directus/errors").DirectusErrorConstructor<UnsupportedMediaTypeErrorExtensions>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = (extensions) => `Unsupported media type "${extensions.mediaType}" in ${extensions.where}.`;
|
|
4
|
+
export const UnsupportedMediaTypeError = createError(ErrorCode.UnsupportedMediaType, messageConstructor, 415);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UserSuspendedError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ValueOutOfRangeErrorExtensions {
|
|
2
|
+
collection: string | null;
|
|
3
|
+
field: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ collection, field }: ValueOutOfRangeErrorExtensions) => string;
|
|
6
|
+
export declare const ValueOutOfRangeError: import("@directus/errors").DirectusErrorConstructor<ValueOutOfRangeErrorExtensions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ collection, field }) => {
|
|
4
|
+
let message = 'Numeric value ';
|
|
5
|
+
if (field) {
|
|
6
|
+
message += `for field "${field}" `;
|
|
7
|
+
}
|
|
8
|
+
if (collection) {
|
|
9
|
+
message += `in collection "${collection}" `;
|
|
10
|
+
}
|
|
11
|
+
message += `is out of range.`;
|
|
12
|
+
return message;
|
|
13
|
+
};
|
|
14
|
+
export const ValueOutOfRangeError = createError(ErrorCode.ValueOutOfRange, messageConstructor, 400);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ValueTooLongErrorExtensions {
|
|
2
|
+
collection: string | null;
|
|
3
|
+
field: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const messageConstructor: ({ collection, field }: ValueTooLongErrorExtensions) => string;
|
|
6
|
+
export declare const ValueTooLongError: import("@directus/errors").DirectusErrorConstructor<ValueTooLongErrorExtensions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createError } from '@directus/errors';
|
|
2
|
+
import { ErrorCode } from './codes.js';
|
|
3
|
+
export const messageConstructor = ({ collection, field }) => {
|
|
4
|
+
let message = 'Value ';
|
|
5
|
+
if (field) {
|
|
6
|
+
message += `for field "${field}" `;
|
|
7
|
+
}
|
|
8
|
+
if (collection) {
|
|
9
|
+
message += `in collection "${collection}" `;
|
|
10
|
+
}
|
|
11
|
+
message += `is too long.`;
|
|
12
|
+
return message;
|
|
13
|
+
};
|
|
14
|
+
export const ValueTooLongError = createError(ErrorCode.ValueTooLong, messageConstructor, 400);
|
package/dist/extensions.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { APP_EXTENSION_TYPES, APP_SHARED_DEPS, HYBRID_EXTENSION_TYPES, JAVASCRIPT_FILE_EXTS, NESTED_EXTENSION_TYPES, } from '@directus/constants';
|
|
2
|
-
import * as sharedExceptions from '@directus/exceptions';
|
|
3
2
|
import { isIn, isTypeIn, pluralize } from '@directus/utils';
|
|
4
3
|
import { ensureExtensionDirs, generateExtensionsEntrypoint, getLocalExtensions, getPackageExtensions, pathToRelativeUrl, resolvePackage, resolvePackageExtensions, } from '@directus/utils/node';
|
|
5
4
|
import aliasDefault from '@rollup/plugin-alias';
|
|
@@ -17,7 +16,6 @@ import { rollup } from 'rollup';
|
|
|
17
16
|
import getDatabase from './database/index.js';
|
|
18
17
|
import emitter, { Emitter } from './emitter.js';
|
|
19
18
|
import env from './env.js';
|
|
20
|
-
import * as exceptions from './exceptions/index.js';
|
|
21
19
|
import { getFlowManager } from './flows.js';
|
|
22
20
|
import logger from './logger.js';
|
|
23
21
|
import * as services from './services/index.js';
|
|
@@ -435,7 +433,6 @@ class ExtensionManager {
|
|
|
435
433
|
};
|
|
436
434
|
register(registerFunctions, {
|
|
437
435
|
services,
|
|
438
|
-
exceptions: { ...exceptions, ...sharedExceptions },
|
|
439
436
|
env,
|
|
440
437
|
database: getDatabase(),
|
|
441
438
|
emitter: this.apiEmitter,
|
|
@@ -450,7 +447,6 @@ class ExtensionManager {
|
|
|
450
447
|
this.endpointRouter.use(`/${routeName}`, scopedRouter);
|
|
451
448
|
register(scopedRouter, {
|
|
452
449
|
services,
|
|
453
|
-
exceptions: { ...exceptions, ...sharedExceptions },
|
|
454
450
|
env,
|
|
455
451
|
database: getDatabase(),
|
|
456
452
|
emitter: this.apiEmitter,
|
package/dist/flows.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Action, REDACTED_TEXT } from '@directus/constants';
|
|
2
|
-
import * as sharedExceptions from '@directus/exceptions';
|
|
3
2
|
import { applyOptionsData, isValidJSON, parseJSON, toArray } from '@directus/utils';
|
|
4
3
|
import { omit, pick } from 'lodash-es';
|
|
5
4
|
import { get } from 'micromustache';
|
|
6
5
|
import getDatabase from './database/index.js';
|
|
7
6
|
import emitter from './emitter.js';
|
|
8
7
|
import env from './env.js';
|
|
9
|
-
import
|
|
8
|
+
import { ForbiddenError } from './errors/index.js';
|
|
10
9
|
import logger from './logger.js';
|
|
11
10
|
import { getMessenger } from './messenger.js';
|
|
12
11
|
import { ActivityService } from './services/activity.js';
|
|
@@ -82,7 +81,7 @@ class FlowManager {
|
|
|
82
81
|
async runWebhookFlow(id, data, context) {
|
|
83
82
|
if (!(id in this.webhookFlowHandlers)) {
|
|
84
83
|
logger.warn(`Couldn't find webhook or manual triggered flow with id "${id}"`);
|
|
85
|
-
throw new
|
|
84
|
+
throw new ForbiddenError();
|
|
86
85
|
}
|
|
87
86
|
const handler = this.webhookFlowHandlers[id];
|
|
88
87
|
return handler(data, context);
|
|
@@ -186,15 +185,15 @@ class FlowManager {
|
|
|
186
185
|
const targetCollection = data?.['body'].collection;
|
|
187
186
|
if (!targetCollection) {
|
|
188
187
|
logger.warn(`Manual trigger requires "collection" to be specified in the payload`);
|
|
189
|
-
throw new
|
|
188
|
+
throw new ForbiddenError();
|
|
190
189
|
}
|
|
191
190
|
if (enabledCollections.length === 0) {
|
|
192
191
|
logger.warn(`There is no collections configured for this manual trigger`);
|
|
193
|
-
throw new
|
|
192
|
+
throw new ForbiddenError();
|
|
194
193
|
}
|
|
195
194
|
if (!enabledCollections.includes(targetCollection)) {
|
|
196
195
|
logger.warn(`Specified collection must be one of: ${enabledCollections.join(', ')}.`);
|
|
197
|
-
throw new
|
|
196
|
+
throw new ForbiddenError();
|
|
198
197
|
}
|
|
199
198
|
if (flow.options['async']) {
|
|
200
199
|
this.executeFlow(flow, data, context);
|
|
@@ -310,7 +309,6 @@ class FlowManager {
|
|
|
310
309
|
try {
|
|
311
310
|
let result = await handler(options, {
|
|
312
311
|
services,
|
|
313
|
-
exceptions: { ...exceptions, ...sharedExceptions },
|
|
314
312
|
env,
|
|
315
313
|
database: getDatabase(),
|
|
316
314
|
logger,
|
|
@@ -331,7 +329,7 @@ class FlowManager {
|
|
|
331
329
|
catch (error) {
|
|
332
330
|
let data;
|
|
333
331
|
if (error instanceof Error) {
|
|
334
|
-
// make sure we
|
|
332
|
+
// make sure we don't expose the stack trace
|
|
335
333
|
data = sanitizeError(error);
|
|
336
334
|
}
|
|
337
335
|
else if (typeof error === 'string') {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/messenger.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ export type MessengerSubscriptionCallback = (payload: Record<string, any>) => vo
|
|
|
3
3
|
export interface Messenger {
|
|
4
4
|
publish: (channel: string, payload: Record<string, any>) => void;
|
|
5
5
|
subscribe: (channel: string, callback: MessengerSubscriptionCallback) => void;
|
|
6
|
-
unsubscribe: (channel: string) => void;
|
|
6
|
+
unsubscribe: (channel: string, callback?: MessengerSubscriptionCallback) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare class MessengerMemory implements Messenger {
|
|
9
|
-
handlers: Record<string, MessengerSubscriptionCallback
|
|
9
|
+
handlers: Record<string, Set<MessengerSubscriptionCallback>>;
|
|
10
10
|
constructor();
|
|
11
11
|
publish(channel: string, payload: Record<string, any>): void;
|
|
12
12
|
subscribe(channel: string, callback: MessengerSubscriptionCallback): void;
|
|
13
|
-
unsubscribe(channel: string): void;
|
|
13
|
+
unsubscribe(channel: string, callback?: MessengerSubscriptionCallback): void;
|
|
14
14
|
}
|
|
15
15
|
export declare class MessengerRedis implements Messenger {
|
|
16
16
|
namespace: string;
|
package/dist/messenger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseJSON } from '@directus/utils';
|
|
2
2
|
import { Redis } from 'ioredis';
|
|
3
|
-
import
|
|
3
|
+
import { getEnv } from './env.js';
|
|
4
4
|
import { getConfigFromEnv } from './utils/get-config-from-env.js';
|
|
5
5
|
export class MessengerMemory {
|
|
6
6
|
handlers;
|
|
@@ -8,13 +8,20 @@ export class MessengerMemory {
|
|
|
8
8
|
this.handlers = {};
|
|
9
9
|
}
|
|
10
10
|
publish(channel, payload) {
|
|
11
|
-
this.handlers[channel]?.(payload);
|
|
11
|
+
this.handlers[channel]?.forEach((callback) => callback(payload));
|
|
12
12
|
}
|
|
13
13
|
subscribe(channel, callback) {
|
|
14
|
-
this.handlers[channel]
|
|
14
|
+
if (!this.handlers[channel])
|
|
15
|
+
this.handlers[channel] = new Set();
|
|
16
|
+
this.handlers[channel]?.add(callback);
|
|
15
17
|
}
|
|
16
|
-
unsubscribe(channel) {
|
|
17
|
-
|
|
18
|
+
unsubscribe(channel, callback) {
|
|
19
|
+
if (!callback) {
|
|
20
|
+
delete this.handlers[channel];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.handlers[channel]?.delete(callback);
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
export class MessengerRedis {
|
|
@@ -22,10 +29,11 @@ export class MessengerRedis {
|
|
|
22
29
|
pub;
|
|
23
30
|
sub;
|
|
24
31
|
constructor() {
|
|
25
|
-
const config = getConfigFromEnv('
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
32
|
+
const config = getConfigFromEnv('REDIS');
|
|
33
|
+
const env = getEnv();
|
|
34
|
+
this.pub = new Redis(env['REDIS'] ?? config);
|
|
35
|
+
this.sub = new Redis(env['REDIS'] ?? config);
|
|
36
|
+
this.namespace = env['MESSENGER_NAMESPACE'] ?? 'directus-messenger';
|
|
29
37
|
}
|
|
30
38
|
publish(channel, payload) {
|
|
31
39
|
this.pub.publish(`${this.namespace}:${channel}`, JSON.stringify(payload));
|
|
@@ -47,6 +55,7 @@ let messenger;
|
|
|
47
55
|
export function getMessenger() {
|
|
48
56
|
if (messenger)
|
|
49
57
|
return messenger;
|
|
58
|
+
const env = getEnv();
|
|
50
59
|
if (env['MESSENGER_STORE'] === 'redis') {
|
|
51
60
|
messenger = new MessengerRedis();
|
|
52
61
|
}
|