directus 9.15.1 → 9.17.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.
Files changed (107) hide show
  1. package/dist/__utils__/items-utils.d.ts +2 -0
  2. package/dist/__utils__/items-utils.js +36 -0
  3. package/dist/__utils__/schemas.d.ts +13 -0
  4. package/dist/__utils__/schemas.js +304 -0
  5. package/dist/__utils__/snapshots.d.ts +5 -0
  6. package/dist/__utils__/snapshots.js +897 -0
  7. package/dist/app.js +8 -7
  8. package/dist/auth/drivers/ldap.js +1 -0
  9. package/dist/auth/drivers/local.js +6 -0
  10. package/dist/auth/drivers/oauth2.js +1 -0
  11. package/dist/auth/drivers/openid.js +1 -0
  12. package/dist/cli/index.test.d.ts +1 -0
  13. package/dist/cli/index.test.js +58 -0
  14. package/dist/cli/utils/create-env/env-stub.liquid +6 -2
  15. package/dist/controllers/activity.js +1 -0
  16. package/dist/controllers/assets.js +20 -16
  17. package/dist/controllers/auth.js +6 -9
  18. package/dist/controllers/files.test.d.ts +1 -0
  19. package/dist/controllers/files.test.js +49 -0
  20. package/dist/controllers/server.js +0 -1
  21. package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +3 -0
  22. package/dist/database/migrations/20220826A-add-origin-to-accountability.js +21 -0
  23. package/dist/database/migrations/run.test.d.ts +1 -0
  24. package/dist/database/migrations/run.test.js +92 -0
  25. package/dist/database/system-data/fields/activity.yaml +6 -0
  26. package/dist/database/system-data/fields/sessions.yaml +2 -0
  27. package/dist/env.js +15 -0
  28. package/dist/env.test.d.ts +8 -0
  29. package/dist/env.test.js +39 -0
  30. package/dist/extensions.d.ts +1 -0
  31. package/dist/extensions.js +16 -3
  32. package/dist/flows.js +28 -17
  33. package/dist/mailer.js +1 -0
  34. package/dist/middleware/authenticate.d.ts +1 -1
  35. package/dist/middleware/authenticate.js +1 -0
  36. package/dist/middleware/authenticate.test.d.ts +1 -0
  37. package/dist/middleware/authenticate.test.js +214 -0
  38. package/dist/middleware/extract-token.test.d.ts +1 -0
  39. package/dist/middleware/extract-token.test.js +60 -0
  40. package/dist/middleware/validate-batch.d.ts +1 -2
  41. package/dist/middleware/validate-batch.js +10 -13
  42. package/dist/middleware/validate-batch.test.d.ts +1 -0
  43. package/dist/middleware/validate-batch.test.js +82 -0
  44. package/dist/operations/exec/index.d.ts +5 -0
  45. package/dist/operations/exec/index.js +26 -0
  46. package/dist/operations/exec/index.test.d.ts +1 -0
  47. package/dist/operations/exec/index.test.js +95 -0
  48. package/dist/operations/notification/index.js +9 -6
  49. package/dist/operations/request/index.js +22 -3
  50. package/dist/operations/transform/index.d.ts +1 -1
  51. package/dist/operations/transform/index.js +1 -1
  52. package/dist/services/authentication.js +13 -3
  53. package/dist/services/files.js +3 -2
  54. package/dist/services/files.test.d.ts +1 -0
  55. package/dist/services/files.test.js +53 -0
  56. package/dist/services/flows.js +4 -0
  57. package/dist/services/graphql/index.d.ts +2 -2
  58. package/dist/services/graphql/index.js +78 -75
  59. package/dist/services/items.js +98 -42
  60. package/dist/services/items.test.d.ts +1 -0
  61. package/dist/services/items.test.js +765 -0
  62. package/dist/services/payload.d.ts +7 -4
  63. package/dist/services/payload.js +63 -12
  64. package/dist/services/payload.test.d.ts +1 -0
  65. package/dist/services/payload.test.js +94 -0
  66. package/dist/services/server.js +10 -7
  67. package/dist/services/shares.js +2 -1
  68. package/dist/services/specifications.test.d.ts +1 -0
  69. package/dist/services/specifications.test.js +96 -0
  70. package/dist/types/items.d.ts +11 -0
  71. package/dist/utils/apply-query.js +7 -3
  72. package/dist/utils/apply-snapshot.js +15 -0
  73. package/dist/utils/apply-snapshot.test.d.ts +1 -0
  74. package/dist/utils/apply-snapshot.test.js +305 -0
  75. package/dist/utils/async-handler.d.ts +2 -6
  76. package/dist/utils/async-handler.js +1 -13
  77. package/dist/utils/async-handler.test.d.ts +1 -0
  78. package/dist/utils/async-handler.test.js +18 -0
  79. package/dist/utils/calculate-field-depth.test.d.ts +1 -0
  80. package/dist/utils/calculate-field-depth.test.js +76 -0
  81. package/dist/utils/filter-items.test.d.ts +1 -0
  82. package/dist/utils/filter-items.test.js +60 -0
  83. package/dist/utils/get-cache-key.test.d.ts +1 -0
  84. package/dist/utils/get-cache-key.test.js +53 -0
  85. package/dist/utils/get-column-path.test.d.ts +1 -0
  86. package/dist/utils/get-column-path.test.js +136 -0
  87. package/dist/utils/get-config-from-env.test.d.ts +1 -0
  88. package/dist/utils/get-config-from-env.test.js +19 -0
  89. package/dist/utils/get-graphql-type.d.ts +1 -1
  90. package/dist/utils/get-graphql-type.js +4 -1
  91. package/dist/utils/get-os-info.d.ts +9 -0
  92. package/dist/utils/get-os-info.js +47 -0
  93. package/dist/utils/get-relation-info.test.d.ts +1 -0
  94. package/dist/utils/get-relation-info.test.js +88 -0
  95. package/dist/utils/get-relation-type.test.d.ts +1 -0
  96. package/dist/utils/get-relation-type.test.js +69 -0
  97. package/dist/utils/get-string-byte-size.test.d.ts +1 -0
  98. package/dist/utils/get-string-byte-size.test.js +8 -0
  99. package/dist/utils/is-directus-jwt.test.d.ts +1 -0
  100. package/dist/utils/is-directus-jwt.test.js +26 -0
  101. package/dist/utils/jwt.test.d.ts +1 -0
  102. package/dist/utils/jwt.test.js +36 -0
  103. package/dist/utils/merge-permissions.test.d.ts +1 -0
  104. package/dist/utils/merge-permissions.test.js +80 -0
  105. package/dist/utils/validate-keys.test.d.ts +1 -0
  106. package/dist/utils/validate-keys.test.js +97 -0
  107. package/package.json +14 -12
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validate_keys_1 = require("../../src/utils/validate-keys");
4
+ const uuid_1 = require("uuid");
5
+ const schema = {
6
+ collections: {
7
+ pk_integer: {
8
+ collection: 'pk_integer',
9
+ primary: 'id',
10
+ singleton: false,
11
+ note: 'Sample schema with integer primary key',
12
+ sortField: null,
13
+ accountability: null,
14
+ fields: {
15
+ id: {
16
+ field: 'id',
17
+ defaultValue: null,
18
+ nullable: false,
19
+ generated: false,
20
+ type: 'integer',
21
+ dbType: 'integer',
22
+ precision: null,
23
+ scale: null,
24
+ special: [],
25
+ note: null,
26
+ alias: false,
27
+ validation: null,
28
+ },
29
+ },
30
+ },
31
+ pk_uuid: {
32
+ collection: 'pk_uuid',
33
+ primary: 'id',
34
+ singleton: false,
35
+ note: 'Sample schema with uuid primary key',
36
+ sortField: null,
37
+ accountability: null,
38
+ fields: {
39
+ id: {
40
+ field: 'id',
41
+ defaultValue: null,
42
+ nullable: false,
43
+ generated: false,
44
+ type: 'uuid',
45
+ dbType: 'uuid',
46
+ precision: null,
47
+ scale: null,
48
+ special: [],
49
+ note: null,
50
+ alias: false,
51
+ validation: null,
52
+ },
53
+ },
54
+ },
55
+ },
56
+ relations: [],
57
+ };
58
+ describe('validate keys', () => {
59
+ describe('of integer type', () => {
60
+ it('Throws an error when provided with an invalid integer key', () => {
61
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', 'invalid')).toThrowError();
62
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', NaN)).toThrowError();
63
+ });
64
+ it('Throws an error when provided with an array containing an invalid integer key', () => {
65
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', [111, 'invalid', 222])).toThrowError();
66
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', [555, NaN, 666])).toThrowError();
67
+ });
68
+ it('Does not throw an error when provided with a valid integer key', () => {
69
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', 111)).not.toThrowError();
70
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', '222')).not.toThrowError();
71
+ });
72
+ it('Does not throw an error when provided with an array of valid integer keys', () => {
73
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', [111, 222, 333])).not.toThrowError();
74
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_integer', 'id', ['444', '555', '666'])).not.toThrowError();
75
+ });
76
+ });
77
+ describe('of uuid type', () => {
78
+ it('Throws an error when provided with an invalid uuid key', () => {
79
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', 'fakeuuid-62d9-434d-a7c7-878c8376782e')).toThrowError();
80
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', 'invalid')).toThrowError();
81
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', NaN)).toThrowError();
82
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', 111)).toThrowError();
83
+ });
84
+ it('Throws an error when provided with an array containing an invalid uuid key', () => {
85
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), 'fakeuuid-62d9-434d-a7c7-878c8376782e', (0, uuid_1.v4)()])).toThrowError();
86
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), 'invalid', (0, uuid_1.v4)()])).toThrowError();
87
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), NaN, (0, uuid_1.v4)()])).toThrowError();
88
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), 111, (0, uuid_1.v4)()])).toThrowError();
89
+ });
90
+ it('Does not throw an error when provided with a valid uuid key', () => {
91
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', (0, uuid_1.v4)())).not.toThrowError();
92
+ });
93
+ it('Does not throw an error when provided with an array of valid uuid keys', () => {
94
+ expect(() => (0, validate_keys_1.validateKeys)(schema, 'pk_uuid', 'id', [(0, uuid_1.v4)(), (0, uuid_1.v4)(), (0, uuid_1.v4)()])).not.toThrowError();
95
+ });
96
+ });
97
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directus",
3
- "version": "9.15.1",
3
+ "version": "9.17.0",
4
4
  "license": "GPL-3.0-only",
