@directus/api 29.0.0 → 29.1.1

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.
Files changed (129) hide show
  1. package/dist/auth/drivers/openid.js +12 -6
  2. package/dist/cli/commands/init/index.js +2 -2
  3. package/dist/cli/commands/init/questions.d.ts +1 -1
  4. package/dist/cli/commands/schema/apply.js +1 -1
  5. package/dist/cli/index.js +1 -0
  6. package/dist/cli/utils/create-db-connection.d.ts +1 -1
  7. package/dist/cli/utils/create-env/index.d.ts +1 -1
  8. package/dist/cli/utils/drivers.d.ts +1 -1
  9. package/dist/constants.d.ts +1 -1
  10. package/dist/controllers/assets.js +1 -1
  11. package/dist/controllers/extensions.js +1 -1
  12. package/dist/database/helpers/index.d.ts +4 -4
  13. package/dist/database/helpers/schema/types.d.ts +1 -2
  14. package/dist/database/index.d.ts +1 -1
  15. package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -1
  16. package/dist/database/migrations/20240924B-populate-versioning-deltas.js +1 -1
  17. package/dist/database/run-ast/lib/apply-query/filter/get-filter-type.d.ts +2 -2
  18. package/dist/extensions/lib/get-extensions-settings.d.ts +1 -1
  19. package/dist/extensions/lib/sandbox/generate-api-extensions-sandbox-entrypoint.d.ts +1 -1
  20. package/dist/extensions/manager.d.ts +1 -2
  21. package/dist/extensions/manager.js +3 -2
  22. package/dist/flows.d.ts +1 -2
  23. package/dist/operations/throw-error/index.d.ts +7 -0
  24. package/dist/operations/throw-error/index.js +11 -0
  25. package/dist/permissions/utils/fetch-share-info.d.ts +1 -1
  26. package/dist/services/access.d.ts +1 -2
  27. package/dist/services/access.js +1 -1
  28. package/dist/services/activity.d.ts +1 -1
  29. package/dist/services/assets.d.ts +1 -3
  30. package/dist/services/authentication.d.ts +1 -2
  31. package/dist/services/collections.d.ts +3 -10
  32. package/dist/services/comments.d.ts +1 -2
  33. package/dist/services/dashboards.d.ts +1 -1
  34. package/dist/services/extensions.d.ts +2 -4
  35. package/dist/services/fields.d.ts +1 -2
  36. package/dist/services/files.d.ts +2 -3
  37. package/dist/services/flows.d.ts +1 -2
  38. package/dist/services/folders.d.ts +1 -1
  39. package/dist/services/graphql/errors/format.d.ts +1 -1
  40. package/dist/services/graphql/errors/format.js +0 -1
  41. package/dist/services/graphql/index.d.ts +1 -3
  42. package/dist/services/graphql/resolvers/system-admin.d.ts +1 -1
  43. package/dist/services/graphql/resolvers/system-global.d.ts +1 -1
  44. package/dist/services/graphql/resolvers/system.d.ts +1 -1
  45. package/dist/services/graphql/schema/get-types.d.ts +1 -1
  46. package/dist/services/graphql/schema/get-types.js +0 -1
  47. package/dist/services/import-export.d.ts +2 -4
  48. package/dist/services/items.d.ts +2 -12
  49. package/dist/services/items.js +2 -1
  50. package/dist/services/mail/index.d.ts +2 -4
  51. package/dist/services/mail/index.js +11 -5
  52. package/dist/services/meta.d.ts +1 -2
  53. package/dist/services/notifications.d.ts +1 -2
  54. package/dist/services/operations.d.ts +1 -2
  55. package/dist/services/panels.d.ts +1 -1
  56. package/dist/services/payload.d.ts +9 -17
  57. package/dist/services/payload.js +1 -1
  58. package/dist/services/permissions.d.ts +1 -3
  59. package/dist/services/policies.d.ts +1 -2
  60. package/dist/services/policies.js +1 -1
  61. package/dist/services/presets.d.ts +1 -1
  62. package/dist/services/relations.d.ts +2 -3
  63. package/dist/services/revisions.d.ts +1 -2
  64. package/dist/services/roles.d.ts +1 -2
  65. package/dist/services/roles.js +1 -1
  66. package/dist/services/schema.d.ts +1 -2
  67. package/dist/services/server.d.ts +1 -2
  68. package/dist/services/settings.d.ts +1 -1
  69. package/dist/services/shares.d.ts +1 -2
  70. package/dist/services/specifications.d.ts +1 -2
  71. package/dist/services/tfa.d.ts +1 -2
  72. package/dist/services/translations.d.ts +1 -3
  73. package/dist/services/users.d.ts +1 -2
  74. package/dist/services/users.js +1 -1
  75. package/dist/services/utils.d.ts +1 -2
  76. package/dist/services/versions.d.ts +1 -2
  77. package/dist/services/webhooks.d.ts +1 -2
  78. package/dist/services/websocket.d.ts +1 -3
  79. package/dist/types/auth.d.ts +0 -6
  80. package/dist/types/index.d.ts +0 -7
  81. package/dist/types/index.js +0 -7
  82. package/dist/utils/apply-diff.d.ts +1 -2
  83. package/dist/utils/apply-diff.js +1 -1
  84. package/dist/utils/apply-snapshot.d.ts +1 -2
  85. package/dist/utils/get-ip-from-req.js +1 -1
  86. package/dist/utils/get-service.d.ts +1 -1
  87. package/dist/utils/get-snapshot-diff.d.ts +1 -1
  88. package/dist/utils/get-snapshot-diff.js +1 -1
  89. package/dist/utils/get-snapshot.d.ts +1 -2
  90. package/dist/utils/schedule.js +4 -1
  91. package/dist/utils/should-clear-cache.d.ts +1 -1
  92. package/dist/utils/transformations.d.ts +1 -2
  93. package/dist/utils/validate-diff.d.ts +1 -1
  94. package/dist/utils/validate-diff.js +1 -1
  95. package/dist/utils/validate-snapshot.d.ts +1 -1
  96. package/dist/utils/validate-snapshot.js +1 -1
  97. package/dist/utils/validate-user-count-integrity.d.ts +1 -8
  98. package/dist/utils/validate-user-count-integrity.js +1 -9
  99. package/dist/websocket/controllers/base.d.ts +2 -1
  100. package/dist/websocket/controllers/base.js +2 -1
  101. package/dist/websocket/controllers/graphql.js +1 -1
  102. package/dist/websocket/controllers/logs.js +1 -1
  103. package/dist/websocket/controllers/rest.d.ts +1 -1
  104. package/dist/websocket/controllers/rest.js +1 -1
  105. package/dist/websocket/errors.d.ts +1 -1
  106. package/dist/websocket/handlers/heartbeat.d.ts +1 -1
  107. package/dist/websocket/handlers/heartbeat.js +1 -1
  108. package/dist/websocket/messages.d.ts +57 -308
  109. package/dist/websocket/messages.js +5 -10
  110. package/dist/websocket/utils/items.d.ts +1 -1
  111. package/dist/websocket/utils/wait-for-message.d.ts +1 -1
  112. package/dist/websocket/utils/wait-for-message.js +1 -1
  113. package/package.json +80 -81
  114. package/dist/extensions/types.d.ts +0 -19
  115. package/dist/extensions/types.js +0 -1
  116. package/dist/types/assets.d.ts +0 -22
  117. package/dist/types/assets.js +0 -51
  118. package/dist/types/database.d.ts +0 -3
  119. package/dist/types/database.js +0 -1
  120. package/dist/types/graphql.d.ts +0 -14
  121. package/dist/types/graphql.js +0 -1
  122. package/dist/types/items.d.ts +0 -52
  123. package/dist/types/items.js +0 -1
  124. package/dist/types/services.d.ts +0 -22
  125. package/dist/types/services.js +0 -1
  126. package/dist/types/snapshot.d.ts +0 -55
  127. package/dist/types/snapshot.js +0 -13
  128. package/dist/types/webhooks.d.ts +0 -15
  129. package/dist/types/webhooks.js +0 -1
