@directus/api 13.1.1 → 14.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/__utils__/snapshots.js +9 -0
- package/dist/app.js +6 -4
- package/dist/auth/drivers/ldap.js +3 -2
- package/dist/auth/drivers/local.js +1 -1
- package/dist/auth/drivers/oauth2.js +1 -1
- package/dist/auth/drivers/openid.js +1 -1
- package/dist/auth/drivers/saml.js +1 -1
- package/dist/auth.js +1 -1
- package/dist/cli/index.js +7 -4
- package/dist/controllers/activity.js +1 -1
- package/dist/controllers/assets.js +2 -2
- package/dist/controllers/auth.js +1 -1
- package/dist/controllers/collections.js +1 -1
- package/dist/controllers/dashboards.js +1 -1
- package/dist/controllers/extensions.js +29 -16
- package/dist/controllers/fields.js +1 -1
- package/dist/controllers/files.js +1 -1
- package/dist/controllers/flows.js +1 -1
- package/dist/controllers/folders.js +1 -1
- package/dist/controllers/items.js +1 -1
- package/dist/controllers/not-found.js +1 -1
- package/dist/controllers/notifications.js +1 -1
- package/dist/controllers/operations.js +1 -1
- package/dist/controllers/panels.js +1 -1
- package/dist/controllers/permissions.js +1 -1
- package/dist/controllers/presets.js +1 -1
- package/dist/controllers/relations.js +1 -1
- package/dist/controllers/roles.js +1 -1
- package/dist/controllers/schema.js +1 -1
- package/dist/controllers/server.js +1 -1
- package/dist/controllers/settings.js +1 -1
- package/dist/controllers/shares.js +1 -1
- package/dist/controllers/translations.js +1 -1
- package/dist/controllers/users.js +1 -1
- package/dist/controllers/utils.js +37 -18
- package/dist/controllers/versions.d.ts +2 -0
- package/dist/controllers/versions.js +188 -0
- package/dist/controllers/webhooks.js +1 -1
- package/dist/database/errors/dialects/mssql.js +1 -1
- package/dist/database/errors/dialects/mysql.js +1 -1
- package/dist/database/errors/dialects/oracle.js +1 -1
- package/dist/database/errors/dialects/postgres.js +1 -1
- package/dist/database/errors/dialects/sqlite.js +1 -1
- package/dist/database/helpers/schema/dialects/mysql.js +1 -1
- package/dist/database/helpers/sequence/dialects/postgres.d.ts +5 -2
- package/dist/database/helpers/sequence/dialects/postgres.js +6 -3
- package/dist/database/migrations/20230823A-add-content-versioning.d.ts +3 -0
- package/dist/database/migrations/20230823A-add-content-versioning.js +36 -0
- package/dist/database/migrations/20230927A-themes.d.ts +3 -0
- package/dist/database/migrations/20230927A-themes.js +49 -0
- package/dist/database/migrations/20231009A-update-csv-fields-to-text.d.ts +3 -0
- package/dist/database/migrations/20231009A-update-csv-fields-to-text.js +44 -0
- package/dist/database/migrations/20231009B-update-panel-options.d.ts +3 -0
- package/dist/database/migrations/20231009B-update-panel-options.js +77 -0
- package/dist/database/migrations/20231010A-add-extensions.d.ts +3 -0
- package/dist/database/migrations/20231010A-add-extensions.js +9 -0
- package/dist/database/run-ast.js +2 -2
- package/dist/database/seeds/run.js +1 -1
- package/dist/database/system-data/collections/collections.yaml +6 -0
- package/dist/database/system-data/fields/activity.yaml +4 -4
- package/dist/database/system-data/fields/collections.yaml +19 -0
- package/dist/database/system-data/fields/extensions.yaml +10 -0
- package/dist/database/system-data/fields/revisions.yaml +3 -0
- package/dist/database/system-data/fields/settings.yaml +73 -17
- package/dist/database/system-data/fields/users.yaml +48 -12
- package/dist/database/system-data/fields/versions.yaml +38 -0
- package/dist/database/system-data/fields/webhooks.yaml +9 -9
- package/dist/database/system-data/relations/relations.yaml +88 -20
- package/dist/env.js +4 -0
- package/dist/extensions/index.d.ts +2 -0
- package/dist/extensions/index.js +9 -0
- package/dist/extensions/lib/get-extensions-settings.d.ts +7 -0
- package/dist/extensions/lib/get-extensions-settings.js +39 -0
- package/dist/extensions/lib/get-extensions.d.ts +1 -0
- package/dist/extensions/lib/get-extensions.js +11 -0
- package/dist/extensions/lib/get-shared-deps-mapping.d.ts +1 -0
- package/dist/extensions/lib/get-shared-deps-mapping.js +26 -0
- package/dist/extensions/lib/sandbox/generate-api-extensions-sandbox-entrypoint.d.ts +31 -0
- package/dist/extensions/lib/sandbox/generate-api-extensions-sandbox-entrypoint.js +80 -0
- package/dist/extensions/lib/sandbox/generate-host-function-reference.d.ts +11 -0
- package/dist/extensions/lib/sandbox/generate-host-function-reference.js +28 -0
- package/dist/extensions/lib/sandbox/register/action.d.ts +6 -0
- package/dist/extensions/lib/sandbox/register/action.js +18 -0
- package/dist/extensions/lib/sandbox/register/call-reference.d.ts +5 -0
- package/dist/extensions/lib/sandbox/register/call-reference.js +20 -0
- package/dist/extensions/lib/sandbox/register/filter.d.ts +6 -0
- package/dist/extensions/lib/sandbox/register/filter.js +21 -0
- package/dist/extensions/lib/sandbox/register/index.d.ts +5 -0
- package/dist/extensions/lib/sandbox/register/index.js +5 -0
- package/dist/extensions/lib/sandbox/register/operation.d.ts +6 -0
- package/dist/extensions/lib/sandbox/register/operation.js +19 -0
- package/dist/extensions/lib/sandbox/register/route.d.ts +17 -0
- package/dist/extensions/lib/sandbox/register/route.js +44 -0
- package/dist/extensions/lib/sandbox/sdk/generators/index.d.ts +3 -0
- package/dist/extensions/lib/sandbox/sdk/generators/index.js +3 -0
- package/dist/extensions/lib/sandbox/sdk/generators/log.d.ts +3 -0
- package/dist/extensions/lib/sandbox/sdk/generators/log.js +11 -0
- package/dist/extensions/lib/sandbox/sdk/generators/request.d.ts +12 -0
- package/dist/extensions/lib/sandbox/sdk/generators/request.js +49 -0
- package/dist/extensions/lib/sandbox/sdk/generators/sleep.d.ts +3 -0
- package/dist/extensions/lib/sandbox/sdk/generators/sleep.js +11 -0
- package/dist/extensions/lib/sandbox/sdk/index.d.ts +2 -0
- package/dist/extensions/lib/sandbox/sdk/index.js +2 -0
- package/dist/extensions/lib/sandbox/sdk/instantiate.d.ts +11 -0
- package/dist/extensions/lib/sandbox/sdk/instantiate.js +28 -0
- package/dist/extensions/lib/sandbox/sdk/sdk.d.ts +20 -0
- package/dist/extensions/lib/sandbox/sdk/sdk.js +11 -0
- package/dist/extensions/lib/sandbox/sdk/utils/index.d.ts +1 -0
- package/dist/extensions/lib/sandbox/sdk/utils/index.js +1 -0
- package/dist/extensions/lib/sandbox/sdk/utils/wrap.d.ts +11 -0
- package/dist/extensions/lib/sandbox/sdk/utils/wrap.js +17 -0
- package/dist/extensions/lib/wrap-embeds.d.ts +4 -0
- package/dist/extensions/lib/wrap-embeds.js +8 -0
- package/dist/extensions/manager.d.ts +158 -0
- package/dist/extensions/manager.js +604 -0
- package/dist/extensions/types.d.ts +19 -0
- package/dist/flows.d.ts +2 -2
- package/dist/flows.js +7 -7
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/collection-exists.js +1 -1
- package/dist/middleware/error-handler.js +1 -1
- package/dist/middleware/graphql.js +1 -1
- package/dist/middleware/rate-limiter-global.js +1 -1
- package/dist/middleware/rate-limiter-ip.js +1 -1
- package/dist/middleware/respond.js +13 -1
- package/dist/middleware/validate-batch.js +1 -1
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/condition/index.js +2 -1
- package/dist/operations/exec/index.d.ts +1 -1
- package/dist/operations/exec/index.js +1 -1
- package/dist/operations/item-create/index.d.ts +1 -1
- package/dist/operations/item-create/index.js +2 -1
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-delete/index.js +2 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-read/index.js +2 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/item-update/index.js +2 -1
- package/dist/operations/json-web-token/index.d.ts +1 -1
- package/dist/operations/json-web-token/index.js +2 -1
- package/dist/operations/log/index.d.ts +1 -1
- package/dist/operations/log/index.js +2 -1
- package/dist/operations/mail/index.d.ts +1 -1
- package/dist/operations/mail/index.js +1 -1
- package/dist/operations/notification/index.d.ts +1 -1
- package/dist/operations/notification/index.js +2 -1
- package/dist/operations/request/index.d.ts +1 -1
- package/dist/operations/request/index.js +3 -2
- package/dist/operations/sleep/index.d.ts +1 -1
- package/dist/operations/sleep/index.js +1 -1
- package/dist/operations/transform/index.d.ts +1 -1
- package/dist/operations/transform/index.js +2 -1
- package/dist/operations/trigger/index.d.ts +1 -1
- package/dist/operations/trigger/index.js +2 -1
- package/dist/services/activity.js +1 -1
- package/dist/services/assets.d.ts +1 -1
- package/dist/services/assets.js +3 -3
- package/dist/services/authentication.js +2 -2
- package/dist/services/authorization.js +1 -1
- package/dist/services/collections.js +3 -3
- package/dist/services/extensions.d.ts +31 -0
- package/dist/services/extensions.js +121 -0
- package/dist/services/fields.d.ts +2 -2
- package/dist/services/fields.js +4 -4
- package/dist/services/files.d.ts +4 -1
- package/dist/services/files.js +5 -5
- package/dist/services/graphql/index.d.ts +1 -1
- package/dist/services/graphql/index.js +87 -24
- package/dist/services/graphql/subscription.js +3 -3
- package/dist/services/import-export/import-worker.d.ts +9 -0
- package/dist/services/import-export/import-worker.js +9 -0
- package/dist/services/{import-export.d.ts → import-export/index.d.ts} +2 -2
- package/dist/services/{import-export.js → import-export/index.js} +51 -42
- package/dist/services/index.d.ts +3 -1
- package/dist/services/index.js +3 -1
- package/dist/services/items.js +2 -2
- package/dist/services/mail/index.js +1 -1
- package/dist/services/meta.js +1 -1
- package/dist/services/payload.js +1 -1
- package/dist/services/permissions.d.ts +2 -2
- package/dist/services/permissions.js +1 -1
- package/dist/services/relations.js +1 -1
- package/dist/services/revisions.js +1 -1
- package/dist/services/roles.js +1 -1
- package/dist/services/schema.js +1 -1
- package/dist/services/server.js +3 -1
- package/dist/services/shares.js +1 -1
- package/dist/services/tfa.js +1 -1
- package/dist/services/translations.js +1 -1
- package/dist/services/users.js +4 -2
- package/dist/services/utils.d.ts +1 -0
- package/dist/services/utils.js +8 -2
- package/dist/services/versions.d.ts +21 -0
- package/dist/services/versions.js +232 -0
- package/dist/services/websocket.js +11 -1
- package/dist/types/collection.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/utils/apply-query.d.ts +1 -1
- package/dist/utils/apply-query.js +31 -3
- package/dist/utils/delete-from-require-cache.d.ts +1 -0
- package/dist/utils/delete-from-require-cache.js +5 -0
- package/dist/utils/get-accountability-for-token.js +1 -1
- package/dist/utils/get-ast-from-query.js +1 -1
- package/dist/utils/get-column-path.js +1 -1
- package/dist/utils/get-column.js +1 -1
- package/dist/utils/get-default-value.d.ts +1 -2
- package/dist/utils/get-permissions.js +1 -1
- package/dist/utils/get-service.js +3 -1
- package/dist/utils/import-file-url.d.ts +5 -0
- package/dist/utils/import-file-url.js +6 -0
- package/dist/utils/job-queue.d.ts +2 -3
- package/dist/utils/jwt.js +1 -1
- package/dist/utils/redact-object.js +9 -3
- package/dist/utils/sanitize-query.js +3 -0
- package/dist/utils/transformations.d.ts +2 -1
- package/dist/utils/validate-diff.js +1 -1
- package/dist/utils/validate-keys.js +1 -1
- package/dist/utils/validate-query.js +2 -1
- package/dist/utils/validate-snapshot.js +1 -1
- package/dist/websocket/controllers/base.js +1 -1
- package/dist/websocket/controllers/index.d.ts +1 -1
- package/dist/websocket/controllers/index.js +0 -7
- package/dist/websocket/handlers/heartbeat.js +6 -1
- package/dist/websocket/handlers/subscribe.js +11 -16
- package/dist/websocket/utils/items.d.ts +4 -14
- package/dist/websocket/utils/items.js +59 -64
- package/dist/worker-pool.d.ts +2 -0
- package/dist/worker-pool.js +11 -0
- package/package.json +34 -31
- package/dist/errors/codes.d.ts +0 -29
- package/dist/errors/codes.js +0 -30
- package/dist/errors/contains-null-values.d.ts +0 -7
- package/dist/errors/contains-null-values.js +0 -4
- package/dist/errors/content-too-large.d.ts +0 -1
- package/dist/errors/content-too-large.js +0 -3
- package/dist/errors/forbidden.d.ts +0 -1
- package/dist/errors/forbidden.js +0 -3
- package/dist/errors/hit-rate-limit.d.ts +0 -6
- package/dist/errors/hit-rate-limit.js +0 -8
- package/dist/errors/illegal-asset-transformation.d.ts +0 -4
- package/dist/errors/illegal-asset-transformation.js +0 -3
- package/dist/errors/index.d.ts +0 -28
- package/dist/errors/index.js +0 -28
- package/dist/errors/invalid-credentials.d.ts +0 -1
- package/dist/errors/invalid-credentials.js +0 -3
- package/dist/errors/invalid-foreign-key.d.ts +0 -6
- package/dist/errors/invalid-foreign-key.js +0 -14
- package/dist/errors/invalid-ip.d.ts +0 -1
- package/dist/errors/invalid-ip.js +0 -3
- package/dist/errors/invalid-otp.d.ts +0 -1
- package/dist/errors/invalid-otp.js +0 -3
- package/dist/errors/invalid-payload.d.ts +0 -5
- package/dist/errors/invalid-payload.js +0 -4
- package/dist/errors/invalid-provider-config.d.ts +0 -5
- package/dist/errors/invalid-provider-config.js +0 -3
- package/dist/errors/invalid-provider.d.ts +0 -1
- package/dist/errors/invalid-provider.js +0 -3
- package/dist/errors/invalid-query.d.ts +0 -5
- package/dist/errors/invalid-query.js +0 -4
- package/dist/errors/invalid-token.d.ts +0 -1
- package/dist/errors/invalid-token.js +0 -3
- package/dist/errors/method-not-allowed.d.ts +0 -6
- package/dist/errors/method-not-allowed.js +0 -6
- package/dist/errors/not-null-violation.d.ts +0 -6
- package/dist/errors/not-null-violation.js +0 -14
- package/dist/errors/range-not-satisfiable.d.ts +0 -7
- package/dist/errors/range-not-satisfiable.js +0 -7
- package/dist/errors/record-not-unique.d.ts +0 -6
- package/dist/errors/record-not-unique.js +0 -14
- package/dist/errors/route-not-found.d.ts +0 -5
- package/dist/errors/route-not-found.js +0 -4
- package/dist/errors/service-unavailable.d.ts +0 -7
- package/dist/errors/service-unavailable.js +0 -4
- package/dist/errors/token-expired.d.ts +0 -1
- package/dist/errors/token-expired.js +0 -3
- package/dist/errors/unexpected-response.d.ts +0 -1
- package/dist/errors/unexpected-response.js +0 -3
- package/dist/errors/unprocessable-content.d.ts +0 -5
- package/dist/errors/unprocessable-content.js +0 -4
- package/dist/errors/unsupported-media-type.d.ts +0 -6
- package/dist/errors/unsupported-media-type.js +0 -4
- package/dist/errors/user-suspended.d.ts +0 -1
- package/dist/errors/user-suspended.js +0 -3
- package/dist/errors/value-out-of-range.d.ts +0 -6
- package/dist/errors/value-out-of-range.js +0 -14
- package/dist/errors/value-too-long.d.ts +0 -6
- package/dist/errors/value-too-long.js +0 -14
- package/dist/extensions.d.ts +0 -51
- package/dist/extensions.js +0 -487
- package/dist/types/files.d.ts +0 -29
- /package/dist/{types/files.js → extensions/types.js} +0 -0
|
@@ -5,7 +5,7 @@ import WebSocket, { WebSocketServer } from 'ws';
|
|
|
5
5
|
import { fromZodError } from 'zod-validation-error';
|
|
6
6
|
import emitter from '../../emitter.js';
|
|
7
7
|
import env from '../../env.js';
|
|
8
|
-
import { InvalidProviderConfigError, TokenExpiredError } from '
|
|
8
|
+
import { InvalidProviderConfigError, TokenExpiredError } from '@directus/errors';
|
|
9
9
|
import logger from '../../logger.js';
|
|
10
10
|
import { createRateLimiter } from '../../rate-limiter.js';
|
|
11
11
|
import { getAccountabilityForToken } from '../../utils/get-accountability-for-token.js';
|
|
@@ -3,7 +3,7 @@ import type { Server as httpServer } from 'http';
|
|
|
3
3
|
import { GraphQLSubscriptionController } from './graphql.js';
|
|
4
4
|
import { WebSocketController } from './rest.js';
|
|
5
5
|
export declare function createWebSocketController(server: httpServer): void;
|
|
6
|
-
export declare function getWebSocketController(): WebSocketController;
|
|
6
|
+
export declare function getWebSocketController(): WebSocketController | undefined;
|
|
7
7
|
export declare function createSubscriptionController(server: httpServer): void;
|
|
8
8
|
export declare function getSubscriptionController(): GraphQLSubscriptionController | undefined;
|
|
9
9
|
export * from './graphql.js';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import env from '../../env.js';
|
|
2
|
-
import { ServiceUnavailableError } from '../../errors/index.js';
|
|
3
2
|
import { toBoolean } from '../../utils/to-boolean.js';
|
|
4
3
|
import { GraphQLSubscriptionController } from './graphql.js';
|
|
5
4
|
import { WebSocketController } from './rest.js';
|
|
@@ -11,12 +10,6 @@ export function createWebSocketController(server) {
|
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
export function getWebSocketController() {
|
|
14
|
-
if (!toBoolean(env['WEBSOCKETS_ENABLED']) || !toBoolean(env['WEBSOCKETS_REST_ENABLED'])) {
|
|
15
|
-
throw new ServiceUnavailableError({ service: 'ws', reason: 'WebSocket server is disabled' });
|
|
16
|
-
}
|
|
17
|
-
if (!websocketController) {
|
|
18
|
-
throw new ServiceUnavailableError({ service: 'ws', reason: 'WebSocket server is not initialized' });
|
|
19
|
-
}
|
|
20
13
|
return websocketController;
|
|
21
14
|
}
|
|
22
15
|
export function createSubscriptionController(server) {
|
|
@@ -4,12 +4,17 @@ import { toBoolean } from '../../utils/to-boolean.js';
|
|
|
4
4
|
import { WebSocketController, getWebSocketController } from '../controllers/index.js';
|
|
5
5
|
import { WebSocketMessage } from '../messages.js';
|
|
6
6
|
import { fmtMessage, getMessageType } from '../utils/message.js';
|
|
7
|
+
import { ServiceUnavailableError } from '@directus/errors';
|
|
7
8
|
const HEARTBEAT_FREQUENCY = Number(env['WEBSOCKETS_HEARTBEAT_PERIOD']) * 1000;
|
|
8
9
|
export class HeartbeatHandler {
|
|
9
10
|
pulse;
|
|
10
11
|
controller;
|
|
11
12
|
constructor(controller) {
|
|
12
|
-
|
|
13
|
+
controller = controller ?? getWebSocketController();
|
|
14
|
+
if (!controller) {
|
|
15
|
+
throw new ServiceUnavailableError({ service: 'ws', reason: 'WebSocket server is not initialized' });
|
|
16
|
+
}
|
|
17
|
+
this.controller = controller;
|
|
13
18
|
emitter.onAction('websocket.message', ({ client, message }) => {
|
|
14
19
|
try {
|
|
15
20
|
this.onMessage(client, WebSocketMessage.parse(message));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import emitter from '../../emitter.js';
|
|
2
|
-
import { InvalidPayloadError } from '
|
|
2
|
+
import { InvalidPayloadError } from '@directus/errors';
|
|
3
3
|
import { getMessenger } from '../../messenger.js';
|
|
4
4
|
import { getSchema } from '../../utils/get-schema.js';
|
|
5
5
|
import { sanitizeQuery } from '../../utils/sanitize-query.js';
|
|
@@ -7,7 +7,7 @@ import { refreshAccountability } from '../authenticate.js';
|
|
|
7
7
|
import { WebSocketError, handleWebSocketError } from '../errors.js';
|
|
8
8
|
import { WebSocketSubscribeMessage } from '../messages.js';
|
|
9
9
|
import { fmtMessage, getMessageType } from '../utils/message.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getPayload } from '../utils/items.js';
|
|
11
11
|
/**
|
|
12
12
|
* Handler responsible for subscriptions
|
|
13
13
|
*/
|
|
@@ -104,13 +104,17 @@ export class SubscribeHandler {
|
|
|
104
104
|
if (subscription.event !== undefined && event.action !== subscription.event) {
|
|
105
105
|
continue; // skip filtered events
|
|
106
106
|
}
|
|
107
|
+
if ('item' in subscription) {
|
|
108
|
+
if ('keys' in event && !event.keys.includes(subscription.item))
|
|
109
|
+
continue;
|
|
110
|
+
if ('key' in event && event.key !== subscription.item)
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
107
113
|
try {
|
|
108
114
|
client.accountability = await refreshAccountability(client.accountability);
|
|
109
|
-
const result =
|
|
110
|
-
? await getSinglePayload(subscription, client.accountability, schema, event)
|
|
111
|
-
: await getMultiPayload(subscription, client.accountability, schema, event);
|
|
115
|
+
const result = await getPayload(subscription, client.accountability, schema, event);
|
|
112
116
|
if (Array.isArray(result?.['data']) && result?.['data']?.length === 0)
|
|
113
|
-
|
|
117
|
+
continue;
|
|
114
118
|
client.send(fmtMessage('subscription', result, subscription.uid));
|
|
115
119
|
}
|
|
116
120
|
catch (err) {
|
|
@@ -147,16 +151,7 @@ export class SubscribeHandler {
|
|
|
147
151
|
// remove the subscription if it already exists
|
|
148
152
|
this.unsubscribe(client, subscription.uid);
|
|
149
153
|
}
|
|
150
|
-
|
|
151
|
-
if (subscription.event === undefined) {
|
|
152
|
-
data =
|
|
153
|
-
'item' in subscription
|
|
154
|
-
? await getSinglePayload(subscription, accountability, schema)
|
|
155
|
-
: await getMultiPayload(subscription, accountability, schema);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
data = { event: 'init' };
|
|
159
|
-
}
|
|
154
|
+
const data = subscription.event === undefined ? await getPayload(subscription, accountability, schema) : { event: 'init' };
|
|
160
155
|
// if no errors were thrown register the subscription
|
|
161
156
|
this.subscribe(subscription);
|
|
162
157
|
// send an initial response
|
|
@@ -2,16 +2,6 @@ import type { Accountability, SchemaOverview } from '@directus/types';
|
|
|
2
2
|
import type { WebSocketEvent } from '../messages.js';
|
|
3
3
|
import type { Subscription } from '../types.js';
|
|
4
4
|
type PSubscription = Omit<Subscription, 'client'>;
|
|
5
|
-
/**
|
|
6
|
-
* Get a single item from a collection using the appropriate service
|
|
7
|
-
*
|
|
8
|
-
* @param subscription Subscription object
|
|
9
|
-
* @param accountability Accountability object
|
|
10
|
-
* @param schema Schema object
|
|
11
|
-
* @param event Event data
|
|
12
|
-
* @returns the fetched item
|
|
13
|
-
*/
|
|
14
|
-
export declare function getSinglePayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<Record<string, any>>;
|
|
15
5
|
/**
|
|
16
6
|
* Get items from a collection using the appropriate service
|
|
17
7
|
*
|
|
@@ -21,7 +11,7 @@ export declare function getSinglePayload(subscription: PSubscription, accountabi
|
|
|
21
11
|
* @param event Event data
|
|
22
12
|
* @returns the fetched items
|
|
23
13
|
*/
|
|
24
|
-
export declare function
|
|
14
|
+
export declare function getPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<Record<string, any>>;
|
|
25
15
|
/**
|
|
26
16
|
* Get collection items
|
|
27
17
|
*
|
|
@@ -30,7 +20,7 @@ export declare function getMultiPayload(subscription: PSubscription, accountabil
|
|
|
30
20
|
* @param event Event data
|
|
31
21
|
* @returns the fetched collection data
|
|
32
22
|
*/
|
|
33
|
-
export declare function getCollectionPayload(accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<(string | number)[] | import("../../types/collection.js").Collection[]>;
|
|
23
|
+
export declare function getCollectionPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | import("../../types/collection.js").Collection | (string | number)[] | import("../../types/collection.js").Collection[]>;
|
|
34
24
|
/**
|
|
35
25
|
* Get fields items
|
|
36
26
|
*
|
|
@@ -39,7 +29,7 @@ export declare function getCollectionPayload(accountability: Accountability | nu
|
|
|
39
29
|
* @param event Event data
|
|
40
30
|
* @returns the fetched field data
|
|
41
31
|
*/
|
|
42
|
-
export declare function getFieldsPayload(accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<Record<string, any> | import("@directus/types").Field[] | (string | number)[]>;
|
|
32
|
+
export declare function getFieldsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | Record<string, any> | import("@directus/types").Field[] | (string | number)[]>;
|
|
43
33
|
/**
|
|
44
34
|
* Get items from a collection using the appropriate service
|
|
45
35
|
*
|
|
@@ -49,5 +39,5 @@ export declare function getFieldsPayload(accountability: Accountability | null,
|
|
|
49
39
|
* @param event Event data
|
|
50
40
|
* @returns the fetched data
|
|
51
41
|
*/
|
|
52
|
-
export declare function getItemsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<(string | number)[] | import("../../types/items.js").Item[]>;
|
|
42
|
+
export declare function getItemsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | import("../../types/items.js").Item | (string | number)[] | import("../../types/items.js").Item[]>;
|
|
53
43
|
export {};
|
|
@@ -1,34 +1,5 @@
|
|
|
1
1
|
import { getService } from '../../utils/get-service.js';
|
|
2
2
|
import { CollectionsService, FieldsService, MetaService } from '../../services/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Get a single item from a collection using the appropriate service
|
|
5
|
-
*
|
|
6
|
-
* @param subscription Subscription object
|
|
7
|
-
* @param accountability Accountability object
|
|
8
|
-
* @param schema Schema object
|
|
9
|
-
* @param event Event data
|
|
10
|
-
* @returns the fetched item
|
|
11
|
-
*/
|
|
12
|
-
export async function getSinglePayload(subscription, accountability, schema, event) {
|
|
13
|
-
const metaService = new MetaService({ schema, accountability });
|
|
14
|
-
const query = subscription.query ?? {};
|
|
15
|
-
const id = subscription.item;
|
|
16
|
-
const result = {
|
|
17
|
-
event: event?.action ?? 'init',
|
|
18
|
-
};
|
|
19
|
-
if (subscription.collection === 'directus_collections') {
|
|
20
|
-
const service = new CollectionsService({ schema, accountability });
|
|
21
|
-
result['data'] = await service.readOne(String(id));
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
const service = getService(subscription.collection, { schema, accountability });
|
|
25
|
-
result['data'] = await service.readOne(id, query);
|
|
26
|
-
}
|
|
27
|
-
if ('meta' in query) {
|
|
28
|
-
result['meta'] = await metaService.getMetaForQuery(subscription.collection, query);
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
3
|
/**
|
|
33
4
|
* Get items from a collection using the appropriate service
|
|
34
5
|
*
|
|
@@ -38,17 +9,17 @@ export async function getSinglePayload(subscription, accountability, schema, eve
|
|
|
38
9
|
* @param event Event data
|
|
39
10
|
* @returns the fetched items
|
|
40
11
|
*/
|
|
41
|
-
export async function
|
|
12
|
+
export async function getPayload(subscription, accountability, schema, event) {
|
|
42
13
|
const metaService = new MetaService({ schema, accountability });
|
|
43
14
|
const result = {
|
|
44
15
|
event: event?.action ?? 'init',
|
|
45
16
|
};
|
|
46
17
|
switch (subscription.collection) {
|
|
47
18
|
case 'directus_collections':
|
|
48
|
-
result['data'] = await getCollectionPayload(accountability, schema, event);
|
|
19
|
+
result['data'] = await getCollectionPayload(subscription, accountability, schema, event);
|
|
49
20
|
break;
|
|
50
21
|
case 'directus_fields':
|
|
51
|
-
result['data'] = await getFieldsPayload(accountability, schema, event);
|
|
22
|
+
result['data'] = await getFieldsPayload(subscription, accountability, schema, event);
|
|
52
23
|
break;
|
|
53
24
|
case 'directus_relations':
|
|
54
25
|
result['data'] = event?.payload;
|
|
@@ -71,19 +42,27 @@ export async function getMultiPayload(subscription, accountability, schema, even
|
|
|
71
42
|
* @param event Event data
|
|
72
43
|
* @returns the fetched collection data
|
|
73
44
|
*/
|
|
74
|
-
export async function getCollectionPayload(accountability, schema, event) {
|
|
45
|
+
export async function getCollectionPayload(subscription, accountability, schema, event) {
|
|
75
46
|
const service = new CollectionsService({ schema, accountability });
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
47
|
+
if ('item' in subscription) {
|
|
48
|
+
if (event?.action === 'delete') {
|
|
49
|
+
// return only the subscribed id in case a bulk delete was done
|
|
50
|
+
return subscription.item;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return await service.readOne(String(subscription.item));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
switch (event?.action) {
|
|
57
|
+
case 'create':
|
|
58
|
+
return await service.readMany([String(event.key)]);
|
|
59
|
+
case 'update':
|
|
60
|
+
return await service.readMany(event.keys.map((key) => String(key)));
|
|
61
|
+
case 'delete':
|
|
62
|
+
return event.keys;
|
|
63
|
+
case undefined:
|
|
64
|
+
default:
|
|
65
|
+
return await service.readByQuery();
|
|
87
66
|
}
|
|
88
67
|
}
|
|
89
68
|
/**
|
|
@@ -94,16 +73,24 @@ export async function getCollectionPayload(accountability, schema, event) {
|
|
|
94
73
|
* @param event Event data
|
|
95
74
|
* @returns the fetched field data
|
|
96
75
|
*/
|
|
97
|
-
export async function getFieldsPayload(accountability, schema, event) {
|
|
76
|
+
export async function getFieldsPayload(subscription, accountability, schema, event) {
|
|
98
77
|
const service = new FieldsService({ schema, accountability });
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
78
|
+
if ('item' in subscription) {
|
|
79
|
+
if (event?.action === 'delete') {
|
|
80
|
+
// return only the subscribed id in case a bluk delete was done
|
|
81
|
+
return subscription.item;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return await service.readOne(subscription.collection, String(subscription.item));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
switch (event?.action) {
|
|
88
|
+
case undefined:
|
|
89
|
+
return await service.readAll();
|
|
90
|
+
case 'delete':
|
|
91
|
+
return event.keys;
|
|
92
|
+
default:
|
|
93
|
+
return await service.readOne(event?.payload?.['collection'], event?.payload?.['field']);
|
|
107
94
|
}
|
|
108
95
|
}
|
|
109
96
|
/**
|
|
@@ -118,16 +105,24 @@ export async function getFieldsPayload(accountability, schema, event) {
|
|
|
118
105
|
export async function getItemsPayload(subscription, accountability, schema, event) {
|
|
119
106
|
const query = subscription.query ?? {};
|
|
120
107
|
const service = getService(subscription.collection, { schema, accountability });
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
108
|
+
if ('item' in subscription) {
|
|
109
|
+
if (event?.action === 'delete') {
|
|
110
|
+
// return only the subscribed id in case a bluk delete was done
|
|
111
|
+
return subscription.item;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return await service.readOne(subscription.item, query);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
switch (event?.action) {
|
|
118
|
+
case 'create':
|
|
119
|
+
return await service.readMany([event.key], query);
|
|
120
|
+
case 'update':
|
|
121
|
+
return await service.readMany(event.keys, query);
|
|
122
|
+
case 'delete':
|
|
123
|
+
return event.keys;
|
|
124
|
+
case undefined:
|
|
125
|
+
default:
|
|
126
|
+
return await service.readByQuery(query);
|
|
132
127
|
}
|
|
133
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@authenio/samlify-node-xmllint": "2.0.0",
|
|
62
62
|
"@aws-sdk/client-ses": "3.332.0",
|
|
63
|
-
"@directus/format-title": "10.
|
|
63
|
+
"@directus/format-title": "10.1.0",
|
|
64
64
|
"@godaddy/terminus": "4.12.0",
|
|
65
65
|
"@rollup/plugin-alias": "5.0.0",
|
|
66
66
|
"@rollup/plugin-node-resolve": "15.0.2",
|
|
67
67
|
"@rollup/plugin-virtual": "3.0.1",
|
|
68
|
-
"argon2": "0.
|
|
68
|
+
"argon2": "0.31.1",
|
|
69
69
|
"async": "3.2.4",
|
|
70
70
|
"axios": "1.4.0",
|
|
71
71
|
"busboy": "1.6.0",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"cookie-parser": "1.4.6",
|
|
79
79
|
"cors": "2.8.5",
|
|
80
80
|
"cron-parser": "4.8.1",
|
|
81
|
-
"csv-parser": "3.0.0",
|
|
82
81
|
"date-fns": "2.30.0",
|
|
83
82
|
"deep-diff": "1.0.2",
|
|
84
83
|
"destroy": "1.2.0",
|
|
@@ -90,9 +89,10 @@
|
|
|
90
89
|
"express": "4.18.2",
|
|
91
90
|
"flat": "5.0.2",
|
|
92
91
|
"fs-extra": "11.1.1",
|
|
93
|
-
"
|
|
92
|
+
"glob-to-regexp": "0.4.1",
|
|
93
|
+
"graphql": "16.8.1",
|
|
94
94
|
"graphql-compose": "9.0.10",
|
|
95
|
-
"graphql-ws": "5.
|
|
95
|
+
"graphql-ws": "5.14.1",
|
|
96
96
|
"helmet": "7.0.0",
|
|
97
97
|
"icc": "3.0.0",
|
|
98
98
|
"inquirer": "9.2.4",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"openid-client": "5.4.2",
|
|
123
123
|
"ora": "6.3.1",
|
|
124
124
|
"otplib": "12.0.1",
|
|
125
|
+
"papaparse": "5.4.1",
|
|
125
126
|
"pino": "8.14.1",
|
|
126
127
|
"pino-http": "8.3.3",
|
|
127
128
|
"pino-http-print": "3.1.0",
|
|
@@ -131,34 +132,35 @@
|
|
|
131
132
|
"rollup": "3.22.0",
|
|
132
133
|
"samlify": "2.8.10",
|
|
133
134
|
"sanitize-html": "2.10.0",
|
|
134
|
-
"sharp": "0.32.
|
|
135
|
+
"sharp": "0.32.6",
|
|
135
136
|
"snappy": "7.2.2",
|
|
136
137
|
"stream-json": "1.7.5",
|
|
137
138
|
"strip-bom-stream": "5.0.0",
|
|
138
|
-
"
|
|
139
|
+
"tinypool": "0.8.1",
|
|
139
140
|
"tsx": "3.12.7",
|
|
140
141
|
"uuid": "9.0.0",
|
|
141
142
|
"uuid-validate": "0.0.3",
|
|
142
143
|
"wellknown": "0.5.0",
|
|
143
|
-
"ws": "8.
|
|
144
|
-
"zod": "3.
|
|
144
|
+
"ws": "8.14.2",
|
|
145
|
+
"zod": "3.22.4",
|
|
145
146
|
"zod-validation-error": "1.0.1",
|
|
146
|
-
"@directus/app": "10.
|
|
147
|
-
"@directus/constants": "
|
|
148
|
-
"@directus/errors": "0.0
|
|
149
|
-
"@directus/extensions
|
|
150
|
-
"@directus/
|
|
151
|
-
"@directus/
|
|
147
|
+
"@directus/app": "10.10.0",
|
|
148
|
+
"@directus/constants": "11.0.1",
|
|
149
|
+
"@directus/errors": "0.2.0",
|
|
150
|
+
"@directus/extensions": "0.1.0",
|
|
151
|
+
"@directus/extensions-sdk": "10.1.13",
|
|
152
|
+
"@directus/pressure": "1.0.12",
|
|
153
|
+
"@directus/schema": "11.0.0",
|
|
152
154
|
"@directus/specs": "10.2.0",
|
|
153
|
-
"@directus/storage": "10.0.
|
|
154
|
-
"@directus/storage-driver-azure": "10.0.
|
|
155
|
-
"@directus/storage-driver-cloudinary": "10.0.
|
|
156
|
-
"@directus/storage-driver-gcs": "10.0.
|
|
157
|
-
"@directus/storage-driver-local": "10.0.
|
|
158
|
-
"@directus/storage-driver-s3": "10.0.
|
|
159
|
-
"@directus/storage-driver-supabase": "1.0.
|
|
160
|
-
"@directus/utils": "
|
|
161
|
-
"@directus/validation": "0.0.
|
|
155
|
+
"@directus/storage": "10.0.7",
|
|
156
|
+
"@directus/storage-driver-azure": "10.0.13",
|
|
157
|
+
"@directus/storage-driver-cloudinary": "10.0.13",
|
|
158
|
+
"@directus/storage-driver-gcs": "10.0.13",
|
|
159
|
+
"@directus/storage-driver-local": "10.0.13",
|
|
160
|
+
"@directus/storage-driver-s3": "10.0.13",
|
|
161
|
+
"@directus/storage-driver-supabase": "1.0.5",
|
|
162
|
+
"@directus/utils": "11.0.1",
|
|
163
|
+
"@directus/validation": "0.0.8"
|
|
162
164
|
},
|
|
163
165
|
"devDependencies": {
|
|
164
166
|
"@ngneat/falso": "6.4.0",
|
|
@@ -176,11 +178,11 @@
|
|
|
176
178
|
"@types/express-serve-static-core": "4.17.35",
|
|
177
179
|
"@types/flat": "5.0.2",
|
|
178
180
|
"@types/fs-extra": "11.0.1",
|
|
181
|
+
"@types/glob-to-regexp": "0.4.3",
|
|
179
182
|
"@types/inquirer": "9.0.3",
|
|
180
183
|
"@types/js-yaml": "4.0.5",
|
|
181
184
|
"@types/json2csv": "5.0.3",
|
|
182
185
|
"@types/jsonwebtoken": "9.0.2",
|
|
183
|
-
"@types/keyv": "4.2.0",
|
|
184
186
|
"@types/ldapjs": "2.2.5",
|
|
185
187
|
"@types/lodash-es": "4.17.7",
|
|
186
188
|
"@types/marked": "4.3.0",
|
|
@@ -190,6 +192,7 @@
|
|
|
190
192
|
"@types/node-schedule": "2.1.0",
|
|
191
193
|
"@types/nodemailer": "6.4.7",
|
|
192
194
|
"@types/object-hash": "3.0.2",
|
|
195
|
+
"@types/papaparse": "5.3.9",
|
|
193
196
|
"@types/qs": "6.9.7",
|
|
194
197
|
"@types/sanitize-html": "2.9.0",
|
|
195
198
|
"@types/stream-json": "1.7.3",
|
|
@@ -197,17 +200,17 @@
|
|
|
197
200
|
"@types/uuid": "9.0.1",
|
|
198
201
|
"@types/uuid-validate": "0.0.1",
|
|
199
202
|
"@types/wellknown": "0.5.4",
|
|
200
|
-
"@types/ws": "8.5.
|
|
203
|
+
"@types/ws": "8.5.8",
|
|
201
204
|
"@vitest/coverage-c8": "0.31.1",
|
|
202
205
|
"copyfiles": "2.4.1",
|
|
203
206
|
"form-data": "4.0.0",
|
|
204
207
|
"knex-mock-client": "2.0.0",
|
|
205
208
|
"supertest": "6.3.3",
|
|
206
|
-
"typescript": "5.
|
|
209
|
+
"typescript": "5.2.2",
|
|
207
210
|
"vitest": "0.31.1",
|
|
208
|
-
"@directus/random": "0.2.
|
|
209
|
-
"@directus/tsconfig": "1.0.
|
|
210
|
-
"@directus/types": "
|
|
211
|
+
"@directus/random": "0.2.3",
|
|
212
|
+
"@directus/tsconfig": "1.0.1",
|
|
213
|
+
"@directus/types": "11.0.1"
|
|
211
214
|
},
|
|
212
215
|
"optionalDependencies": {
|
|
213
216
|
"@keyv/redis": "2.5.8",
|
package/dist/errors/codes.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare enum ErrorCode {
|
|
2
|
-
ContainsNullValues = "CONTAINS_NULL_VALUES",
|
|
3
|
-
ContentTooLarge = "CONTENT_TOO_LARGE",
|
|
4
|
-
Forbidden = "FORBIDDEN",
|
|
5
|
-
IllegalAssetTransformation = "ILLEGAL_ASSET_TRANSFORMATION",
|
|
6
|
-
InvalidCredentials = "INVALID_CREDENTIALS",
|
|
7
|
-
InvalidForeignKey = "INVALID_FOREIGN_KEY",
|
|
8
|
-
InvalidIp = "INVALID_IP",
|
|
9
|
-
InvalidOtp = "INVALID_OTP",
|
|
10
|
-
InvalidPayload = "INVALID_PAYLOAD",
|
|
11
|
-
InvalidProvider = "INVALID_PROVIDER",
|
|
12
|
-
InvalidProviderConfig = "INVALID_PROVIDER_CONFIG",
|
|
13
|
-
InvalidQuery = "INVALID_QUERY",
|
|
14
|
-
InvalidToken = "INVALID_TOKEN",
|
|
15
|
-
MethodNotAllowed = "METHOD_NOT_ALLOWED",
|
|
16
|
-
NotNullViolation = "NOT_NULL_VIOLATION",
|
|
17
|
-
RangeNotSatisfiable = "RANGE_NOT_SATISFIABLE",
|
|
18
|
-
RecordNotUnique = "RECORD_NOT_UNIQUE",
|
|
19
|
-
RequestsExceeded = "REQUESTS_EXCEEDED",
|
|
20
|
-
RouteNotFound = "ROUTE_NOT_FOUND",
|
|
21
|
-
ServiceUnavailable = "SERVICE_UNAVAILABLE",
|
|
22
|
-
TokenExpired = "TOKEN_EXPIRED",
|
|
23
|
-
UnexpectedResponse = "UNEXPECTED_RESPONSE",
|
|
24
|
-
UnprocessableContent = "UNPROCESSABLE_CONTENT",
|
|
25
|
-
UnsupportedMediaType = "UNSUPPORTED_MEDIA_TYPE",
|
|
26
|
-
UserSuspended = "USER_SUSPENDED",
|
|
27
|
-
ValueOutOfRange = "VALUE_OUT_OF_RANGE",
|
|
28
|
-
ValueTooLong = "VALUE_TOO_LONG"
|
|
29
|
-
}
|
package/dist/errors/codes.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export var ErrorCode;
|
|
2
|
-
(function (ErrorCode) {
|
|
3
|
-
ErrorCode["ContainsNullValues"] = "CONTAINS_NULL_VALUES";
|
|
4
|
-
ErrorCode["ContentTooLarge"] = "CONTENT_TOO_LARGE";
|
|
5
|
-
ErrorCode["Forbidden"] = "FORBIDDEN";
|
|
6
|
-
ErrorCode["IllegalAssetTransformation"] = "ILLEGAL_ASSET_TRANSFORMATION";
|
|
7
|
-
ErrorCode["InvalidCredentials"] = "INVALID_CREDENTIALS";
|
|
8
|
-
ErrorCode["InvalidForeignKey"] = "INVALID_FOREIGN_KEY";
|
|
9
|
-
ErrorCode["InvalidIp"] = "INVALID_IP";
|
|
10
|
-
ErrorCode["InvalidOtp"] = "INVALID_OTP";
|
|
11
|
-
ErrorCode["InvalidPayload"] = "INVALID_PAYLOAD";
|
|
12
|
-
ErrorCode["InvalidProvider"] = "INVALID_PROVIDER";
|
|
13
|
-
ErrorCode["InvalidProviderConfig"] = "INVALID_PROVIDER_CONFIG";
|
|
14
|
-
ErrorCode["InvalidQuery"] = "INVALID_QUERY";
|
|
15
|
-
ErrorCode["InvalidToken"] = "INVALID_TOKEN";
|
|
16
|
-
ErrorCode["MethodNotAllowed"] = "METHOD_NOT_ALLOWED";
|
|
17
|
-
ErrorCode["NotNullViolation"] = "NOT_NULL_VIOLATION";
|
|
18
|
-
ErrorCode["RangeNotSatisfiable"] = "RANGE_NOT_SATISFIABLE";
|
|
19
|
-
ErrorCode["RecordNotUnique"] = "RECORD_NOT_UNIQUE";
|
|
20
|
-
ErrorCode["RequestsExceeded"] = "REQUESTS_EXCEEDED";
|
|
21
|
-
ErrorCode["RouteNotFound"] = "ROUTE_NOT_FOUND";
|
|
22
|
-
ErrorCode["ServiceUnavailable"] = "SERVICE_UNAVAILABLE";
|
|
23
|
-
ErrorCode["TokenExpired"] = "TOKEN_EXPIRED";
|
|
24
|
-
ErrorCode["UnexpectedResponse"] = "UNEXPECTED_RESPONSE";
|
|
25
|
-
ErrorCode["UnprocessableContent"] = "UNPROCESSABLE_CONTENT";
|
|
26
|
-
ErrorCode["UnsupportedMediaType"] = "UNSUPPORTED_MEDIA_TYPE";
|
|
27
|
-
ErrorCode["UserSuspended"] = "USER_SUSPENDED";
|
|
28
|
-
ErrorCode["ValueOutOfRange"] = "VALUE_OUT_OF_RANGE";
|
|
29
|
-
ErrorCode["ValueTooLong"] = "VALUE_TOO_LONG";
|
|
30
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
interface ContainsNullValuesErrorExtensions {
|
|
2
|
-
collection: string;
|
|
3
|
-
field: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const messageConstructor: ({ collection, field }: ContainsNullValuesErrorExtensions) => string;
|
|
6
|
-
export declare const ContainsNullValuesError: import("@directus/errors").DirectusErrorConstructor<ContainsNullValuesErrorExtensions>;
|
|
7
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createError } from '@directus/errors';
|
|
2
|
-
import { ErrorCode } from './codes.js';
|
|
3
|
-
export const messageConstructor = ({ collection, field }) => `Field "${field}" in collection "${collection}" contains null values.`;
|
|
4
|
-
export const ContainsNullValuesError = createError(ErrorCode.ContainsNullValues, messageConstructor, 400);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ContentTooLargeError: import("@directus/errors").DirectusErrorConstructor<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ForbiddenError: import("@directus/errors").DirectusErrorConstructor<void>;
|
package/dist/errors/forbidden.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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>;
|
|
@@ -1,8 +0,0 @@
|
|
|
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);
|