5
5
  "homepage": "https://github.com/directus/directus#readme",
6
6
  "description": "Directus is a real-time API and App dashboard for managing SQL database content.",
@@ -66,16 +66,16 @@
66
66
  ],
67
67
  "dependencies": {
68
68
  "@aws-sdk/client-ses": "^3.107.0",
69
- "@directus/app": "9.15.1",
70
- "@directus/drive": "9.15.1",
71
- "@directus/drive-azure": "9.15.1",
72
- "@directus/drive-gcs": "9.15.1",
73
- "@directus/drive-s3": "9.15.1",
69
+ "@directus/app": "9.17.0",
70
+ "@directus/drive": "9.17.0",
71
+ "@directus/drive-azure": "9.17.0",
72
+ "@directus/drive-gcs": "9.17.0",
73
+ "@directus/drive-s3": "9.17.0",
74
74
  "@directus/extensions-sdk": "^9.14.1",
75
75
  "@directus/format-title": "^9.15.0",
76
- "@directus/schema": "9.15.1",
77
- "@directus/shared": "9.15.1",
78
- "@directus/specs": "9.15.1",
76
+ "@directus/schema": "9.17.0",
77
+ "@directus/shared": "9.17.0",
78
+ "@directus/specs": "9.17.0",
79
79
  "@godaddy/terminus": "^4.10.2",
80
80
  "@rollup/plugin-alias": "^3.1.9",
81
81
  "@rollup/plugin-virtual": "^2.1.0",
@@ -97,6 +97,7 @@
97
97
  "deep-map": "^2.0.0",
98
98
  "destroy": "^1.2.0",
99
99
  "dotenv": "^10.0.0",
100
+ "encodeurl": "^1.0.2",
100
101
  "eventemitter2": "^6.4.5",
101
102
  "execa": "^5.1.1",
102
103
  "exifr": "^7.1.3",
@@ -117,17 +118,16 @@
117
118
  "jsonwebtoken": "^8.5.1",
118
119
  "keyv": "^4.3.0",
119
120
  "knex": "2.2.0",
120
- "knex-schema-inspector": "^2.0.3",
121
+ "knex-schema-inspector": "2.0.4",
121
122
  "ldapjs": "^2.3.3",
122
123
  "liquidjs": "^9.37.0",
123
124
  "lodash": "^4.17.21",
124
- "macos-release": "^2.4.1",
125
125
  "marked": "^4.0.16",
126
126
  "micromustache": "^8.0.3",
127
127
  "mime-types": "^2.1.35",
128
128
  "ms": "^2.1.3",
129
129
  "nanoid": "^3.1.23",
130
- "node-cron": "^3.0.1",
130
+ "node-cron": "^3.0.2",
131
131
  "node-machine-id": "^1.1.12",
132
132
  "nodemailer": "^6.7.5",
133
133
  "object-hash": "^2.2.0",
@@ -152,6 +152,7 @@
152
152
  "update-check": "^1.5.4",
153
153
  "uuid": "^8.3.2",
154
154
  "uuid-validate": "0.0.3",
155
+ "vm2": "^3.9.10",
155
156
  "wellknown": "^0.5.0"
156
157
  },
157
158
  "optionalDependencies": {
@@ -175,6 +176,7 @@
175
176
  "@types/cors": "2.8.12",
176
177
  "@types/deep-diff": "1.0.1",
177
178
  "@types/destroy": "1.0.0",
179
+ "@types/encodeurl": "^1.0.0",
178
180
  "@types/express": "4.17.13",
179
181
  "@types/express-pino-logger": "4.0.3",
180
182
  "@types/express-serve-static-core": "^4.17.29",