@@ -1,5 +1,5 @@
1
+ import { WebSocketMessage } from '@directus/types';
1
2
  import type { Server as httpServer } from 'http';
2
- import { WebSocketMessage } from '../messages.js';
3
3
  import SocketController from './base.js';
4
4
  export declare class WebSocketController extends SocketController {
5
5
  constructor(httpServer: httpServer);
@@ -1,9 +1,9 @@
1
1
  import { parseJSON } from '@directus/utils';
2
+ import { WebSocketMessage } from '@directus/types';
2
3
  import emitter from '../../emitter.js';
3
4
  import { useLogger } from '../../logger/index.js';
4
5
  import { getAddress } from '../../utils/get-address.js';
5
6
  import { WebSocketError, handleWebSocketError } from '../errors.js';
6
- import { WebSocketMessage } from '../messages.js';
7
7
  import SocketController from './base.js';
8
8
  import { registerWebSocketEvents } from './hooks.js';
9
9
  const logger = useLogger();
@@ -1,4 +1,4 @@
1
- import type { DirectusError } from '@directus/errors';
1
+ import { type DirectusError } from '@directus/errors';
2
2
  import type { WebSocket } from 'ws';
3
3
  import { ZodError } from 'zod';
4
4
  import type { WebSocketResponse } from './messages.js';
@@ -1,5 +1,5 @@
1
+ import { WebSocketMessage } from '@directus/types';
1
2
  import { WebSocketController } from '../controllers/index.js';
2
- import { WebSocketMessage } from '../messages.js';
3
3
  import type { WebSocketClient } from '../types.js';
4
4
  export declare class HeartbeatHandler {
5
5
  private pulse;
@@ -1,9 +1,9 @@
1
1
  import { useEnv } from '@directus/env';
2
2
  import { ServiceUnavailableError } from '@directus/errors';
3
+ import { WebSocketMessage } from '@directus/types';
3
4
  import { toBoolean } from '@directus/utils';
4
5
  import emitter from '../../emitter.js';
5
6
  import { WebSocketController, getWebSocketController } from '../controllers/index.js';
6
- import { WebSocketMessage } from '../messages.js';
7
7
  import { fmtMessage, getMessageType } from '../utils/message.js';
8
8
  const env = useEnv();
9
9
  const HEARTBEAT_FREQUENCY = Number(env['WEBSOCKETS_HEARTBEAT_PERIOD']) * 1000;
@@ -1,365 +1,114 @@
1
1
  import type { Item, Query } from '@directus/types';
2
2
  import { z } from 'zod';
3
- export declare const WebSocketMessage: z.ZodObject<{
3
+ export declare const WebSocketResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
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<z.objectUtil.extendShape<{
15
- type: z.ZodString;
16
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
17
- }, {
18
- status: z.ZodLiteral<"ok">;
19
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
20
- type: z.ZodString;
21
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
22
- }, {
23
- status: z.ZodLiteral<"ok">;
24
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
25
- type: z.ZodString;
26
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
27
- }, {
5
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
28
6
  status: z.ZodLiteral<"ok">;
29
- }>, z.ZodTypeAny, "passthrough">>, z.ZodObject<z.objectUtil.extendShape<{
7
+ }, z.core.$loose>, z.ZodObject<{
30
8
  type: z.ZodString;
31
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
32
- }, {
9
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
33
10
  status: z.ZodLiteral<"error">;
34
11
  error: z.ZodObject<{
35
12
  code: z.ZodString;
36
13
  message: z.ZodString;
37
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
38
- code: z.ZodString;
39
- message: z.ZodString;
40
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
41
- code: z.ZodString;
42
- message: z.ZodString;
43
- }, z.ZodTypeAny, "passthrough">>;
44
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
45
- type: z.ZodString;
46
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
47
- }, {
48
- status: z.ZodLiteral<"error">;
49
- error: z.ZodObject<{
50
- code: z.ZodString;
51
- message: z.ZodString;
52
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
53
- code: z.ZodString;
54
- message: z.ZodString;
55
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
56
- code: z.ZodString;
57
- message: z.ZodString;
58
- }, z.ZodTypeAny, "passthrough">>;
59
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
60
- type: z.ZodString;
61
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
62
- }, {
63
- status: z.ZodLiteral<"error">;
64
- error: z.ZodObject<{
65
- code: z.ZodString;
66
- message: z.ZodString;
67
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
68
- code: z.ZodString;
69
- message: z.ZodString;
70
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
71
- code: z.ZodString;
72
- message: z.ZodString;
73
- }, z.ZodTypeAny, "passthrough">>;
74
- }>, z.ZodTypeAny, "passthrough">>]>;
14
+ }, z.core.$loose>;
15
+ }, z.core.$loose>]>;
75
16
  export type WebSocketResponse = z.infer<typeof WebSocketResponse>;
