@directus/api 12.0.1 → 12.0.3

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.
@@ -183,11 +183,11 @@ const handleError = (e) => {
183
183
  if (e instanceof errors.OPError) {
184
184
  if (e.error === 'invalid_grant') {
185
185
  // Invalid token
186
- logger.trace(e, `[OAuth2] Invalid grant`);
186
+ logger.warn(e, `[OAuth2] Invalid grant`);
187
187
  return new InvalidTokenError();
188
188
  }
189
189
  // Server response error
190
- logger.trace(e, `[OAuth2] Unknown OP error`);
190
+ logger.warn(e, `[OAuth2] Unknown OP error`);
191
191
  return new ServiceUnavailableError({
192
192
  service: 'oauth2',
193
193
  reason: `Service returned unexpected response: ${e.error_description}`,
@@ -195,10 +195,10 @@ const handleError = (e) => {
195
195
  }
196
196
  else if (e instanceof errors.RPError) {
197
197
  // Internal client error
198
- logger.trace(e, `[OAuth2] Unknown RP error`);
198
+ logger.warn(e, `[OAuth2] Unknown RP error`);
199
199
  return new InvalidCredentialsError();
200
200
  }
201
- logger.trace(e, `[OAuth2] Unknown error`);
201
+ logger.warn(e, `[OAuth2] Unknown error`);
202
202
  return e;
203
203
  };
204
204
  export function createOAuth2AuthRouter(providerName) {
@@ -205,11 +205,11 @@ const handleError = (e) => {
205
205
  if (e instanceof errors.OPError) {
206
206
  if (e.error === 'invalid_grant') {
207
207
  // Invalid token
208
- logger.trace(e, `[OpenID] Invalid grant`);
208
+ logger.warn(e, `[OpenID] Invalid grant`);
209
209
  return new InvalidTokenError();
210
210
  }
211
211
  // Server response error
212
- logger.trace(e, `[OpenID] Unknown OP error`);
212
+ logger.warn(e, `[OpenID] Unknown OP error`);
213
213
  return new ServiceUnavailableError({
214
214
  service: 'openid',
215
215
  reason: `Service returned unexpected response: ${e.error_description}`,
@@ -217,10 +217,10 @@ const handleError = (e) => {
217
217
  }
218
218
  else if (e instanceof errors.RPError) {
219
219
  // Internal client error
220
- logger.trace(e, `[OpenID] Unknown RP error`);
220
+ logger.warn(e, `[OpenID] Unknown RP error`);
221
221
  return new InvalidCredentialsError();
222
222
  }
223
- logger.trace(e, `[OpenID] Unknown error`);
223
+ logger.warn(e, `[OpenID] Unknown error`);
224
224
  return e;
225
225
  };
226
226
  export function createOpenIDAuthRouter(providerName) {
@@ -45,7 +45,7 @@ export class SAMLAuthDriver extends LocalAuthDriver {
45
45
  if (userID)
46
46
  return userID;
47
47
  if (!allowPublicRegistration) {
48
- logger.trace(`[SAML] User doesn't exist, and public registration not allowed for provider "${provider}"`);
48
+ logger.warn(`[SAML] User doesn't exist, and public registration not allowed for provider "${provider}"`);
49
49
  throw new InvalidCredentialsError();
50
50
  }
51
51
  const firstName = payload[givenNameKey ?? 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname'];
@@ -3,6 +3,8 @@ type Options = {
3
3
  subject: string;
4
4
  message?: unknown | null;
5
5
  permissions: string;
6
+ collection?: string;
7
+ item?: string;
6
8
  };
7
9
  declare const _default: import("@directus/types").OperationApiConfig<Options>;
8
10
  export default _default;
@@ -3,7 +3,7 @@ import { NotificationsService } from '../../services/notifications.js';
3
3
  import { getAccountabilityForRole } from '../../utils/get-accountability-for-role.js';
4
4
  export default defineOperationApi({
5
5
  id: 'notification',
6
- handler: async ({ recipient, subject, message, permissions }, { accountability, database, getSchema }) => {
6
+ handler: async ({ recipient, subject, message, permissions, collection, item }, { accountability, database, getSchema }) => {
7
7
  const schema = await getSchema({ database });
8
8
  let customAccountability;
9
9
  if (!permissions || permissions === '$trigger') {
@@ -24,12 +24,16 @@ export default defineOperationApi({
24
24
  knex: database,
25
25
  });
26
26
  const messageString = message ? optionToString(message) : null;
27
+ const collectionString = message ? optionToString(collection) : null;
28
+ const itemString = message ? optionToString(item) : null;
27
29
  const payload = toArray(recipient).map((userId) => {
28
30
  return {
29
31
  recipient: userId,
30
32
  sender: customAccountability?.user ?? null,
31
33
  subject,
32
34
  message: messageString,
35
+ collection: collectionString,
36
+ item: itemString,
33
37
  };
34
38
  });
35
39
  const result = await notificationsService.createMany(payload);
@@ -2,6 +2,8 @@ import getDatabase from '../database/index.js';
2
2
  import { systemCollectionRows } from '../database/system-data/collections/index.js';
3
3
  import emitter from '../emitter.js';
4
4
  import { ForbiddenError, InvalidPayloadError } from '../errors/index.js';
5
+ import { getCache } from '../cache.js';
6
+ import { shouldClearCache } from '../utils/should-clear-cache.js';
5
7
  export class UtilsService {
6
8
  knex;
7
9
  accountability;
@@ -95,6 +97,11 @@ export class UtilsService {
95
97
  .andWhere(sortField, '<=', sourceSortValue)
96
98
  .andWhereNot({ [primaryKeyField]: item });
97
99
  }
100
+ // check if cache should be cleared
101
+ const { cache } = getCache();
102
+ if (shouldClearCache(cache, undefined, collection)) {
103
+ await cache.clear();
104
+ }
98
105
  emitter.emitAction(['items.sort', `${collection}.items.sort`], {
99
106
  collection,
100
107
  item,
@@ -8,11 +8,13 @@ import { getEnv } from '../env.js';
8
8
  */
9
9
  export function shouldClearCache(cache, opts, collection) {
10
10
  const env = getEnv();
11
- if (collection && env['CACHE_AUTO_PURGE_IGNORE_LIST'].includes(collection)) {
12
- return false;
13
- }
14
- if (cache && env['CACHE_AUTO_PURGE'] && opts?.autoPurgeCache !== false) {
15
- return true;
11
+ if (env['CACHE_AUTO_PURGE']) {
12
+ if (collection && env['CACHE_AUTO_PURGE_IGNORE_LIST'].includes(collection)) {
13
+ return false;
14
+ }
15
+ if (cache && opts?.autoPurgeCache !== false) {
16
+ return true;
17
+ }
16
18
  }
17
19
  return false;
18
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/api",
3
- "version": "12.0.1",
3
+ "version": "12.0.3",
4
4
  "description": "Directus is a real-time API and App dashboard for managing SQL database content",
5
5
  "keywords": [
6
6
  "directus",
@@ -143,21 +143,21 @@
143
143
  "ws": "8.12.1",
144
144
  "zod": "3.21.4",
145
145
  "zod-validation-error": "1.0.1",
146
- "@directus/app": "10.4.1",
146
+ "@directus/app": "10.5.0",
147
147
  "@directus/constants": "10.2.1",
148
148
  "@directus/errors": "0.0.1",
149
- "@directus/extensions-sdk": "10.1.5",
150
- "@directus/pressure": "1.0.5",
149
+ "@directus/extensions-sdk": "10.1.6",
150
+ "@directus/pressure": "1.0.6",
151
151
  "@directus/schema": "10.0.1",
152
152
  "@directus/specs": "10.1.1",
153
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"
154
+ "@directus/storage-driver-azure": "10.0.7",
155
+ "@directus/storage-driver-cloudinary": "10.0.7",
156
+ "@directus/storage-driver-gcs": "10.0.7",
157
+ "@directus/storage-driver-local": "10.0.7",
158
+ "@directus/storage-driver-s3": "10.0.7",
159
+ "@directus/utils": "10.0.7",
160
+ "@directus/validation": "0.0.2"
161
161
  },
162
162
  "devDependencies": {
163
163
  "@ngneat/falso": "6.4.0",