@directus/api 16.0.0 → 17.0.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 (92) hide show
  1. package/dist/controllers/items.js +8 -7
  2. package/dist/controllers/permissions.js +11 -2
  3. package/dist/controllers/utils.js +13 -32
  4. package/dist/extensions/lib/sandbox/generate-api-extensions-sandbox-entrypoint.d.ts +1 -1
  5. package/dist/flows.js +2 -1
  6. package/dist/middleware/collection-exists.js +6 -6
  7. package/dist/middleware/respond.js +1 -1
  8. package/dist/operations/request/index.js +5 -5
  9. package/dist/request/agent-with-ip-validation.d.ts +11 -0
  10. package/dist/request/agent-with-ip-validation.js +34 -0
  11. package/dist/request/index.js +6 -5
  12. package/dist/request/is-denied-ip.d.ts +1 -0
  13. package/dist/request/{validate-ip.js → is-denied-ip.js} +10 -12
  14. package/dist/services/assets.js +1 -3
  15. package/dist/services/authorization.d.ts +1 -1
  16. package/dist/services/authorization.js +15 -3
  17. package/dist/services/collections.d.ts +3 -2
  18. package/dist/services/collections.js +1 -1
  19. package/dist/services/fields.js +2 -1
  20. package/dist/services/files.js +4 -3
  21. package/dist/services/graphql/index.js +3 -2
  22. package/dist/services/{import-export/index.d.ts → import-export.d.ts} +1 -1
  23. package/dist/services/{import-export/index.js → import-export.js} +12 -11
  24. package/dist/services/index.d.ts +1 -1
  25. package/dist/services/index.js +1 -1
  26. package/dist/services/items.js +2 -1
  27. package/dist/services/permissions.d.ts +3 -2
  28. package/dist/services/permissions.js +77 -2
  29. package/dist/services/relations.js +1 -1
  30. package/dist/services/roles.js +83 -15
  31. package/dist/services/server.js +2 -1
  32. package/dist/services/specifications.js +4 -3
  33. package/dist/services/utils.js +1 -1
  34. package/dist/telemetry/utils/get-user-item-count.js +2 -1
  35. package/dist/types/collection.d.ts +2 -13
  36. package/dist/types/items.d.ts +4 -12
  37. package/dist/types/items.js +0 -4
  38. package/dist/utils/get-field-system-rows.d.ts +2 -0
  39. package/dist/utils/get-field-system-rows.js +17 -0
  40. package/dist/utils/get-permissions.js +1 -1
  41. package/dist/utils/get-schema.js +3 -2
  42. package/dist/utils/merge-permissions-for-share.js +1 -1
  43. package/dist/utils/should-skip-cache.js +1 -1
  44. package/dist/websocket/handlers/items.js +2 -1
  45. package/dist/websocket/messages.d.ts +18 -18
  46. package/package.json +36 -35
  47. package/dist/database/system-data/app-access-permissions/app-access-permissions.yaml +0 -107
  48. package/dist/database/system-data/app-access-permissions/index.d.ts +0 -3
  49. package/dist/database/system-data/app-access-permissions/index.js +0 -17
  50. package/dist/database/system-data/app-access-permissions/schema-access-permissions.yaml +0 -17
  51. package/dist/database/system-data/collections/collections.yaml +0 -103
  52. package/dist/database/system-data/collections/index.d.ts +0 -2
  53. package/dist/database/system-data/collections/index.js +0 -9
  54. package/dist/database/system-data/fields/_defaults.yaml +0 -16
  55. package/dist/database/system-data/fields/activity.yaml +0 -83
  56. package/dist/database/system-data/fields/collections.yaml +0 -249
  57. package/dist/database/system-data/fields/dashboards.yaml +0 -20
  58. package/dist/database/system-data/fields/extensions.yaml +0 -10
  59. package/dist/database/system-data/fields/fields.yaml +0 -104
  60. package/dist/database/system-data/fields/files.yaml +0 -160
  61. package/dist/database/system-data/fields/flows.yaml +0 -26
  62. package/dist/database/system-data/fields/folders.yaml +0 -14
  63. package/dist/database/system-data/fields/index.d.ts +0 -2
  64. package/dist/database/system-data/fields/index.js +0 -33
  65. package/dist/database/system-data/fields/migrations.yaml +0 -10
  66. package/dist/database/system-data/fields/notifications.yaml +0 -15
  67. package/dist/database/system-data/fields/operations.yaml +0 -23
  68. package/dist/database/system-data/fields/panels.yaml +0 -29
  69. package/dist/database/system-data/fields/permissions.yaml +0 -37
  70. package/dist/database/system-data/fields/presets.yaml +0 -56
  71. package/dist/database/system-data/fields/relations.yaml +0 -34
  72. package/dist/database/system-data/fields/revisions.yaml +0 -30
  73. package/dist/database/system-data/fields/roles.yaml +0 -61
  74. package/dist/database/system-data/fields/sessions.yaml +0 -16
  75. package/dist/database/system-data/fields/settings.yaml +0 -471
  76. package/dist/database/system-data/fields/shares.yaml +0 -83
  77. package/dist/database/system-data/fields/translations.yaml +0 -27
  78. package/dist/database/system-data/fields/users.yaml +0 -224
  79. package/dist/database/system-data/fields/versions.yaml +0 -38
  80. package/dist/database/system-data/fields/webhooks.yaml +0 -141
  81. package/dist/database/system-data/relations/index.d.ts +0 -2
  82. package/dist/database/system-data/relations/index.js +0 -9
  83. package/dist/database/system-data/relations/relations.yaml +0 -197
  84. package/dist/request/request-interceptor.d.ts +0 -2
  85. package/dist/request/request-interceptor.js +0 -28
  86. package/dist/request/response-interceptor.d.ts +0 -2
  87. package/dist/request/response-interceptor.js +0 -5
  88. package/dist/request/validate-ip.d.ts +0 -1
  89. package/dist/services/import-export/import-worker.d.ts +0 -9
  90. package/dist/services/import-export/import-worker.js +0 -9
  91. package/dist/worker-pool.d.ts +0 -2
  92. package/dist/worker-pool.js +0 -19