76
17
  export declare const ConnectionParams: z.ZodObject<{
77
18
  access_token: z.ZodOptional<z.ZodString>;
78
- }, "strip", z.ZodTypeAny, {
79
- access_token?: string | undefined;
80
- }, {
81
- access_token?: string | undefined;
82
- }>;
19
+ }, z.core.$strip>;
83
20
  export type ConnectionParams = z.infer<typeof ConnectionParams>;
84
- export declare const BasicAuthMessage: z.ZodUnion<[z.ZodObject<{
21
+ export declare const BasicAuthMessage: z.ZodUnion<readonly [z.ZodObject<{
85
22
  email: z.ZodString;
86
23
  password: z.ZodString;
87
- }, "strip", z.ZodTypeAny, {
88
- email: string;
89
- password: string;
90
- }, {
91
- email: string;
92
- password: string;
93
- }>, z.ZodObject<{
24
+ }, z.core.$strip>, z.ZodObject<{
94
25
  access_token: z.ZodString;
95
- }, "strip", z.ZodTypeAny, {
96
- access_token: string;
97
- }, {
98
- access_token: string;
99
- }>, z.ZodObject<{
26
+ }, z.core.$strip>, z.ZodObject<{
100
27
  refresh_token: z.ZodString;
101
- }, "strip", z.ZodTypeAny, {
102
- refresh_token: string;
103
- }, {
104
- refresh_token: string;
105
- }>]>;
28
+ }, z.core.$strip>]>;
106
29
  export type BasicAuthMessage = z.infer<typeof BasicAuthMessage>;
