@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,311 @@
|
|
|
1
|
+
import type { Item, Query } from '@directus/types';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const WebSocketMessage: z.ZodObject<{
|
|
4
|
+
type: z.ZodString;
|
|
5
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
6
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
7
|
+
type: z.ZodString;
|
|
8
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
9
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
10
|
+
type: z.ZodString;
|
|
11
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
12
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
13
|
+
export type WebSocketMessage = z.infer<typeof WebSocketMessage>;
|
|
14
|
+
export declare const WebSocketResponse: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
|
|
15
|
+
type: z.ZodString;
|
|
16
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
17
|
+
status: z.ZodLiteral<"ok">;
|
|
18
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
19
|
+
type: z.ZodString;
|
|
20
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
21
|
+
status: z.ZodLiteral<"ok">;
|
|
22
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
23
|
+
type: z.ZodString;
|
|
24
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
25
|
+
status: z.ZodLiteral<"ok">;
|
|
26
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
27
|
+
type: z.ZodString;
|
|
28
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
29
|
+
status: z.ZodLiteral<"error">;
|
|
30
|
+
error: z.ZodObject<{
|
|
31
|
+
code: z.ZodString;
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
34
|
+
code: z.ZodString;
|
|
35
|
+
message: z.ZodString;
|
|
36
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
37
|
+
code: z.ZodString;
|
|
38
|
+
message: z.ZodString;
|
|
39
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
40
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
41
|
+
type: z.ZodString;
|
|
42
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
43
|
+
status: z.ZodLiteral<"error">;
|
|
44
|
+
error: z.ZodObject<{
|
|
45
|
+
code: z.ZodString;
|
|
46
|
+
message: z.ZodString;
|
|
47
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
48
|
+
code: z.ZodString;
|
|
49
|
+
message: z.ZodString;
|
|
50
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
51
|
+
code: z.ZodString;
|
|
52
|
+
message: z.ZodString;
|
|
53
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
54
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
55
|
+
type: z.ZodString;
|
|
56
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
57
|
+
status: z.ZodLiteral<"error">;
|
|
58
|
+
error: z.ZodObject<{
|
|
59
|
+
code: z.ZodString;
|
|
60
|
+
message: z.ZodString;
|
|
61
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
62
|
+
code: z.ZodString;
|
|
63
|
+
message: z.ZodString;
|
|
64
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
65
|
+
code: z.ZodString;
|
|
66
|
+
message: z.ZodString;
|
|
67
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
68
|
+
}, z.ZodTypeAny, "passthrough">>]>;
|
|
69
|
+
export type WebSocketResponse = z.infer<typeof WebSocketResponse>;
|
|
70
|
+
export declare const ConnectionParams: z.ZodObject<{
|
|
71
|
+
access_token: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
access_token?: string | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
access_token?: string | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
export type ConnectionParams = z.infer<typeof ConnectionParams>;
|
|
78
|
+
export declare const BasicAuthMessage: z.ZodUnion<[z.ZodObject<{
|
|
79
|
+
email: z.ZodString;
|
|
80
|
+
password: z.ZodString;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
email: string;
|
|
83
|
+
password: string;
|
|
84
|
+
}, {
|
|
85
|
+
email: string;
|
|
86
|
+
password: string;
|
|
87
|
+
}>, z.ZodObject<{
|
|
88
|
+
access_token: z.ZodString;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
access_token: string;
|
|
91
|
+
}, {
|
|
92
|
+
access_token: string;
|
|
93
|
+
}>, z.ZodObject<{
|
|
94
|
+
refresh_token: z.ZodString;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
refresh_token: string;
|
|
97
|
+
}, {
|
|
98
|
+
refresh_token: string;
|
|
99
|
+
}>]>;
|
|
100
|
+
export type BasicAuthMessage = z.infer<typeof BasicAuthMessage>;
|
|
101
|
+
export declare const WebSocketAuthMessage: z.ZodIntersection<z.ZodObject<{
|
|
102
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
103
|
+
type: z.ZodLiteral<"auth">;
|
|
104
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
105
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
106
|
+
type: z.ZodLiteral<"auth">;
|
|
107
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
108
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
109
|
+
type: z.ZodLiteral<"auth">;
|
|
110
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
|
|
111
|
+
email: z.ZodString;
|
|
112
|
+
password: z.ZodString;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
email: string;
|
|
115
|
+
password: string;
|
|
116
|
+
}, {
|
|
117
|
+
email: string;
|
|
118
|
+
password: string;
|
|
119
|
+
}>, z.ZodObject<{
|
|
120
|
+
access_token: z.ZodString;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
access_token: string;
|
|
123
|
+
}, {
|
|
124
|
+
access_token: string;
|
|
125
|
+
}>, z.ZodObject<{
|
|
126
|
+
refresh_token: z.ZodString;
|
|
127
|
+
}, "strip", z.ZodTypeAny, {
|
|
128
|
+
refresh_token: string;
|
|
129
|
+
}, {
|
|
130
|
+
refresh_token: string;
|
|
131
|
+
}>]>>;
|
|
132
|
+
export type WebSocketAuthMessage = z.infer<typeof WebSocketAuthMessage>;
|
|
133
|
+
export declare const WebSocketSubscribeMessage: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
134
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
135
|
+
type: z.ZodLiteral<"subscribe">;
|
|
136
|
+
collection: z.ZodString;
|
|
137
|
+
event: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"create">, z.ZodLiteral<"update">, z.ZodLiteral<"delete">]>>;
|
|
138
|
+
item: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
139
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
140
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
141
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
142
|
+
type: z.ZodLiteral<"subscribe">;
|
|
143
|
+
collection: z.ZodString;
|
|
144
|
+
event: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"create">, z.ZodLiteral<"update">, z.ZodLiteral<"delete">]>>;
|
|
145
|
+
item: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
146
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
147
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
148
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
149
|
+
type: z.ZodLiteral<"subscribe">;
|
|
150
|
+
collection: z.ZodString;
|
|
151
|
+
event: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"create">, z.ZodLiteral<"update">, z.ZodLiteral<"delete">]>>;
|
|
152
|
+
item: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
153
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
154
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
155
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
156
|
+
type: z.ZodLiteral<"unsubscribe">;
|
|
157
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
158
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
159
|
+
type: z.ZodLiteral<"unsubscribe">;
|
|
160
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
161
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
162
|
+
type: z.ZodLiteral<"unsubscribe">;
|
|
163
|
+
}, z.ZodTypeAny, "passthrough">>]>;
|
|
164
|
+
export type WebSocketSubscribeMessage = z.infer<typeof WebSocketSubscribeMessage>;
|
|
165
|
+
export declare const WebSocketItemsMessage: z.ZodUnion<[z.ZodObject<{
|
|
166
|
+
type: z.ZodLiteral<"items">;
|
|
167
|
+
collection: z.ZodString;
|
|
168
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
169
|
+
action: z.ZodLiteral<"create">;
|
|
170
|
+
data: z.ZodUnion<[z.ZodArray<z.ZodType<Partial<Item>, z.ZodTypeDef, Partial<Item>>, "many">, z.ZodType<Partial<Item>, z.ZodTypeDef, Partial<Item>>]>;
|
|
171
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
type: "items";
|
|
174
|
+
action: "create";
|
|
175
|
+
data: (Partial<Item> | Partial<Item>[]) & (Partial<Item> | Partial<Item>[] | undefined);
|
|
176
|
+
collection: string;
|
|
177
|
+
uid?: string | number | undefined;
|
|
178
|
+
query?: Query | undefined;
|
|
179
|
+
}, {
|
|
180
|
+
type: "items";
|
|
181
|
+
action: "create";
|
|
182
|
+
data: (Partial<Item> | Partial<Item>[]) & (Partial<Item> | Partial<Item>[] | undefined);
|
|
183
|
+
collection: string;
|
|
184
|
+
uid?: string | number | undefined;
|
|
185
|
+
query?: Query | undefined;
|
|
186
|
+
}>, z.ZodObject<{
|
|
187
|
+
type: z.ZodLiteral<"items">;
|
|
188
|
+
collection: z.ZodString;
|
|
189
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
190
|
+
action: z.ZodLiteral<"read">;
|
|
191
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
192
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
193
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
type: "items";
|
|
196
|
+
action: "read";
|
|
197
|
+
collection: string;
|
|
198
|
+
uid?: string | number | undefined;
|
|
199
|
+
ids?: (string | number)[] | undefined;
|
|
200
|
+
id?: string | number | undefined;
|
|
201
|
+
query?: Query | undefined;
|
|
202
|
+
}, {
|
|
203
|
+
type: "items";
|
|
204
|
+
action: "read";
|
|
205
|
+
collection: string;
|
|
206
|
+
uid?: string | number | undefined;
|
|
207
|
+
ids?: (string | number)[] | undefined;
|
|
208
|
+
id?: string | number | undefined;
|
|
209
|
+
query?: Query | undefined;
|
|
210
|
+
}>, z.ZodObject<{
|
|
211
|
+
type: z.ZodLiteral<"items">;
|
|
212
|
+
collection: z.ZodString;
|
|
213
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
214
|
+
action: z.ZodLiteral<"update">;
|
|
215
|
+
data: z.ZodType<Partial<Item>, z.ZodTypeDef, Partial<Item>>;
|
|
216
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
217
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
218
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
219
|
+
}, "strip", z.ZodTypeAny, {
|
|
220
|
+
type: "items";
|
|
221
|
+
action: "update";
|
|
222
|
+
data: Partial<Item>;
|
|
223
|
+
collection: string;
|
|
224
|
+
uid?: string | number | undefined;
|
|
225
|
+
ids?: (string | number)[] | undefined;
|
|
226
|
+
id?: string | number | undefined;
|
|
227
|
+
query?: Query | undefined;
|
|
228
|
+
}, {
|
|
229
|
+
type: "items";
|
|
230
|
+
action: "update";
|
|
231
|
+
data: Partial<Item>;
|
|
232
|
+
collection: string;
|
|
233
|
+
uid?: string | number | undefined;
|
|
234
|
+
ids?: (string | number)[] | undefined;
|
|
235
|
+
id?: string | number | undefined;
|
|
236
|
+
query?: Query | undefined;
|
|
237
|
+
}>, z.ZodObject<{
|
|
238
|
+
type: z.ZodLiteral<"items">;
|
|
239
|
+
collection: z.ZodString;
|
|
240
|
+
uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
241
|
+
action: z.ZodLiteral<"delete">;
|
|
242
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
|
|
243
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
244
|
+
query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
|
|
245
|
+
}, "strip", z.ZodTypeAny, {
|
|
246
|
+
type: "items";
|
|
247
|
+
action: "delete";
|
|
248
|
+
collection: string;
|
|
249
|
+
uid?: string | number | undefined;
|
|
250
|
+
ids?: (string | number)[] | undefined;
|
|
251
|
+
id?: string | number | undefined;
|
|
252
|
+
query?: Query | undefined;
|
|
253
|
+
}, {
|
|
254
|
+
type: "items";
|
|
255
|
+
action: "delete";
|
|
256
|
+
collection: string;
|
|
257
|
+
uid?: string | number | undefined;
|
|
258
|
+
ids?: (string | number)[] | undefined;
|
|
259
|
+
id?: string | number | undefined;
|
|
260
|
+
query?: Query | undefined;
|
|
261
|
+
}>]>;
|
|
262
|
+
export type WebSocketItemsMessage = z.infer<typeof WebSocketItemsMessage>;
|
|
263
|
+
export declare const WebSocketEvent: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
|
|
264
|
+
action: z.ZodLiteral<"create">;
|
|
265
|
+
collection: z.ZodString;
|
|
266
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
267
|
+
key: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
268
|
+
}, "strip", z.ZodTypeAny, {
|
|
269
|
+
key: string | number;
|
|
270
|
+
action: "create";
|
|
271
|
+
collection: string;
|
|
272
|
+
payload?: Record<string, any> | undefined;
|
|
273
|
+
}, {
|
|
274
|
+
key: string | number;
|
|
275
|
+
action: "create";
|
|
276
|
+
collection: string;
|
|
277
|
+
payload?: Record<string, any> | undefined;
|
|
278
|
+
}>, z.ZodObject<{
|
|
279
|
+
action: z.ZodLiteral<"update">;
|
|
280
|
+
collection: z.ZodString;
|
|
281
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
282
|
+
keys: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
|
|
283
|
+
}, "strip", z.ZodTypeAny, {
|
|
284
|
+
action: "update";
|
|
285
|
+
keys: (string | number)[];
|
|
286
|
+
collection: string;
|
|
287
|
+
payload?: Record<string, any> | undefined;
|
|
288
|
+
}, {
|
|
289
|
+
action: "update";
|
|
290
|
+
keys: (string | number)[];
|
|
291
|
+
collection: string;
|
|
292
|
+
payload?: Record<string, any> | undefined;
|
|
293
|
+
}>, z.ZodObject<{
|
|
294
|
+
action: z.ZodLiteral<"delete">;
|
|
295
|
+
collection: z.ZodString;
|
|
296
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
297
|
+
keys: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
|
|
298
|
+
}, "strip", z.ZodTypeAny, {
|
|
299
|
+
action: "delete";
|
|
300
|
+
keys: (string | number)[];
|
|
301
|
+
collection: string;
|
|
302
|
+
payload?: Record<string, any> | undefined;
|
|
303
|
+
}, {
|
|
304
|
+
action: "delete";
|
|
305
|
+
keys: (string | number)[];
|
|
306
|
+
collection: string;
|
|
307
|
+
payload?: Record<string, any> | undefined;
|
|
308
|
+
}>]>;
|
|
309
|
+
export type WebSocketEvent = z.infer<typeof WebSocketEvent>;
|
|
310
|
+
export declare const AuthMode: z.ZodUnion<[z.ZodLiteral<"public">, z.ZodLiteral<"handshake">, z.ZodLiteral<"strict">]>;
|
|
311
|
+
export type AuthMode = z.infer<typeof AuthMode>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const zodStringOrNumber = z.union([z.string(), z.number()]);
|
|
3
|
+
export const WebSocketMessage = z
|
|
4
|
+
.object({
|
|
5
|
+
type: z.string(),
|
|
6
|
+
uid: zodStringOrNumber.optional(),
|
|
7
|
+
})
|
|
8
|
+
.passthrough();
|
|
9
|
+
export const WebSocketResponse = z.discriminatedUnion('status', [
|
|
10
|
+
WebSocketMessage.extend({
|
|
11
|
+
status: z.literal('ok'),
|
|
12
|
+
}),
|
|
13
|
+
WebSocketMessage.extend({
|
|
14
|
+
status: z.literal('error'),
|
|
15
|
+
error: z
|
|
16
|
+
.object({
|
|
17
|
+
code: z.string(),
|
|
18
|
+
message: z.string(),
|
|
19
|
+
})
|
|
20
|
+
.passthrough(),
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
23
|
+
export const ConnectionParams = z.object({ access_token: z.string().optional() });
|
|
24
|
+
export const BasicAuthMessage = z.union([
|
|
25
|
+
z.object({ email: z.string().email(), password: z.string() }),
|
|
26
|
+
z.object({ access_token: z.string() }),
|
|
27
|
+
z.object({ refresh_token: z.string() }),
|
|
28
|
+
]);
|
|
29
|
+
export const WebSocketAuthMessage = WebSocketMessage.extend({
|
|
30
|
+
type: z.literal('auth'),
|
|
31
|
+
}).and(BasicAuthMessage);
|
|
32
|
+
export const WebSocketSubscribeMessage = z.discriminatedUnion('type', [
|
|
33
|
+
WebSocketMessage.extend({
|
|
34
|
+
type: z.literal('subscribe'),
|
|
35
|
+
collection: z.string(),
|
|
36
|
+
event: z.union([z.literal('create'), z.literal('update'), z.literal('delete')]).optional(),
|
|
37
|
+
item: zodStringOrNumber.optional(),
|
|
38
|
+
query: z.custom().optional(),
|
|
39
|
+
}),
|
|
40
|
+
WebSocketMessage.extend({
|
|
41
|
+
type: z.literal('unsubscribe'),
|
|
42
|
+
}),
|
|
43
|
+
]);
|
|
44
|
+
const ZodItem = z.custom();
|
|
45
|
+
const PartialItemsMessage = z.object({
|
|
46
|
+
uid: zodStringOrNumber.optional(),
|
|
47
|
+
type: z.literal('items'),
|
|
48
|
+
collection: z.string(),
|
|
49
|
+
});
|
|
50
|
+
export const WebSocketItemsMessage = z.union([
|
|
51
|
+
PartialItemsMessage.extend({
|
|
52
|
+
action: z.literal('create'),
|
|
53
|
+
data: z.union([z.array(ZodItem), ZodItem]),
|
|
54
|
+
query: z.custom().optional(),
|
|
55
|
+
}),
|
|
56
|
+
PartialItemsMessage.extend({
|
|
57
|
+
action: z.literal('read'),
|
|
58
|
+
ids: z.array(zodStringOrNumber).optional(),
|
|
59
|
+
id: zodStringOrNumber.optional(),
|
|
60
|
+
query: z.custom().optional(),
|
|
61
|
+
}),
|
|
62
|
+
PartialItemsMessage.extend({
|
|
63
|
+
action: z.literal('update'),
|
|
64
|
+
data: ZodItem,
|
|
65
|
+
ids: z.array(zodStringOrNumber).optional(),
|
|
66
|
+
id: zodStringOrNumber.optional(),
|
|
67
|
+
query: z.custom().optional(),
|
|
68
|
+
}),
|
|
69
|
+
PartialItemsMessage.extend({
|
|
70
|
+
action: z.literal('delete'),
|
|
71
|
+
ids: z.array(zodStringOrNumber).optional(),
|
|
72
|
+
id: zodStringOrNumber.optional(),
|
|
73
|
+
query: z.custom().optional(),
|
|
74
|
+
}),
|
|
75
|
+
]);
|
|
76
|
+
export const WebSocketEvent = z.discriminatedUnion('action', [
|
|
77
|
+
z.object({
|
|
78
|
+
action: z.literal('create'),
|
|
79
|
+
collection: z.string(),
|
|
80
|
+
payload: z.record(z.any()).optional(),
|
|
81
|
+
key: zodStringOrNumber,
|
|
82
|
+
}),
|
|
83
|
+
z.object({
|
|
84
|
+
action: z.literal('update'),
|
|
85
|
+
collection: z.string(),
|
|
86
|
+
payload: z.record(z.any()).optional(),
|
|
87
|
+
keys: z.array(zodStringOrNumber),
|
|
88
|
+
}),
|
|
89
|
+
z.object({
|
|
90
|
+
action: z.literal('delete'),
|
|
91
|
+
collection: z.string(),
|
|
92
|
+
payload: z.record(z.any()).optional(),
|
|
93
|
+
keys: z.array(zodStringOrNumber),
|
|
94
|
+
}),
|
|
95
|
+
]);
|
|
96
|
+
export const AuthMode = z.union([z.literal('public'), z.literal('handshake'), z.literal('strict')]);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
+
import type { Accountability, Query } from '@directus/types';
|
|
5
|
+
import type { IncomingMessage } from 'http';
|
|
6
|
+
import type internal from 'stream';
|
|
7
|
+
import type { WebSocket } from 'ws';
|
|
8
|
+
export type AuthenticationState = {
|
|
9
|
+
accountability: Accountability | null;
|
|
10
|
+
expires_at: number | null;
|
|
11
|
+
refresh_token?: string;
|
|
12
|
+
};
|
|
13
|
+
export type WebSocketClient = WebSocket & AuthenticationState & {
|
|
14
|
+
uid: string | number;
|
|
15
|
+
auth_timer: NodeJS.Timer | null;
|
|
16
|
+
};
|
|
17
|
+
export type UpgradeRequest = IncomingMessage & AuthenticationState;
|
|
18
|
+
export type SubscriptionEvent = 'create' | 'update' | 'delete';
|
|
19
|
+
export type Subscription = {
|
|
20
|
+
uid?: string | number;
|
|
21
|
+
query?: Query;
|
|
22
|
+
item?: string | number;
|
|
23
|
+
event?: SubscriptionEvent;
|
|
24
|
+
collection: string;
|
|
25
|
+
client: WebSocketClient;
|
|
26
|
+
};
|
|
27
|
+
export type UpgradeContext = {
|
|
28
|
+
request: IncomingMessage;
|
|
29
|
+
socket: internal.Duplex;
|
|
30
|
+
head: Buffer;
|
|
31
|
+
};
|
|
32
|
+
export type GraphQLSocket = {
|
|
33
|
+
client: WebSocketClient;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getExpiresAtForToken(token: string): number | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebSocketClient } from '../types.js';
|
|
2
|
+
export declare const fmtMessage: (type: string, data?: Record<string, any>, uid?: string | number) => string;
|
|
3
|
+
export declare const safeSend: (client: WebSocketClient, data: string, delay?: number) => Promise<unknown>;
|
|
4
|
+
export declare const getMessageType: (message: any) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// a simple util for building a message object
|
|
2
|
+
export const fmtMessage = (type, data = {}, uid) => {
|
|
3
|
+
const message = { type, ...data };
|
|
4
|
+
if (uid !== undefined) {
|
|
5
|
+
message['uid'] = uid;
|
|
6
|
+
}
|
|
7
|
+
return JSON.stringify(message);
|
|
8
|
+
};
|
|
9
|
+
// we may need this later for slow connections
|
|
10
|
+
export const safeSend = async (client, data, delay = 100) => {
|
|
11
|
+
if (client.readyState !== client.OPEN)
|
|
12
|
+
return false;
|
|
13
|
+
if (client.bufferedAmount > 0) {
|
|
14
|
+
// wait for the buffer to clear
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
safeSend(client, data, delay).then((success) => resolve(success));
|
|
18
|
+
}, delay);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
client.send(data);
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
// an often used message type extractor function
|
|
25
|
+
export const getMessageType = (message) => {
|
|
26
|
+
return typeof message !== 'object' || Array.isArray(message) || message === null ? '' : String(message.type);
|
|
27
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebSocket } from 'ws';
|
|
2
|
+
import { WebSocketMessage } from '../messages.js';
|
|
3
|
+
export declare const waitForAnyMessage: (client: WebSocket, timeout: number) => Promise<Record<string, any>>;
|
|
4
|
+
export declare const waitForMessageType: (client: WebSocket, type: string, timeout: number) => Promise<WebSocketMessage>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parseJSON } from '@directus/utils';
|
|
2
|
+
import { WebSocketMessage } from '../messages.js';
|
|
3
|
+
import { getMessageType } from './message.js';
|
|
4
|
+
export const waitForAnyMessage = (client, timeout) => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
client.on('message', awaitMessage);
|
|
7
|
+
const timer = setTimeout(() => {
|
|
8
|
+
client.off('message', awaitMessage);
|
|
9
|
+
reject();
|
|
10
|
+
}, timeout);
|
|
11
|
+
function awaitMessage(event) {
|
|
12
|
+
try {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
client.off('message', awaitMessage);
|
|
15
|
+
resolve(parseJSON(event.toString()));
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
reject(err);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export const waitForMessageType = (client, type, timeout) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
client.on('message', awaitMessage);
|
|
26
|
+
const timer = setTimeout(() => {
|
|
27
|
+
client.off('message', awaitMessage);
|
|
28
|
+
reject();
|
|
29
|
+
}, timeout);
|
|
30
|
+
function awaitMessage(event) {
|
|
31
|
+
let msg;
|
|
32
|
+
try {
|
|
33
|
+
msg = WebSocketMessage.parse(parseJSON(event.toString()));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (getMessageType(msg) === type) {
|
|
39
|
+
clearTimeout(timer);
|
|
40
|
+
client.off('message', awaitMessage);
|
|
41
|
+
resolve(msg);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.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",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"fs-extra": "11.1.1",
|
|
93
93
|
"graphql": "16.6.0",
|
|
94
94
|
"graphql-compose": "9.0.10",
|
|
95
|
+
"graphql-ws": "5.12.0",
|
|
95
96
|
"helmet": "7.0.0",
|
|
96
97
|
"icc": "3.0.0",
|
|
97
98
|
"inquirer": "9.2.4",
|
|
@@ -139,20 +140,24 @@
|
|
|
139
140
|
"uuid-validate": "0.0.3",
|
|
140
141
|
"vm2": "3.9.19",
|
|
141
142
|
"wellknown": "0.5.0",
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"@directus/
|
|
146
|
-
"@directus/
|
|
143
|
+
"ws": "8.12.1",
|
|
144
|
+
"zod": "3.21.4",
|
|
145
|
+
"zod-validation-error": "1.0.1",
|
|
146
|
+
"@directus/app": "10.4.0",
|
|
147
|
+
"@directus/constants": "10.2.1",
|
|
148
|
+
"@directus/errors": "0.0.1",
|
|
149
|
+
"@directus/extensions-sdk": "10.1.5",
|
|
150
|
+
"@directus/pressure": "1.0.5",
|
|
147
151
|
"@directus/schema": "10.0.1",
|
|
148
152
|
"@directus/specs": "10.1.1",
|
|
149
|
-
"@directus/storage": "10.0.
|
|
150
|
-
"@directus/storage-driver-azure": "10.0.
|
|
151
|
-
"@directus/storage-driver-cloudinary": "10.0.
|
|
152
|
-
"@directus/storage-driver-gcs": "10.0.
|
|
153
|
-
"@directus/storage-driver-local": "10.0.
|
|
154
|
-
"@directus/storage-driver-s3": "10.0.
|
|
155
|
-
"@directus/utils": "10.0.
|
|
153
|
+
"@directus/storage": "10.0.4",
|
|
154
|
+
"@directus/storage-driver-azure": "10.0.6",
|
|
155
|
+
"@directus/storage-driver-cloudinary": "10.0.6",
|
|
156
|
+
"@directus/storage-driver-gcs": "10.0.6",
|
|
157
|
+
"@directus/storage-driver-local": "10.0.6",
|
|
158
|
+
"@directus/storage-driver-s3": "10.0.6",
|
|
159
|
+
"@directus/utils": "10.0.6",
|
|
160
|
+
"@directus/validation": "0.0.1"
|
|
156
161
|
},
|
|
157
162
|
"devDependencies": {
|
|
158
163
|
"@ngneat/falso": "6.4.0",
|
|
@@ -191,6 +196,7 @@
|
|
|
191
196
|
"@types/uuid": "9.0.1",
|
|
192
197
|
"@types/uuid-validate": "0.0.1",
|
|
193
198
|
"@types/wellknown": "0.5.4",
|
|
199
|
+
"@types/ws": "8.5.4",
|
|
194
200
|
"@vitest/coverage-c8": "0.31.1",
|
|
195
201
|
"copyfiles": "2.4.1",
|
|
196
202
|
"form-data": "4.0.0",
|
|
@@ -198,13 +204,12 @@
|
|
|
198
204
|
"supertest": "6.3.3",
|
|
199
205
|
"typescript": "5.0.4",
|
|
200
206
|
"vitest": "0.31.1",
|
|
207
|
+
"@directus/random": "0.2.1",
|
|
201
208
|
"@directus/tsconfig": "0.0.7",
|
|
202
|
-
"@directus/types": "10.1.
|
|
209
|
+
"@directus/types": "10.1.2"
|
|
203
210
|
},
|
|
204
211
|
"optionalDependencies": {
|
|
205
212
|
"@keyv/redis": "2.5.8",
|
|
206
|
-
"keyv-memcache": "1.3.3",
|
|
207
|
-
"memcached": "2.2.2",
|
|
208
213
|
"mysql": "2.18.1",
|
|
209
214
|
"nodemailer-mailgun-transport": "2.1.5",
|
|
210
215
|
"nodemailer-sendgrid": "1.0.3",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseException } from '@directus/exceptions';
|
|
2
|
-
type Exceptions = {
|
|
3
|
-
collection: string;
|
|
4
|
-
field: string;
|
|
5
|
-
};
|
|
6
|
-
export declare class ContainsNullValuesException extends BaseException {
|
|
7
|
-
constructor(field: string, exceptions?: Exceptions);
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseException } from '@directus/exceptions';
|
|
2
|
-
type Extensions = {
|
|
3
|
-
collection: string;
|
|
4
|
-
field: string;
|
|
5
|
-
invalid?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class InvalidForeignKeyException extends BaseException {
|
|
8
|
-
constructor(field: string | null, extensions?: Extensions);
|
|
9
|
-
}
|
|
10
|
-
export {};
|