@directus/api 32.2.0 → 33.1.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/ai/chat/controllers/chat.post.js +19 -4
- package/dist/ai/chat/lib/create-ui-stream.d.ts +8 -7
- package/dist/ai/chat/lib/create-ui-stream.js +28 -25
- package/dist/ai/chat/middleware/load-settings.js +31 -7
- package/dist/ai/chat/models/chat-request.d.ts +135 -2
- package/dist/ai/chat/models/chat-request.js +56 -2
- package/dist/ai/chat/models/providers.d.ts +16 -2
- package/dist/ai/chat/models/providers.js +16 -2
- package/dist/ai/chat/utils/chat-request-tool-to-ai-sdk-tool.js +3 -4
- package/dist/ai/chat/utils/format-context.d.ts +5 -0
- package/dist/ai/chat/utils/format-context.js +122 -0
- package/dist/ai/mcp/server.d.ts +27 -1
- package/dist/ai/providers/index.d.ts +3 -0
- package/dist/ai/providers/index.js +3 -0
- package/dist/ai/providers/options.d.ts +14 -0
- package/dist/ai/providers/options.js +26 -0
- package/dist/ai/providers/registry.d.ts +6 -0
- package/dist/ai/providers/registry.js +65 -0
- package/dist/ai/providers/types.d.ts +34 -0
- package/dist/ai/providers/types.js +1 -0
- package/dist/ai/tools/assets/index.js +1 -1
- package/dist/ai/tools/collections/index.js +2 -2
- package/dist/ai/tools/fields/index.js +2 -2
- package/dist/ai/tools/files/index.js +1 -1
- package/dist/ai/tools/flows/index.js +1 -1
- package/dist/ai/tools/folders/index.js +1 -1
- package/dist/ai/tools/items/index.js +6 -3
- package/dist/ai/tools/items/prompt.md +7 -9
- package/dist/ai/tools/relations/index.js +1 -1
- package/dist/ai/tools/schema.js +1 -1
- package/dist/ai/tools/trigger-flow/index.js +1 -1
- package/dist/app.js +12 -8
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +144 -139
- package/dist/auth/drivers/local.js +1 -1
- package/dist/auth/drivers/oauth2.d.ts +1 -2
- package/dist/auth/drivers/oauth2.js +22 -17
- package/dist/auth/drivers/openid.d.ts +1 -2
- package/dist/auth/drivers/openid.js +18 -13
- package/dist/auth/drivers/saml.js +3 -3
- package/dist/auth/utils/generate-callback-url.d.ts +11 -0
- package/dist/auth/utils/generate-callback-url.js +40 -0
- package/dist/auth/utils/is-login-redirect-allowed.d.ts +7 -0
- package/dist/{utils → auth/utils}/is-login-redirect-allowed.js +12 -9
- package/dist/cache.d.ts +12 -0
- package/dist/cache.js +27 -3
- package/dist/cli/commands/bootstrap/index.js +2 -2
- package/dist/cli/commands/database/install.js +1 -1
- package/dist/cli/commands/database/migrate.js +1 -1
- package/dist/cli/commands/init/index.js +2 -2
- package/dist/cli/commands/roles/create.js +4 -4
- package/dist/cli/commands/schema/apply.js +3 -3
- package/dist/cli/commands/schema/snapshot.js +1 -1
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +1 -1
- package/dist/cli/utils/create-env/env-stub.liquid +3 -0
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/constants.d.ts +7 -3
- package/dist/constants.js +7 -3
- package/dist/controllers/access.js +1 -1
- package/dist/controllers/assets.js +1 -1
- package/dist/controllers/deployment.js +481 -0
- package/dist/controllers/extensions.js +1 -1
- package/dist/controllers/fields.js +8 -6
- package/dist/controllers/files.js +1 -1
- package/dist/controllers/items.js +1 -1
- package/dist/controllers/not-found.js +1 -1
- package/dist/controllers/relations.js +1 -1
- package/dist/database/errors/dialects/mysql.d.ts +1 -1
- package/dist/database/errors/dialects/postgres.d.ts +1 -1
- package/dist/database/errors/dialects/sqlite.d.ts +1 -1
- package/dist/database/errors/translate.d.ts +1 -1
- package/dist/database/errors/translate.js +1 -1
- package/dist/database/get-ast-from-query/lib/parse-fields.js +2 -2
- package/dist/database/helpers/date/dialects/mssql.js +1 -1
- package/dist/database/helpers/date/dialects/mysql.js +1 -1
- package/dist/database/helpers/date/types.js +1 -1
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -0
- package/dist/database/helpers/schema/dialects/cockroachdb.js +24 -1
- package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.d.ts +2 -1
- package/dist/database/helpers/schema/dialects/mysql.js +16 -3
- package/dist/database/helpers/schema/dialects/postgres.d.ts +1 -1
- package/dist/database/helpers/schema/types.d.ts +13 -0
- package/dist/database/helpers/schema/types.js +24 -0
- package/dist/database/index.js +4 -4
- package/dist/database/migrations/20220429A-add-flows.js +1 -1
- package/dist/database/migrations/20230526A-migrate-translation-strings.js +1 -1
- package/dist/database/migrations/20231009A-update-csv-fields-to-text.js +1 -1
- package/dist/database/migrations/20240204A-marketplace.js +9 -7
- package/dist/database/migrations/20240311A-deprecate-webhooks.d.ts +15 -0
- package/dist/database/migrations/20240311A-deprecate-webhooks.js +1 -1
- package/dist/database/migrations/20240806A-permissions-policies.js +2 -2
- package/dist/database/migrations/20240924A-migrate-legacy-comments.js +1 -1
- package/dist/database/migrations/20251014A-add-project-owner.js +1 -1
- package/dist/database/migrations/20251224A-remove-webhooks.d.ts +3 -0
- package/dist/database/migrations/20251224A-remove-webhooks.js +19 -0
- package/dist/database/migrations/20260110A-add-ai-provider-settings.d.ts +3 -0
- package/dist/database/migrations/20260110A-add-ai-provider-settings.js +35 -0
- package/dist/database/migrations/20260113A-add-revisions-index.d.ts +3 -0
- package/dist/database/migrations/20260113A-add-revisions-index.js +41 -0
- package/dist/database/migrations/20260128A-add-collaborative-editing.d.ts +3 -0
- package/dist/database/migrations/20260128A-add-collaborative-editing.js +10 -0
- package/dist/database/migrations/20260204A-add-deployment.d.ts +3 -0
- package/dist/database/migrations/20260204A-add-deployment.js +32 -0
- package/dist/database/migrations/run.js +3 -3
- package/dist/database/run-ast/lib/apply-query/add-join.js +1 -1
- package/dist/database/run-ast/lib/apply-query/filter/get-filter-type.d.ts +2 -2
- package/dist/database/run-ast/lib/apply-query/filter/get-filter-type.js +1 -1
- package/dist/database/run-ast/lib/apply-query/filter/index.js +1 -1
- package/dist/database/run-ast/lib/apply-query/filter/operator.js +1 -1
- package/dist/database/run-ast/lib/apply-query/sort.js +1 -1
- package/dist/database/run-ast/utils/get-column-pre-processor.js +2 -2
- package/dist/database/run-ast/utils/get-column.js +1 -1
- package/dist/database/seeds/run.js +3 -3
- package/dist/deployment/deployment.d.ts +94 -0
- package/dist/deployment/deployment.js +29 -0
- package/dist/deployment/drivers/index.d.ts +1 -0
- package/dist/deployment/drivers/index.js +1 -0
- package/dist/deployment/drivers/vercel.d.ts +32 -0
- package/dist/deployment/drivers/vercel.js +208 -0
- package/dist/deployment/index.d.ts +2 -0
- package/dist/deployment/index.js +2 -0
- package/dist/deployment.d.ts +24 -0
- package/dist/deployment.js +39 -0
- package/dist/extensions/lib/get-extensions-path.js +1 -1
- package/dist/extensions/lib/get-extensions-settings.js +1 -1
- package/dist/extensions/lib/get-extensions.js +1 -1
- package/dist/extensions/lib/get-shared-deps-mapping.js +3 -3
- package/dist/extensions/lib/installation/manager.js +3 -3
- package/dist/extensions/lib/sandbox/register/route.d.ts +1 -1
- package/dist/extensions/lib/sync/status.js +1 -1
- package/dist/extensions/lib/sync/sync.js +7 -7
- package/dist/extensions/lib/sync/utils.js +2 -2
- package/dist/extensions/manager.d.ts +1 -1
- package/dist/extensions/manager.js +8 -8
- package/dist/flows.d.ts +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/logs-stream.d.ts +1 -1
- package/dist/logger/logs-stream.js +1 -1
- package/dist/mailer.js +1 -1
- package/dist/metrics/lib/create-metrics.js +2 -2
- package/dist/middleware/authenticate.js +3 -3
- package/dist/middleware/collection-exists.js +1 -1
- package/dist/middleware/extract-token.js +1 -1
- package/dist/middleware/graphql.js +2 -2
- package/dist/middleware/respond.js +27 -14
- package/dist/middleware/validate-batch.js +1 -1
- package/dist/operations/exec/index.js +2 -1
- package/dist/operations/mail/index.js +1 -1
- package/dist/operations/mail/rate-limiter.js +2 -2
- package/dist/permissions/cache.js +5 -0
- package/dist/permissions/modules/fetch-allowed-collections/fetch-allowed-collections.js +1 -1
- package/dist/permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.js +1 -1
- package/dist/permissions/modules/fetch-inconsistent-field-map/fetch-inconsistent-field-map.js +2 -2
- package/dist/permissions/modules/process-ast/lib/inject-cases.js +1 -1
- package/dist/permissions/modules/process-ast/process-ast.js +1 -1
- package/dist/permissions/modules/process-ast/utils/find-related-collection.js +1 -1
- package/dist/permissions/modules/process-payload/process-payload.js +1 -1
- package/dist/permissions/modules/validate-access/lib/validate-item-access.d.ts +14 -2
- package/dist/permissions/modules/validate-access/lib/validate-item-access.js +72 -13
- package/dist/permissions/modules/validate-access/validate-access.js +3 -2
- package/dist/rate-limiter.js +1 -1
- package/dist/request/is-denied-ip.js +1 -1
- package/dist/schedules/project.js +1 -1
- package/dist/schedules/telemetry.js +1 -1
- package/dist/schedules/tus.js +1 -1
- package/dist/server.js +6 -5
- package/dist/services/assets.d.ts +2 -1
- package/dist/services/assets.js +35 -8
- package/dist/services/authentication.js +2 -2
- package/dist/services/collections.js +1 -1
- package/dist/services/deployment-projects.d.ts +20 -0
- package/dist/services/deployment-projects.js +34 -0
- package/dist/services/deployment-runs.d.ts +13 -0
- package/dist/services/deployment-runs.js +6 -0
- package/dist/services/deployment.d.ts +40 -0
- package/dist/services/deployment.js +202 -0
- package/dist/services/extensions.d.ts +1 -1
- package/dist/services/files/utils/get-metadata.d.ts +1 -1
- package/dist/services/files/utils/get-metadata.js +1 -1
- package/dist/services/files.d.ts +1 -1
- package/dist/services/files.js +4 -4
- package/dist/services/graphql/index.d.ts +1 -1
- package/dist/services/graphql/index.js +1 -1
- package/dist/services/graphql/resolvers/mutation.js +1 -1
- package/dist/services/graphql/resolvers/system-admin.js +2 -3
- package/dist/services/graphql/schema/get-types.d.ts +1 -1
- package/dist/services/graphql/schema/read.js +1 -1
- package/dist/services/graphql/subscription.d.ts +1 -1
- package/dist/services/graphql/types/date.js +1 -1
- package/dist/services/graphql/types/hash.js +1 -1
- package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -1
- package/dist/services/graphql/utils/filter-replace-m2a.js +3 -4
- package/dist/services/import-export.d.ts +1 -1
- package/dist/services/import-export.js +2 -2
- package/dist/services/index.d.ts +3 -1
- package/dist/services/index.js +3 -1
- package/dist/services/mail/index.js +2 -2
- package/dist/services/mail/rate-limiter.js +2 -2
- package/dist/services/payload.js +2 -2
- package/dist/services/schema.js +1 -1
- package/dist/services/server.js +13 -4
- package/dist/services/settings.js +2 -2
- package/dist/services/specifications.js +2 -2
- package/dist/services/tfa.js +1 -1
- package/dist/services/translations.js +1 -1
- package/dist/services/tus/data-store.d.ts +1 -3
- package/dist/services/tus/data-store.js +2 -5
- package/dist/services/tus/server.js +6 -6
- package/dist/services/users.js +4 -4
- package/dist/services/versions.js +1 -1
- package/dist/telemetry/lib/get-report.js +2 -0
- package/dist/telemetry/lib/send-report.d.ts +1 -1
- package/dist/telemetry/lib/send-report.js +1 -1
- package/dist/telemetry/lib/track.js +1 -1
- package/dist/telemetry/types/report.d.ts +8 -0
- package/dist/telemetry/utils/get-settings.d.ts +2 -0
- package/dist/telemetry/utils/get-settings.js +5 -0
- package/dist/test-utils/knex.js +1 -1
- package/dist/types/collection.d.ts +1 -1
- package/dist/utils/async-handler.d.ts +1 -1
- package/dist/utils/calculate-field-depth.js +1 -1
- package/dist/utils/compress.js +1 -1
- package/dist/utils/deep-map-response.d.ts +1 -1
- package/dist/utils/deep-map-response.js +2 -2
- package/dist/utils/get-cache-key.js +1 -1
- package/dist/utils/get-column-path.js +1 -1
- package/dist/utils/get-field-system-rows.js +1 -1
- package/dist/utils/get-ip-from-req.d.ts +1 -1
- package/dist/utils/get-ip-from-req.js +1 -1
- package/dist/utils/get-local-type.js +7 -3
- package/dist/utils/get-service.js +7 -3
- package/dist/utils/get-snapshot-diff.js +1 -1
- package/dist/utils/is-field-allowed.d.ts +4 -0
- package/dist/utils/is-field-allowed.js +9 -0
- package/dist/utils/is-url-allowed.js +1 -1
- package/dist/utils/jwt.js +1 -1
- package/dist/utils/sanitize-schema.d.ts +1 -1
- package/dist/utils/should-clear-cache.d.ts +1 -1
- package/dist/utils/should-skip-cache.js +2 -2
- package/dist/utils/validate-diff.js +1 -1
- package/dist/utils/validate-snapshot.js +3 -3
- package/dist/utils/validate-storage.js +2 -2
- package/dist/utils/verify-session-jwt.js +1 -1
- package/dist/utils/versioning/handle-version.js +1 -1
- package/dist/websocket/collab/calculate-cache-metadata.d.ts +9 -0
- package/dist/websocket/collab/calculate-cache-metadata.js +121 -0
- package/dist/websocket/collab/collab.d.ts +63 -0
- package/dist/websocket/collab/collab.js +481 -0
- package/dist/websocket/collab/constants.d.ts +1 -0
- package/dist/websocket/collab/constants.js +13 -0
- package/dist/websocket/collab/filter-to-fields.d.ts +2 -0
- package/dist/websocket/collab/filter-to-fields.js +11 -0
- package/dist/websocket/collab/messenger.d.ts +43 -0
- package/dist/websocket/collab/messenger.js +225 -0
- package/dist/websocket/collab/payload-permissions.d.ts +18 -0
- package/dist/websocket/collab/payload-permissions.js +158 -0
- package/dist/websocket/collab/permissions-cache.d.ts +52 -0
- package/dist/websocket/collab/permissions-cache.js +204 -0
- package/dist/websocket/collab/room.d.ts +125 -0
- package/dist/websocket/collab/room.js +593 -0
- package/dist/websocket/collab/store.d.ts +7 -0
- package/dist/websocket/collab/store.js +33 -0
- package/dist/websocket/collab/types.d.ts +21 -0
- package/dist/websocket/collab/types.js +1 -0
- package/dist/websocket/collab/verify-permissions.d.ts +11 -0
- package/dist/websocket/collab/verify-permissions.js +100 -0
- package/dist/websocket/controllers/base.d.ts +2 -2
- package/dist/websocket/controllers/base.js +3 -3
- package/dist/websocket/controllers/graphql.d.ts +1 -1
- package/dist/websocket/controllers/graphql.js +1 -1
- package/dist/websocket/controllers/logs.d.ts +1 -1
- package/dist/websocket/controllers/rest.d.ts +1 -1
- package/dist/websocket/controllers/rest.js +2 -2
- package/dist/websocket/handlers/heartbeat.js +1 -1
- package/dist/websocket/handlers/index.d.ts +2 -0
- package/dist/websocket/handlers/index.js +9 -0
- package/dist/websocket/handlers/items.js +2 -2
- package/dist/websocket/handlers/subscribe.js +1 -1
- package/dist/websocket/types.d.ts +1 -1
- package/dist/websocket/utils/items.d.ts +2 -2
- package/dist/websocket/utils/message.d.ts +1 -1
- package/dist/websocket/utils/message.js +2 -2
- package/dist/websocket/utils/wait-for-message.js +1 -1
- package/package.json +35 -33
- package/dist/controllers/webhooks.js +0 -74
- package/dist/services/webhooks.d.ts +0 -14
- package/dist/services/webhooks.js +0 -32
- package/dist/utils/get-relation-info.d.ts +0 -6
- package/dist/utils/get-relation-info.js +0 -43
- package/dist/utils/get-relation-type.d.ts +0 -6
- package/dist/utils/get-relation-type.js +0 -18
- package/dist/utils/is-login-redirect-allowed.d.ts +0 -4
- package/dist/utils/versioning/deep-map-with-schema.d.ts +0 -23
- package/dist/utils/versioning/deep-map-with-schema.js +0 -81
- /package/dist/controllers/{webhooks.d.ts → deployment.d.ts} +0 -0
package/dist/ai/mcp/server.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export declare class DirectusMCP {
|
|
|
25
25
|
content: ({
|
|
26
26
|
type: "text";
|
|
27
27
|
text: string;
|
|
28
|
+
annotations?: {
|
|
29
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
30
|
+
priority?: number | undefined;
|
|
31
|
+
lastModified?: string | undefined;
|
|
32
|
+
} | undefined;
|
|
28
33
|
_meta?: {
|
|
29
34
|
[x: string]: unknown;
|
|
30
35
|
} | undefined;
|
|
@@ -32,6 +37,11 @@ export declare class DirectusMCP {
|
|
|
32
37
|
type: "image";
|
|
33
38
|
data: string;
|
|
34
39
|
mimeType: string;
|
|
40
|
+
annotations?: {
|
|
41
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
42
|
+
priority?: number | undefined;
|
|
43
|
+
lastModified?: string | undefined;
|
|
44
|
+
} | undefined;
|
|
35
45
|
_meta?: {
|
|
36
46
|
[x: string]: unknown;
|
|
37
47
|
} | undefined;
|
|
@@ -39,6 +49,11 @@ export declare class DirectusMCP {
|
|
|
39
49
|
type: "audio";
|
|
40
50
|
data: string;
|
|
41
51
|
mimeType: string;
|
|
52
|
+
annotations?: {
|
|
53
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
54
|
+
priority?: number | undefined;
|
|
55
|
+
lastModified?: string | undefined;
|
|
56
|
+
} | undefined;
|
|
42
57
|
_meta?: {
|
|
43
58
|
[x: string]: unknown;
|
|
44
59
|
} | undefined;
|
|
@@ -48,6 +63,11 @@ export declare class DirectusMCP {
|
|
|
48
63
|
type: "resource_link";
|
|
49
64
|
description?: string | undefined;
|
|
50
65
|
mimeType?: string | undefined;
|
|
66
|
+
annotations?: {
|
|
67
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
68
|
+
priority?: number | undefined;
|
|
69
|
+
lastModified?: string | undefined;
|
|
70
|
+
} | undefined;
|
|
51
71
|
_meta?: {
|
|
52
72
|
[x: string]: unknown;
|
|
53
73
|
} | undefined;
|
|
@@ -55,6 +75,7 @@ export declare class DirectusMCP {
|
|
|
55
75
|
src: string;
|
|
56
76
|
mimeType?: string | undefined;
|
|
57
77
|
sizes?: string[] | undefined;
|
|
78
|
+
theme?: "light" | "dark" | undefined;
|
|
58
79
|
}[] | undefined;
|
|
59
80
|
title?: string | undefined;
|
|
60
81
|
} | {
|
|
@@ -74,14 +95,19 @@ export declare class DirectusMCP {
|
|
|
74
95
|
[x: string]: unknown;
|
|
75
96
|
} | undefined;
|
|
76
97
|
};
|
|
98
|
+
annotations?: {
|
|
99
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
100
|
+
priority?: number | undefined;
|
|
101
|
+
lastModified?: string | undefined;
|
|
102
|
+
} | undefined;
|
|
77
103
|
_meta?: {
|
|
78
104
|
[x: string]: unknown;
|
|
79
105
|
} | undefined;
|
|
80
106
|
})[];
|
|
81
107
|
_meta?: {
|
|
82
108
|
[x: string]: unknown;
|
|
109
|
+
progressToken?: string | number | undefined;
|
|
83
110
|
"io.modelcontextprotocol/related-task"?: {
|
|
84
|
-
[x: string]: unknown;
|
|
85
111
|
taskId: string;
|
|
86
112
|
} | undefined;
|
|
87
113
|
} | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ModelDefinition, type ProviderType } from '@directus/ai';
|
|
2
|
+
import type { AISettings } from './types.js';
|
|
3
|
+
export declare function getModelDefinition(provider: ProviderType, model: string, settings: AISettings): ModelDefinition | undefined;
|
|
4
|
+
export declare function getProviderOptions(provider: ProviderType, model: string, settings: AISettings): {
|
|
5
|
+
openai: {
|
|
6
|
+
reasoningSummary: string;
|
|
7
|
+
store: boolean;
|
|
8
|
+
include: string[];
|
|
9
|
+
};
|
|
10
|
+
} | {
|
|
11
|
+
[x: string]: {
|
|
12
|
+
[key: string]: import("@directus/ai").JSONValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { buildCustomModels, DEFAULT_AI_MODELS } from '@directus/ai';
|
|
2
|
+
export function getModelDefinition(provider, model, settings) {
|
|
3
|
+
const customModels = buildCustomModels(settings.openaiCompatibleModels);
|
|
4
|
+
return [...DEFAULT_AI_MODELS, ...customModels].find((m) => m.provider === provider && m.model === model);
|
|
5
|
+
}
|
|
6
|
+
const OPENAI_REASONING_OPTIONS = {
|
|
7
|
+
openai: {
|
|
8
|
+
reasoningSummary: 'auto',
|
|
9
|
+
store: false,
|
|
10
|
+
include: ['reasoning.encrypted_content'],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export function getProviderOptions(provider, model, settings) {
|
|
14
|
+
const modelDef = getModelDefinition(provider, model, settings);
|
|
15
|
+
if (provider === 'openai' && modelDef?.reasoning) {
|
|
16
|
+
return OPENAI_REASONING_OPTIONS;
|
|
17
|
+
}
|
|
18
|
+
if (provider === 'openai-compatible') {
|
|
19
|
+
const customModel = settings.openaiCompatibleModels?.find((m) => m.id === model);
|
|
20
|
+
if (customModel?.providerOptions) {
|
|
21
|
+
const providerName = settings.openaiCompatibleName ?? 'openai-compatible';
|
|
22
|
+
return { [providerName]: customModel.providerOptions };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createProviderRegistry } from 'ai';
|
|
2
|
+
import type { AISettings, ProviderConfig } from './types.js';
|
|
3
|
+
type ProviderRegistry = ReturnType<typeof createProviderRegistry>;
|
|
4
|
+
export declare function buildProviderConfigs(settings: AISettings): ProviderConfig[];
|
|
5
|
+
export declare function createAIProviderRegistry(configs: ProviderConfig[], settings?: AISettings): ProviderRegistry;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
2
|
+
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
3
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
4
|
+
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
5
|
+
import { createProviderRegistry } from 'ai';
|
|
6
|
+
export function buildProviderConfigs(settings) {
|
|
7
|
+
const configs = [];
|
|
8
|
+
if (settings.openaiApiKey) {
|
|
9
|
+
configs.push({
|
|
10
|
+
type: 'openai',
|
|
11
|
+
apiKey: settings.openaiApiKey,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (settings.anthropicApiKey) {
|
|
15
|
+
configs.push({
|
|
16
|
+
type: 'anthropic',
|
|
17
|
+
apiKey: settings.anthropicApiKey,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (settings.googleApiKey) {
|
|
21
|
+
configs.push({
|
|
22
|
+
type: 'google',
|
|
23
|
+
apiKey: settings.googleApiKey,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (settings.openaiCompatibleApiKey && settings.openaiCompatibleBaseUrl) {
|
|
27
|
+
configs.push({
|
|
28
|
+
type: 'openai-compatible',
|
|
29
|
+
apiKey: settings.openaiCompatibleApiKey,
|
|
30
|
+
baseUrl: settings.openaiCompatibleBaseUrl,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return configs;
|
|
34
|
+
}
|
|
35
|
+
export function createAIProviderRegistry(configs, settings) {
|
|
36
|
+
const providers = {};
|
|
37
|
+
for (const config of configs) {
|
|
38
|
+
switch (config.type) {
|
|
39
|
+
case 'openai':
|
|
40
|
+
providers['openai'] = createOpenAI({ apiKey: config.apiKey });
|
|
41
|
+
break;
|
|
42
|
+
case 'anthropic':
|
|
43
|
+
providers['anthropic'] = createAnthropic({ apiKey: config.apiKey });
|
|
44
|
+
break;
|
|
45
|
+
case 'google':
|
|
46
|
+
providers['google'] = createGoogleGenerativeAI({ apiKey: config.apiKey });
|
|
47
|
+
break;
|
|
48
|
+
case 'openai-compatible':
|
|
49
|
+
if (config.baseUrl) {
|
|
50
|
+
const customHeaders = settings?.openaiCompatibleHeaders?.reduce((acc, { header, value }) => {
|
|
51
|
+
acc[header] = value;
|
|
52
|
+
return acc;
|
|
53
|
+
}, {}) ?? {};
|
|
54
|
+
providers['openai-compatible'] = createOpenAICompatible({
|
|
55
|
+
name: settings?.openaiCompatibleName ?? 'openai-compatible',
|
|
56
|
+
apiKey: config.apiKey,
|
|
57
|
+
baseURL: config.baseUrl,
|
|
58
|
+
headers: customHeaders,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return createProviderRegistry(providers);
|
|
65
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { OpenAICompatibleHeader, OpenAICompatibleModel } from '@directus/ai';
|
|
2
|
+
interface OpenAIConfig {
|
|
3
|
+
type: 'openai';
|
|
4
|
+
apiKey: string;
|
|
5
|
+
}
|
|
6
|
+
interface AnthropicConfig {
|
|
7
|
+
type: 'anthropic';
|
|
8
|
+
apiKey: string;
|
|
9
|
+
}
|
|
10
|
+
interface GoogleConfig {
|
|
11
|
+
type: 'google';
|
|
12
|
+
apiKey: string;
|
|
13
|
+
}
|
|
14
|
+
interface OpenAICompatibleConfig {
|
|
15
|
+
type: 'openai-compatible';
|
|
16
|
+
apiKey: string;
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
}
|
|
19
|
+
export type ProviderConfig = OpenAIConfig | AnthropicConfig | GoogleConfig | OpenAICompatibleConfig;
|
|
20
|
+
export interface AISettings {
|
|
21
|
+
openaiApiKey: string | null;
|
|
22
|
+
anthropicApiKey: string | null;
|
|
23
|
+
googleApiKey: string | null;
|
|
24
|
+
openaiCompatibleApiKey: string | null;
|
|
25
|
+
openaiCompatibleBaseUrl: string | null;
|
|
26
|
+
openaiCompatibleName: string | null;
|
|
27
|
+
openaiCompatibleModels: OpenAICompatibleModel[] | null;
|
|
28
|
+
openaiCompatibleHeaders: OpenAICompatibleHeader[] | null;
|
|
29
|
+
openaiAllowedModels: string[] | null;
|
|
30
|
+
anthropicAllowedModels: string[] | null;
|
|
31
|
+
googleAllowedModels: string[] | null;
|
|
32
|
+
systemPrompt: string | null;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UnsupportedMediaTypeError } from '@directus/errors';
|
|
2
1
|
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { UnsupportedMediaTypeError } from '@directus/errors';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { AssetsService } from '../../../services/assets.js';
|
|
6
6
|
import { FilesService } from '../../../services/files.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { InvalidPayloadError } from '@directus/errors';
|
|
2
|
-
import { isObject, toArray } from '@directus/utils';
|
|
3
1
|
import { dirname, resolve } from 'node:path';
|
|
4
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { InvalidPayloadError } from '@directus/errors';
|
|
4
|
+
import { isObject, toArray } from '@directus/utils';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { CollectionsService } from '../../../services/collections.js';
|
|
7
7
|
import { requireText } from '../../../utils/require-text.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { InvalidPayloadError } from '@directus/errors';
|
|
2
|
-
import { toArray } from '@directus/utils';
|
|
3
1
|
import { dirname, resolve } from 'node:path';
|
|
4
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { InvalidPayloadError } from '@directus/errors';
|
|
4
|
+
import { toArray } from '@directus/utils';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { clearSystemCache } from '../../../cache.js';
|
|
7
7
|
import getDatabase from '../../../database/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isObject } from '@directus/utils';
|
|
2
1
|
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { isObject } from '@directus/utils';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { FilesService } from '../../../services/files.js';
|
|
6
6
|
import { requireText } from '../../../utils/require-text.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isObject } from '@directus/utils';
|
|
2
1
|
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { isObject } from '@directus/utils';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { FlowsService } from '../../../services/flows.js';
|
|
6
6
|
import { requireText } from '../../../utils/require-text.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toArray } from '@directus/utils';
|
|
2
1
|
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { toArray } from '@directus/utils';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { FoldersService } from '../../../services/folders.js';
|
|
6
6
|
import { requireText } from '../../../utils/require-text.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
1
3
|
import { ForbiddenError, InvalidPayloadError } from '@directus/errors';
|
|
2
4
|
import { isSystemCollection } from '@directus/system-data';
|
|
3
5
|
import { toArray } from '@directus/utils';
|
|
4
6
|
import { isObject } from 'graphql-compose';
|
|
5
|
-
import { dirname, resolve } from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { ItemsService } from '../../../services/items.js';
|
|
9
9
|
import { requireText } from '../../../utils/require-text.js';
|
|
@@ -41,7 +41,10 @@ const ItemsInputSchema = z.object({
|
|
|
41
41
|
collection: z.string().describe('The name of the collection'),
|
|
42
42
|
query: QueryInputSchema.optional(),
|
|
43
43
|
keys: z.array(PrimaryKeyInputSchema).optional(),
|
|
44
|
-
data: z
|
|
44
|
+
data: z
|
|
45
|
+
.union([z.array(ItemInputSchema), ItemInputSchema])
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('Object when using keys, array with PKs for batch updates'),
|
|
45
48
|
});
|
|
46
49
|
export const items = defineTool({
|
|
47
50
|
name: 'items',
|
|
@@ -99,7 +99,7 @@ Core: `_eq`, `_neq`, `_in`, `_nin`, `_null`, `_nnull`, `_lt`, `_lte`, `_gt`, `_g
|
|
|
99
99
|
"action": "update",
|
|
100
100
|
"collection": "posts",
|
|
101
101
|
"keys": ["uuid-1", "uuid-2"],
|
|
102
|
-
"data":
|
|
102
|
+
"data": { "status": "published" }
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
@@ -123,15 +123,13 @@ Core: `_eq`, `_neq`, `_in`, `_nin`, `_null`, `_nnull`, `_lt`, `_lte`, `_gt`, `_g
|
|
|
123
123
|
"action": "update",
|
|
124
124
|
"collection": "posts",
|
|
125
125
|
"keys": ["uuid-1"],
|
|
126
|
-
"data":
|
|
127
|
-
{
|
|
128
|
-
"
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
"delete": [5]
|
|
132
|
-
}
|
|
126
|
+
"data": {
|
|
127
|
+
"categories": {
|
|
128
|
+
"create": [{ "name": "New Category" }],
|
|
129
|
+
"update": [{ "id": 3, "name": "Renamed" }],
|
|
130
|
+
"delete": [5]
|
|
133
131
|
}
|
|
134
|
-
|
|
132
|
+
}
|
|
135
133
|
}
|
|
136
134
|
```
|
|
137
135
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InvalidPayloadError } from '@directus/errors';
|
|
2
1
|
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { InvalidPayloadError } from '@directus/errors';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { RelationsService } from '../../../services/relations.js';
|
|
6
6
|
import { requireText } from '../../../utils/require-text.js';
|
package/dist/ai/tools/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InvalidPayloadError } from '@directus/errors';
|
|
2
1
|
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { InvalidPayloadError } from '@directus/errors';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { getFlowManager } from '../../../flows.js';
|
|
6
6
|
import { FlowsService } from '../../../services/flows.js';
|
package/dist/app.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import path from 'path';
|
|
1
4
|
import { useEnv } from '@directus/env';
|
|
2
5
|
import { InvalidPayloadError, ServiceUnavailableError } from '@directus/errors';
|
|
3
6
|
import { handlePressure } from '@directus/pressure';
|
|
@@ -5,10 +8,8 @@ import { toBoolean } from '@directus/utils';
|
|
|
5
8
|
import cookieParser from 'cookie-parser';
|
|
6
9
|
import express from 'express';
|
|
7
10
|
import { merge } from 'lodash-es';
|
|
8
|
-
import { readFile } from 'node:fs/promises';
|
|
9
|
-
import { createRequire } from 'node:module';
|
|
10
|
-
import path from 'path';
|
|
11
11
|
import qs from 'qs';
|
|
12
|
+
import { aiChatRouter } from './ai/chat/router.js';
|
|
12
13
|
import { registerAuthProviders } from './auth.js';
|
|
13
14
|
import accessRouter from './controllers/access.js';
|
|
14
15
|
import activityRouter from './controllers/activity.js';
|
|
@@ -17,6 +18,7 @@ import authRouter from './controllers/auth.js';
|
|
|
17
18
|
import collectionsRouter from './controllers/collections.js';
|
|
18
19
|
import commentsRouter from './controllers/comments.js';
|
|
19
20
|
import dashboardsRouter from './controllers/dashboards.js';
|
|
21
|
+
import deploymentRouter from './controllers/deployment.js';
|
|
20
22
|
import extensionsRouter from './controllers/extensions.js';
|
|
21
23
|
import fieldsRouter from './controllers/fields.js';
|
|
22
24
|
import filesRouter from './controllers/files.js';
|
|
@@ -45,8 +47,8 @@ import tusRouter from './controllers/tus.js';
|
|
|
45
47
|
import usersRouter from './controllers/users.js';
|
|
46
48
|
import utilsRouter from './controllers/utils.js';
|
|
47
49
|
import versionsRouter from './controllers/versions.js';
|
|
48
|
-
import webhooksRouter from './controllers/webhooks.js';
|
|
49
50
|
import { isInstalled, validateDatabaseConnection, validateDatabaseExtensions, validateMigrations, } from './database/index.js';
|
|
51
|
+
import { registerDeploymentDrivers } from './deployment.js';
|
|
50
52
|
import emitter from './emitter.js';
|
|
51
53
|
import { getExtensionManager } from './extensions/index.js';
|
|
52
54
|
import { getFlowManager } from './flows.js';
|
|
@@ -61,14 +63,13 @@ import rateLimiter from './middleware/rate-limiter-ip.js';
|
|
|
61
63
|
import sanitizeQuery from './middleware/sanitize-query.js';
|
|
62
64
|
import schema from './middleware/schema.js';
|
|
63
65
|
import metricsSchedule from './schedules/metrics.js';
|
|
66
|
+
import projectSchedule from './schedules/project.js';
|
|
64
67
|
import retentionSchedule from './schedules/retention.js';
|
|
65
68
|
import telemetrySchedule from './schedules/telemetry.js';
|
|
66
69
|
import tusSchedule from './schedules/tus.js';
|
|
67
|
-
import projectSchedule from './schedules/project.js';
|
|
68
70
|
import { getConfigFromEnv } from './utils/get-config-from-env.js';
|
|
69
71
|
import { Url } from './utils/url.js';
|
|
70
72
|
import { validateStorage } from './utils/validate-storage.js';
|
|
71
|
-
import { aiChatRouter } from './ai/chat/router.js';
|
|
72
73
|
const require = createRequire(import.meta.url);
|
|
73
74
|
export default async function createApp() {
|
|
74
75
|
const env = useEnv();
|
|
@@ -94,6 +95,7 @@ export default async function createApp() {
|
|
|
94
95
|
await validateDatabaseExtensions();
|
|
95
96
|
await validateStorage();
|
|
96
97
|
await registerAuthProviders();
|
|
98
|
+
registerDeploymentDrivers();
|
|
97
99
|
const extensionManager = getExtensionManager();
|
|
98
100
|
const flowManager = getFlowManager();
|
|
99
101
|
await extensionManager.initialize();
|
|
@@ -223,6 +225,7 @@ export default async function createApp() {
|
|
|
223
225
|
app.use('/collections', collectionsRouter);
|
|
224
226
|
app.use('/comments', commentsRouter);
|
|
225
227
|
app.use('/dashboards', dashboardsRouter);
|
|
228
|
+
app.use('/deployments', deploymentRouter);
|
|
226
229
|
app.use('/extensions', extensionsRouter);
|
|
227
230
|
app.use('/fields', fieldsRouter);
|
|
228
231
|
if (env['TUS_ENABLED'] === true) {
|
|
@@ -235,7 +238,9 @@ export default async function createApp() {
|
|
|
235
238
|
if (toBoolean(env['MCP_ENABLED']) === true) {
|
|
236
239
|
app.use('/mcp', mcpRouter);
|
|
237
240
|
}
|
|
238
|
-
|
|
241
|
+
if (toBoolean(env['AI_ENABLED']) === true) {
|
|
242
|
+
app.use('/ai/chat', aiChatRouter);
|
|
243
|
+
}
|
|
239
244
|
if (env['METRICS_ENABLED'] === true) {
|
|
240
245
|
app.use('/metrics', metricsRouter);
|
|
241
246
|
}
|
|
@@ -256,7 +261,6 @@ export default async function createApp() {
|
|
|
256
261
|
app.use('/users', usersRouter);
|
|
257
262
|
app.use('/utils', utilsRouter);
|
|
258
263
|
app.use('/versions', versionsRouter);
|
|
259
|
-
app.use('/webhooks', webhooksRouter);
|
|
260
264
|
// Register custom endpoints
|
|
261
265
|
await emitter.emitInit('routes.custom.before', { app });
|
|
262
266
|
app.use(extensionManager.getEndpointRouter());
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import
|
|
2
|
+
import { Client } from 'ldapts';
|
|
3
3
|
import type { AuthDriverOptions, User } from '../../types/index.js';
|
|
4
4
|
import { AuthDriver } from '../auth.js';
|
|
5
5
|
export declare class LDAPAuthDriver extends AuthDriver {
|