107
- export declare const WebSocketAuthMessage: z.ZodIntersection<z.ZodObject<z.objectUtil.extendShape<{
108
- type: z.ZodString;
109
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
110
- }, {
111
- type: z.ZodLiteral<"auth">;
112
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
113
- type: z.ZodString;
114
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
115
- }, {
116
- type: z.ZodLiteral<"auth">;
117
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
118
- type: z.ZodString;
119
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
120
- }, {
30
+ export declare const WebSocketAuthMessage: z.ZodIntersection<z.ZodObject<{
31
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
121
32
  type: z.ZodLiteral<"auth">;
122
- }>, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
33
+ }, z.core.$loose>, z.ZodUnion<readonly [z.ZodObject<{
123
34
  email: z.ZodString;
124
35
  password: z.ZodString;
125
- }, "strip", z.ZodTypeAny, {
126
- email: string;
127
- password: string;
128
- }, {
129
- email: string;
130
- password: string;
131
- }>, z.ZodObject<{
36
+ }, z.core.$strip>, z.ZodObject<{
132
37
  access_token: z.ZodString;
133
- }, "strip", z.ZodTypeAny, {
134
- access_token: string;
135
- }, {
136
- access_token: string;
137
- }>, z.ZodObject<{
38
+ }, z.core.$strip>, z.ZodObject<{
138
39
  refresh_token: z.ZodString;
139
- }, "strip", z.ZodTypeAny, {
140
- refresh_token: string;
141
- }, {
142
- refresh_token: string;
143
- }>]>>;
40
+ }, z.core.$strip>]>>;
144
41
  export type WebSocketAuthMessage = z.infer<typeof WebSocketAuthMessage>;
145
- export declare const WebSocketSubscribeMessage: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
146
- type: z.ZodString;
147
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
148
- }, {
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.ZodRecord<z.ZodString, z.ZodAny>>;
154
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
155
- type: z.ZodString;
156
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
157
- }, {
158
- type: z.ZodLiteral<"subscribe">;
159
- collection: z.ZodString;
160
- event: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"create">, z.ZodLiteral<"update">, z.ZodLiteral<"delete">]>>;
161
- item: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
162
- query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
163
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
164
- type: z.ZodString;
165
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
166
- }, {
42
+ export declare const WebSocketSubscribeMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
43
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
167
44
  type: z.ZodLiteral<"subscribe">;
168
45
  collection: z.ZodString;
169
- event: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"create">, z.ZodLiteral<"update">, z.ZodLiteral<"delete">]>>;
170
- item: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
46
+ event: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"create">, z.ZodLiteral<"update">, z.ZodLiteral<"delete">]>>;
47
+ item: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
171
48
  query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