@@ -1,2 +0,0 @@
1
- import type { InternalAxiosRequestConfig } from 'axios';
2
- export declare const requestInterceptor: (config: InternalAxiosRequestConfig) => Promise<InternalAxiosRequestConfig<any>>;
@@ -1,28 +0,0 @@
1
- import axios from 'axios';
2
- import { lookup } from 'node:dns/promises';
3
- import { isIP } from 'node:net';
4
- import { URL } from 'node:url';
5
- import { useLogger } from '../logger.js';
6
- import { validateIp } from './validate-ip.js';
7
- export const requestInterceptor = async (config) => {
8
- const logger = useLogger();
9
- const uri = axios.getUri(config);
10
- const { hostname } = new URL(uri);
11
- let ip;
12
- if (isIP(hostname) === 0) {
13
- try {
14
- const dns = await lookup(hostname);
15
- ip = dns.address;
16
- }
17
- catch (error) {
18
- logger.warn(`Couldn't lookup the DNS for URL "${uri}"`);
19
- logger.warn(error);
20
- throw new Error(`Requested URL "${uri}" resolves to a denied IP address`);
21
- }
22
- }
23
- else {
24
- ip = hostname;
25
- }
26
- validateIp(ip, uri);
27
- return config;
28
- };
@@ -1,2 +0,0 @@
1
- import type { AxiosResponse } from 'axios';
2
- export declare const responseInterceptor: (config: AxiosResponse<any, any>) => Promise<AxiosResponse<any, any>>;
@@ -1,5 +0,0 @@
1
- import { validateIp } from './validate-ip.js';
2
- export const responseInterceptor = async (config) => {
3
- validateIp(config.request.socket.remoteAddress, config.request.url);
4
- return config;
5
- };
@@ -1 +0,0 @@
1
- export declare function validateIp(ip: string, url: string): void;
@@ -1,9 +0,0 @@
1
- import type { Accountability, SchemaOverview } from '@directus/types';
2
- export type ImportWorkerData = {
3
- collection: string;
4
- mimeType: string;
5
- filePath: string;
6
- accountability: Accountability | undefined;
7
- schema: SchemaOverview;
8
- };
9
- export default function ({ collection, mimeType, filePath, accountability, schema }: ImportWorkerData): Promise<void>;
@@ -1,9 +0,0 @@
1
- import { createReadStream } from 'node:fs';
2
- import { ImportService } from './index.js';
3
- export default async function ({ collection, mimeType, filePath, accountability, schema }) {
4
- const service = new ImportService({
5
- accountability: accountability,
6
- schema: schema,
7
- });
8
- await service.import(collection, mimeType, createReadStream(filePath));
9
- }
@@ -1,2 +0,0 @@
1
- import Tinypool from 'tinypool';
2
- export declare function getWorkerPool(): Tinypool;
@@ -1,19 +0,0 @@
1
- import os from 'node:os';
2
- import Tinypool from 'tinypool';
3
- let workerPool;
4
- export function getWorkerPool() {
5
- if (!workerPool) {
6
- workerPool = new Tinypool({
7
- minThreads: 0,
8
- maxQueue: 'auto',
9
- });
10
- // TODO Workaround currently required for failing CPU count on ARM in Tinypool,
11
- // remove again once fixed upstream
12
- if (workerPool.options.maxThreads === 0) {
13
- const availableParallelism = os.availableParallelism();
14
- workerPool.options.maxThreads = availableParallelism;
15
- workerPool.options.maxQueue = availableParallelism ** 2;
16
- }
17
- }
18
- return workerPool;
19
- }