172
- }>, z.ZodTypeAny, "passthrough">>, z.ZodObject<z.objectUtil.extendShape<{
173
- type: z.ZodString;
174
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
175
- }, {
49
+ }, z.core.$loose>, z.ZodObject<{
50
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
176
51
  type: z.ZodLiteral<"unsubscribe">;
177
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
178
- type: z.ZodString;
179
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
180
- }, {
181
- type: z.ZodLiteral<"unsubscribe">;
182
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
183
- type: z.ZodString;
184
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
185
- }, {
186
- type: z.ZodLiteral<"unsubscribe">;
187
- }>, z.ZodTypeAny, "passthrough">>]>;
52
+ }, z.core.$loose>]>;
188
53
  export type WebSocketSubscribeMessage = z.infer<typeof WebSocketSubscribeMessage>;
189
- export declare const WebSocketLogsMessage: z.ZodUnion<[z.ZodObject<{
54
+ export declare const WebSocketLogsMessage: z.ZodUnion<readonly [z.ZodObject<{
190
55
  type: z.ZodLiteral<"subscribe">;
191
56
  log_level: z.ZodString;
192
- }, "strip", z.ZodTypeAny, {
193
- type: "subscribe";
194
- log_level: string;
195
- }, {
196
- type: "subscribe";
197
- log_level: string;
198
- }>, z.ZodObject<z.objectUtil.extendShape<{
199
- type: z.ZodString;
200
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
201
- }, {
202
- type: z.ZodLiteral<"unsubscribe">;
203
- }>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
204
- type: z.ZodString;
205
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
206
- }, {
207
- type: z.ZodLiteral<"unsubscribe">;
208
- }>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
209
- type: z.ZodString;
210
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
211
- }, {
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
212
59
  type: z.ZodLiteral<"unsubscribe">;
213
- }>, z.ZodTypeAny, "passthrough">>]>;
60
+ }, z.core.$loose>]>;
214
61
  export type WebSocketLogsMessage = z.infer<typeof WebSocketLogsMessage>;
215
- export declare const WebSocketItemsMessage: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
216
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
62
+ export declare const WebSocketItemsMessage: z.ZodUnion<readonly [z.ZodObject<{
63
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
217
64
  type: z.ZodLiteral<"items">;
218
65
  collection: z.ZodString;
219
- }, {
220
66
  action: z.ZodLiteral<"create">;
221
- data: z.ZodUnion<[z.ZodArray<z.ZodType<Partial<Item>, z.ZodTypeDef, Partial<Item>>, "many">, z.ZodType<Partial<Item>, z.ZodTypeDef, Partial<Item>>]>;
222
- query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
223
- }>, "strip", z.ZodTypeAny, {
224
- collection: string;
225
- type: "items";
226
- action: "create";
227
- data: Partial<Item> | Partial<Item>[];
228
- query?: Query | undefined;
229
- uid?: string | number | undefined;
230
- }, {
231
- collection: string;
232
- type: "items";
233
- action: "create";
234
- data: Partial<Item> | Partial<Item>[];
235
- query?: Query | undefined;
236
- uid?: string | number | undefined;
237
- }>, z.ZodObject<z.objectUtil.extendShape<{
238
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
67
+ data: z.ZodUnion<readonly [z.ZodArray<z.ZodCustom<Partial<Item>, Partial<Item>>>, z.ZodCustom<Partial<Item>, Partial<Item>>]>;
68
+ query: z.ZodOptional<z.ZodCustom<Query, Query>>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
239
71
  type: z.ZodLiteral<"items">;
240
72
  collection: z.ZodString;
241
- }, {
242
73
  action: z.ZodLiteral<"read">;
243
- ids: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
244
- id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
245
- query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
246
- }>, "strip", z.ZodTypeAny, {
247
- collection: string;
248
- type: "items";
249
- action: "read";
250
- id?: string | number | undefined;
251
- query?: Query | undefined;
252
- uid?: string | number | undefined;
253
- ids?: (string | number)[] | undefined;
254
- }, {
255
- collection: string;
256
- type: "items";
257
- action: "read";
258
- id?: string | number | undefined;
259
- query?: Query | undefined;
260
- uid?: string | number | undefined;
261
- ids?: (string | number)[] | undefined;
262
- }>, z.ZodObject<z.objectUtil.extendShape<{
263
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
74
+ ids: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
75
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
76
+ query: z.ZodOptional<z.ZodCustom<Query, Query>>;
77
+ }, z.core.$strip>, z.ZodObject<{
78
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
264
79
  type: z.ZodLiteral<"items">;
265
80
  collection: z.ZodString;
266
- }, {
267
81
  action: z.ZodLiteral<"update">;
268
- data: z.ZodType<Partial<Item>, z.ZodTypeDef, Partial<Item>>;
269
- ids: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
270
- id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
271
- query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
272
- }>, "strip", z.ZodTypeAny, {
273
- collection: string;
274
- type: "items";
275
- action: "update";
276
- data: Partial<Item>;
277
- id?: string | number | undefined;
278
- query?: Query | undefined;
279
- uid?: string | number | undefined;
280
- ids?: (string | number)[] | undefined;
281
- }, {
282
- collection: string;
283
- type: "items";
284
- action: "update";
285
- data: Partial<Item>;
286
- id?: string | number | undefined;
287
- query?: Query | undefined;
288
- uid?: string | number | undefined;
289
- ids?: (string | number)[] | undefined;
290
- }>, z.ZodObject<z.objectUtil.extendShape<{
291
- uid: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
82
+ data: z.ZodCustom<Partial<Item>, Partial<Item>>;
83
+ ids: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
84
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
85
+ query: z.ZodOptional<z.ZodCustom<Query, Query>>;
86
+ }, z.core.$strip>, z.ZodObject<{
87
+ uid: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
292
88
  type: z.ZodLiteral<"items">;
293
89
  collection: z.ZodString;
294
- }, {
295
90
  action: z.ZodLiteral<"delete">;
296
- ids: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
297
- id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
298
- query: z.ZodOptional<z.ZodType<Query, z.ZodTypeDef, Query>>;
299
- }>, "strip", z.ZodTypeAny, {
300
- collection: string;
301
- type: "items";
302
- action: "delete";
303
- id?: string | number | undefined;
304
- query?: Query | undefined;
305
- uid?: string | number | undefined;
306
- ids?: (string | number)[] | undefined;
307
- }, {
308
- collection: string;
309
- type: "items";
310
- action: "delete";
311
- id?: string | number | undefined;
312
- query?: Query | undefined;
313
- uid?: string | number | undefined;
314
- ids?: (string | number)[] | undefined;
315
- }>]>;
91
+ ids: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
92
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
93
+ query: z.ZodOptional<z.ZodCustom<Query, Query>>;
94
+ }, z.core.$strip>]>;
316
95
  export type WebSocketItemsMessage = z.infer<typeof WebSocketItemsMessage>;
317
- export declare const WebSocketEvent: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
96
+ export declare const WebSocketEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
318
97
  action: z.ZodLiteral<"create">;
319
98
  collection: z.ZodString;
320
99
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
321
- key: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
322
- }, "strip", z.ZodTypeAny, {
323
- collection: string;
324
- key: string | number;
325
- action: "create";
326
- payload?: Record<string, any> | undefined;
327
- }, {
328
- collection: string;
329
- key: string | number;
330
- action: "create";
331
- payload?: Record<string, any> | undefined;
332
- }>, z.ZodObject<{
100
+ key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
101
+ }, z.core.$strip>, z.ZodObject<{
333
102
  action: z.ZodLiteral<"update">;
334
103
  collection: z.ZodString;
335
104
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
336
- keys: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
337
- }, "strip", z.ZodTypeAny, {
338
- collection: string;
339
- keys: (string | number)[];
340
- action: "update";
341
- payload?: Record<string, any> | undefined;
342
- }, {
343
- collection: string;
344
- keys: (string | number)[];
345
- action: "update";
346
- payload?: Record<string, any> | undefined;
347
- }>, z.ZodObject<{
105
+ keys: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
106
+ }, z.core.$strip>, z.ZodObject<{
348
107
  action: z.ZodLiteral<"delete">;
349
108
  collection: z.ZodString;
350
109
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
351
- keys: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
352
- }, "strip", z.ZodTypeAny, {
353
- collection: string;
354
- keys: (string | number)[];
355
- action: "delete";
356
- payload?: Record<string, any> | undefined;
357
- }, {
358
- collection: string;
359
- keys: (string | number)[];
360
- action: "delete";
361
- payload?: Record<string, any> | undefined;
362
- }>]>;
110
+ keys: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
111
+ }, z.core.$strip>]>;
363
112
  export type WebSocketEvent = z.infer<typeof WebSocketEvent>;
364
- export declare const AuthMode: z.ZodUnion<[z.ZodLiteral<"public">, z.ZodLiteral<"handshake">, z.ZodLiteral<"strict">]>;
113
+ export declare const AuthMode: z.ZodUnion<readonly [z.ZodLiteral<"public">, z.ZodLiteral<"handshake">, z.ZodLiteral<"strict">]>;
365
114
  export type AuthMode = z.infer<typeof AuthMode>;
@@ -1,11 +1,6 @@
1
+ import { WebSocketMessage } from '@directus/types';
1
2
  import { z } from 'zod';
2
3
  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
4
  export const WebSocketResponse = z.discriminatedUnion('status', [
10
5
  WebSocketMessage.extend({
11
6
  status: z.literal('ok'),
@@ -35,7 +30,7 @@ export const WebSocketSubscribeMessage = z.discriminatedUnion('type', [
35
30
  collection: z.string(),
36
31
  event: z.union([z.literal('create'), z.literal('update'), z.literal('delete')]).optional(),
37
32
  item: zodStringOrNumber.optional(),
38
- query: z.record(z.any()).optional(),
33
+ query: z.record(z.string(), z.any()).optional(),
39
34
  }),
40
35
  WebSocketMessage.extend({
41
36
  type: z.literal('unsubscribe'),
@@ -86,19 +81,19 @@ export const WebSocketEvent = z.discriminatedUnion('action', [
86
81
  z.object({
87
82
  action: z.literal('create'),
88
83
  collection: z.string(),
89
- payload: z.record(z.any()).optional(),
84
+ payload: z.record(z.string(), z.any()).optional(),
90
85
  key: zodStringOrNumber,
91
86
  }),
92
87
  z.object({
93
88
  action: z.literal('update'),
94
89
  collection: z.string(),
95
- payload: z.record(z.any()).optional(),
90
+ payload: z.record(z.string(), z.any()).optional(),
96
91
  keys: z.array(zodStringOrNumber),
97
92
  }),
98
93
  z.object({
99
94
  action: z.literal('delete'),
100
95
  collection: z.string(),
101
- payload: z.record(z.any()).optional(),
96
+ payload: z.record(z.string(), z.any()).optional(),
102
97
  keys: z.array(zodStringOrNumber),
103
98
  }),
104
99
  ]);
@@ -39,5 +39,5 @@ export declare function getFieldsPayload(subscription: PSubscription, accountabi
39
39
  * @param event Event data
40
40
  * @returns the fetched data
41
41
  */
42
- export declare function getItemsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | import("@directus/types").Item | (string | number)[] | import("@directus/types").Item[]>;
42
+ export declare function getItemsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | (string | number)[] | import("@directus/types").Item | import("@directus/types").Item[]>;
43
43
  export {};
@@ -1,4 +1,4 @@
1
+ import { WebSocketMessage } from '@directus/types';
1
2
  import type { WebSocket } from 'ws';
2
- import { WebSocketMessage } from '../messages.js';
3
3
  export declare const waitForAnyMessage: (client: WebSocket, timeout: number) => Promise<Record<string, any>>;
4
4
  export declare const waitForMessageType: (client: WebSocket, type: string, timeout: number) => Promise<WebSocketMessage>;
@@ -1,5 +1,5 @@
1
1
  import { parseJSON } from '@directus/utils';
2
- import { WebSocketMessage } from '../messages.js';
2
+ import { WebSocketMessage } from '@directus/types';
3
3
  import { getMessageType } from './message.js';
4
4
  export const waitForAnyMessage = (client, timeout) => {
5
5
  return new Promise((resolve, reject) => {