@strapi/strapi 4.10.0-beta.1 → 4.10.1-experimental.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 (193) hide show
  1. package/bin/strapi.js +2 -468
  2. package/coverage/clover.xml +1613 -0
  3. package/coverage/coverage-final.json +48 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +87 -0
  6. package/coverage/lcov-report/commands/__tests__/data-transfer/shared/index.html +116 -0
  7. package/coverage/lcov-report/commands/__tests__/data-transfer/shared/transfer.test.utils.js.html +133 -0
  8. package/coverage/lcov-report/commands/admin-create.js.html +424 -0
  9. package/coverage/lcov-report/commands/admin-reset.js.html +241 -0
  10. package/coverage/lcov-report/commands/generate-template.js.html +373 -0
  11. package/coverage/lcov-report/commands/index.html +146 -0
  12. package/coverage/lcov-report/commands/transfer/export.js.html +619 -0
  13. package/coverage/lcov-report/commands/transfer/import.js.html +562 -0
  14. package/coverage/lcov-report/commands/transfer/index.html +146 -0
  15. package/coverage/lcov-report/commands/transfer/transfer.js.html +532 -0
  16. package/coverage/lcov-report/commands/utils/helpers.js.html +430 -0
  17. package/coverage/lcov-report/commands/utils/index.html +116 -0
  18. package/coverage/lcov-report/core/registries/custom-fields.js.html +301 -0
  19. package/coverage/lcov-report/core/registries/index.html +116 -0
  20. package/coverage/lcov-report/core-api/controller/collection-type.js.html +418 -0
  21. package/coverage/lcov-report/core-api/controller/index.html +161 -0
  22. package/coverage/lcov-report/core-api/controller/index.js.html +220 -0
  23. package/coverage/lcov-report/core-api/controller/single-type.js.html +274 -0
  24. package/coverage/lcov-report/core-api/controller/transform.js.html +376 -0
  25. package/coverage/lcov-report/core-api/service/collection-type.js.html +325 -0
  26. package/coverage/lcov-report/core-api/service/index.html +161 -0
  27. package/coverage/lcov-report/core-api/service/index.js.html +220 -0
  28. package/coverage/lcov-report/core-api/service/pagination.js.html +460 -0
  29. package/coverage/lcov-report/core-api/service/single-type.js.html +301 -0
  30. package/coverage/lcov-report/favicon.png +0 -0
  31. package/coverage/lcov-report/index.html +386 -0
  32. package/coverage/lcov-report/load/filepath-to-prop-path.js.html +151 -0
  33. package/coverage/lcov-report/load/index.html +116 -0
  34. package/coverage/lcov-report/prettify.css +1 -0
  35. package/coverage/lcov-report/prettify.js +2 -0
  36. package/coverage/lcov-report/services/content-api/index.html +116 -0
  37. package/coverage/lcov-report/services/content-api/index.js.html +307 -0
  38. package/coverage/lcov-report/services/content-api/permissions/engine.js.html +100 -0
  39. package/coverage/lcov-report/services/content-api/permissions/index.html +131 -0
  40. package/coverage/lcov-report/services/content-api/permissions/index.js.html +529 -0
  41. package/coverage/lcov-report/services/content-api/permissions/providers/action.js.html +142 -0
  42. package/coverage/lcov-report/services/content-api/permissions/providers/condition.js.html +142 -0
  43. package/coverage/lcov-report/services/content-api/permissions/providers/index.html +146 -0
  44. package/coverage/lcov-report/services/content-api/permissions/providers/index.js.html +112 -0
  45. package/coverage/lcov-report/services/core-store.js.html +520 -0
  46. package/coverage/lcov-report/services/entity-service/attributes/index.html +131 -0
  47. package/coverage/lcov-report/services/entity-service/attributes/index.js.html +178 -0
  48. package/coverage/lcov-report/services/entity-service/attributes/transforms.js.html +145 -0
  49. package/coverage/lcov-report/services/entity-service/components.js.html +1246 -0
  50. package/coverage/lcov-report/services/entity-service/index.html +146 -0
  51. package/coverage/lcov-report/services/entity-service/index.js.html +1120 -0
  52. package/coverage/lcov-report/services/entity-service/params.js.html +112 -0
  53. package/coverage/lcov-report/services/entity-validator/__tests__/relations/utils/index.html +116 -0
  54. package/coverage/lcov-report/services/entity-validator/__tests__/relations/utils/relations.testdata.js.html +544 -0
  55. package/coverage/lcov-report/services/entity-validator/index.html +131 -0
  56. package/coverage/lcov-report/services/entity-validator/index.js.html +1231 -0
  57. package/coverage/lcov-report/services/entity-validator/validators.js.html +733 -0
  58. package/coverage/lcov-report/services/event-hub.js.html +319 -0
  59. package/coverage/lcov-report/services/fs.js.html +259 -0
  60. package/coverage/lcov-report/services/index.html +161 -0
  61. package/coverage/lcov-report/services/metrics/admin-user-hash.js.html +148 -0
  62. package/coverage/lcov-report/services/metrics/index.html +206 -0
  63. package/coverage/lcov-report/services/metrics/index.js.html +265 -0
  64. package/coverage/lcov-report/services/metrics/is-truthy.js.html +112 -0
  65. package/coverage/lcov-report/services/metrics/middleware.js.html +184 -0
  66. package/coverage/lcov-report/services/metrics/rate-limiter.js.html +166 -0
  67. package/coverage/lcov-report/services/metrics/sender.js.html +394 -0
  68. package/coverage/lcov-report/services/metrics/stringify-deep.js.html +151 -0
  69. package/coverage/lcov-report/services/utils/index.html +116 -0
  70. package/coverage/lcov-report/services/utils/upload-files.js.html +322 -0
  71. package/coverage/lcov-report/services/worker-queue.js.html +262 -0
  72. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  73. package/coverage/lcov-report/sorter.js +196 -0
  74. package/coverage/lcov-report/utils/convert-custom-field-type.js.html +151 -0
  75. package/coverage/lcov-report/utils/index.html +146 -0
  76. package/coverage/lcov-report/utils/machine-id.js.html +127 -0
  77. package/coverage/lcov-report/utils/url-from-segments.js.html +121 -0
  78. package/ee/LICENSE.txt +21 -0
  79. package/ee/index.js +3 -1
  80. package/ee/license.js +8 -7
  81. package/lib/Strapi.js +3 -0
  82. package/lib/commands/__tests__/commands.test.js +20 -0
  83. package/lib/commands/__tests__/commands.test.utils.js +16 -0
  84. package/lib/commands/actions/admin/create-user/__tests__/admin.create-user.test.js +450 -0
  85. package/lib/commands/{admin-create.js → actions/admin/create-user/action.js} +2 -2
  86. package/lib/commands/actions/admin/create-user/command.js +19 -0
  87. package/lib/commands/actions/admin/reset-user-password/__tests__/admin.reset-user-password.test.js +145 -0
  88. package/lib/commands/{admin-reset.js → actions/admin/reset-user-password/action.js} +2 -2
  89. package/lib/commands/actions/admin/reset-user-password/command.js +17 -0
  90. package/lib/commands/{build.js → actions/build/action.js} +2 -2
  91. package/lib/commands/actions/build/command.js +15 -0
  92. package/lib/commands/{configurationDump.js → actions/configuration/dump/action.js} +1 -1
  93. package/lib/commands/actions/configuration/dump/command.js +17 -0
  94. package/lib/commands/{configurationRestore.js → actions/configuration/restore/action.js} +1 -1
  95. package/lib/commands/actions/configuration/restore/command.js +17 -0
  96. package/lib/commands/{console.js → actions/console/action.js} +2 -2
  97. package/lib/commands/actions/console/command.js +14 -0
  98. package/lib/commands/{content-types/list.js → actions/content-types/list/action.js} +2 -2
  99. package/lib/commands/actions/content-types/list/command.js +14 -0
  100. package/lib/commands/{controllers/list.js → actions/controllers/list/action.js} +2 -2
  101. package/lib/commands/actions/controllers/list/command.js +14 -0
  102. package/lib/commands/{develop.js → actions/develop/action.js} +3 -3
  103. package/lib/commands/actions/develop/command.js +19 -0
  104. package/lib/commands/actions/export/__tests__/export.test.js +175 -0
  105. package/lib/commands/{transfer/export.js → actions/export/action.js} +3 -2
  106. package/lib/commands/actions/export/command.js +45 -0
  107. package/lib/commands/actions/generate/command.js +18 -0
  108. package/lib/commands/{hooks/list.js → actions/hooks/list/action.js} +2 -2
  109. package/lib/commands/actions/hooks/list/command.js +14 -0
  110. package/lib/commands/actions/import/__tests__/import.test.js +143 -0
  111. package/lib/commands/{transfer/import.js → actions/import/action.js} +2 -2
  112. package/lib/commands/actions/import/command.js +97 -0
  113. package/lib/commands/{install.js → actions/install/action.js} +1 -1
  114. package/lib/commands/actions/install/command.js +14 -0
  115. package/lib/commands/{middlewares/list.js → actions/middlewares/list/action.js} +2 -2
  116. package/lib/commands/actions/middlewares/list/command.js +14 -0
  117. package/lib/commands/{new.js → actions/new/action.js} +1 -1
  118. package/lib/commands/actions/new/command.js +35 -0
  119. package/lib/commands/{policies/list.js → actions/policies/list/action.js} +2 -2
  120. package/lib/commands/actions/policies/list/command.js +14 -0
  121. package/lib/commands/{report.js → actions/report/action.js} +1 -1
  122. package/lib/commands/actions/report/command.js +17 -0
  123. package/lib/commands/{routes/list.js → actions/routes/list/action.js} +2 -2
  124. package/lib/commands/actions/routes/list/command.js +14 -0
  125. package/lib/commands/{services/list.js → actions/services/list/action.js} +2 -2
  126. package/lib/commands/actions/services/list/command.js +14 -0
  127. package/lib/commands/{start.js → actions/start/action.js} +1 -1
  128. package/lib/commands/actions/start/command.js +14 -0
  129. package/lib/commands/{opt-out-telemetry.js → actions/telemetry/disable/action.js} +1 -1
  130. package/lib/commands/actions/telemetry/disable/command.js +14 -0
  131. package/lib/commands/{opt-in-telemetry.js → actions/telemetry/enable/action.js} +1 -1
  132. package/lib/commands/actions/telemetry/enable/command.js +14 -0
  133. package/lib/commands/actions/templates/generate/__tests__/templates.generate.js +118 -0
  134. package/lib/commands/actions/templates/generate/command.js +14 -0
  135. package/lib/commands/actions/transfer/__tests__/transfer.test.js +178 -0
  136. package/lib/commands/{transfer/transfer.js → actions/transfer/action.js} +2 -2
  137. package/lib/commands/actions/transfer/command.js +115 -0
  138. package/lib/commands/{ts/generate-types.js → actions/ts/generate-types/action.js} +2 -2
  139. package/lib/commands/actions/ts/generate-types/command.js +21 -0
  140. package/lib/commands/{uninstall.js → actions/uninstall/action.js} +1 -1
  141. package/lib/commands/actions/uninstall/command.js +15 -0
  142. package/lib/commands/actions/version/command.js +19 -0
  143. package/lib/commands/{watchAdmin.js → actions/watch-admin/action.js} +4 -4
  144. package/lib/commands/actions/watch-admin/command.js +15 -0
  145. package/lib/commands/index.js +66 -0
  146. package/lib/commands/{transfer/utils.js → utils/data-transfer.js} +2 -2
  147. package/lib/commands/utils/helpers.js +54 -3
  148. package/lib/core/registries/__tests__/custom-fields.test.js +152 -0
  149. package/lib/core/registries/custom-fields.js +19 -2
  150. package/lib/core-api/__tests__/controller.test.js +39 -0
  151. package/lib/core-api/controller/__tests__/transform.test.js +226 -0
  152. package/lib/core-api/service/__tests__/index.test.js +127 -0
  153. package/lib/core-api/service/__tests__/pagination.test.js +275 -0
  154. package/lib/load/__tests__/filepath-to-prop-path.test.js +30 -0
  155. package/lib/middlewares/__tests__/errors.test.js +21 -0
  156. package/lib/services/__tests__/content-api-permissions.test.js +291 -0
  157. package/lib/services/__tests__/core-store.test.js +148 -0
  158. package/lib/services/__tests__/event-hub.test.js +126 -0
  159. package/lib/services/__tests__/fs.test.js +78 -0
  160. package/lib/services/__tests__/worker-queue.test.js +47 -0
  161. package/lib/services/entity-service/__tests__/entity-service-events.test.js +117 -0
  162. package/lib/services/entity-service/__tests__/entity-service.test.js +587 -0
  163. package/lib/services/entity-validator/__tests__/biginteger-validators.test.js +220 -0
  164. package/lib/services/entity-validator/__tests__/date-validators.test.js +183 -0
  165. package/lib/services/entity-validator/__tests__/datetime-validators.test.js +183 -0
  166. package/lib/services/entity-validator/__tests__/email-validators.test.js +56 -0
  167. package/lib/services/entity-validator/__tests__/enumeration-validators.test.js +43 -0
  168. package/lib/services/entity-validator/__tests__/float-validators.test.js +278 -0
  169. package/lib/services/entity-validator/__tests__/index.test.js +609 -0
  170. package/lib/services/entity-validator/__tests__/integer-validators.test.js +278 -0
  171. package/lib/services/entity-validator/__tests__/relations/attribute-level.test.js +123 -0
  172. package/lib/services/entity-validator/__tests__/relations/component-level.test.js +275 -0
  173. package/lib/services/entity-validator/__tests__/relations/dynamic-zone-level.test.js +159 -0
  174. package/lib/services/entity-validator/__tests__/relations/media-level.test.js +74 -0
  175. package/lib/services/entity-validator/__tests__/relations/utils/relations.testdata.js +153 -0
  176. package/lib/services/entity-validator/__tests__/string-validators.test.js +374 -0
  177. package/lib/services/entity-validator/__tests__/time-validators.test.js +183 -0
  178. package/lib/services/entity-validator/__tests__/timestamp-validators.test.js +204 -0
  179. package/lib/services/entity-validator/__tests__/uid-validators.test.js +229 -0
  180. package/lib/services/metrics/__tests__/admin-user-hash.test.js +41 -0
  181. package/lib/services/metrics/__tests__/index.test.js +157 -0
  182. package/lib/services/metrics/__tests__/is-truthy.js +33 -0
  183. package/lib/services/metrics/__tests__/middleware.test.js +60 -0
  184. package/lib/services/metrics/__tests__/rate-limiter.test.js +50 -0
  185. package/lib/services/metrics/__tests__/stringify-deep.test.js +27 -0
  186. package/lib/services/metrics/sender.js +1 -2
  187. package/lib/services/webhook-runner.js +4 -4
  188. package/lib/types/core/commands/index.d.ts +6 -0
  189. package/lib/utils/__tests__/convert-custom-field-type.test.js +69 -0
  190. package/lib/utils/__tests__/url-from-segments.test.js +40 -0
  191. package/lib/utils/fetch.js +23 -0
  192. package/package.json +17 -16
  193. /package/lib/commands/{generate-template.js → actions/templates/generate/action.js} +0 -0
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ const createMiddleware = require('../middleware');
4
+
5
+ describe('Metrics middleware', () => {
6
+ test('Ignores request with extension in them', async () => {
7
+ const sendEvent = jest.fn();
8
+
9
+ const middleware = createMiddleware({ sendEvent });
10
+
11
+ await middleware(
12
+ {
13
+ request: {
14
+ method: 'GET',
15
+ url: '/uploads/image.png',
16
+ },
17
+ },
18
+ jest.fn()
19
+ );
20
+
21
+ expect(sendEvent).not.toHaveBeenCalled();
22
+ });
23
+
24
+ test.each(['OPTIONS', 'HEAD'])('Ignores %s method', async (method) => {
25
+ const sendEvent = jest.fn();
26
+
27
+ const middleware = createMiddleware({ sendEvent });
28
+
29
+ await middleware(
30
+ {
31
+ request: {
32
+ method,
33
+ url: '/some-api',
34
+ },
35
+ },
36
+ jest.fn()
37
+ );
38
+
39
+ expect(sendEvent).not.toHaveBeenCalled();
40
+ });
41
+
42
+ test('Stops sending after 1000 events', async () => {
43
+ const sendEvent = jest.fn();
44
+ const middleware = createMiddleware({ sendEvent });
45
+
46
+ for (let i = 0; i < 2000; i += 1) {
47
+ await middleware(
48
+ {
49
+ request: {
50
+ method: 'GET',
51
+ url: '/some-api',
52
+ },
53
+ },
54
+ jest.fn()
55
+ );
56
+ }
57
+
58
+ expect(sendEvent).toHaveBeenCalledTimes(1000);
59
+ });
60
+ });
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ const wrapWithRateLimiter = require('../rate-limiter');
4
+
5
+ describe('Telemetry daily RateLimiter', () => {
6
+ test('Passes event and payload to sender', async () => {
7
+ const sender = jest.fn(() => Promise.resolve(true));
8
+
9
+ const send = wrapWithRateLimiter(sender, { limitedEvents: ['testEvent'] });
10
+
11
+ const payload = { key: 'value' };
12
+ await send('notRestricted', payload);
13
+
14
+ expect(sender).toHaveBeenCalledWith('notRestricted', payload);
15
+ });
16
+
17
+ test('Calls sender if event is not restricted', async () => {
18
+ const sender = jest.fn(() => Promise.resolve(true));
19
+
20
+ const send = wrapWithRateLimiter(sender, { limitedEvents: ['testEvent'] });
21
+
22
+ await send('notRestricted');
23
+
24
+ expect(sender).toHaveBeenCalledWith('notRestricted');
25
+ });
26
+
27
+ test('Calls the sender as many times as request when events is not restricted', async () => {
28
+ const sender = jest.fn(() => Promise.resolve(true));
29
+
30
+ const send = wrapWithRateLimiter(sender, { limitedEvents: ['testEvent'] });
31
+
32
+ await send('notRestricted');
33
+ await send('notRestricted');
34
+ await send('notRestricted');
35
+
36
+ expect(sender).toHaveBeenCalledTimes(3);
37
+ });
38
+
39
+ test('Calls the sender only once when event is restricted', async () => {
40
+ const sender = jest.fn(() => Promise.resolve(true));
41
+
42
+ const send = wrapWithRateLimiter(sender, { limitedEvents: ['restrictedEvent'] });
43
+
44
+ await send('restrictedEvent');
45
+ await send('restrictedEvent');
46
+ await send('restrictedEvent');
47
+
48
+ expect(sender).toHaveBeenCalledTimes(1);
49
+ });
50
+ });
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const stringifyDeep = require('../stringify-deep');
4
+
5
+ describe('stringifyDeep', () => {
6
+ test('Stringifies recursively', () => {
7
+ const input = {
8
+ property: 15,
9
+ subOjbect: {
10
+ property: 'test',
11
+ number: 81,
12
+ boolean: true,
13
+ },
14
+ arrayValue: ['valueA', 'valueB'],
15
+ };
16
+
17
+ expect(stringifyDeep(input)).toStrictEqual({
18
+ property: '15',
19
+ subOjbect: {
20
+ property: 'test',
21
+ number: '81',
22
+ boolean: 'true',
23
+ },
24
+ arrayValue: ['valueA', 'valueB'],
25
+ });
26
+ });
27
+ });
@@ -4,7 +4,6 @@ const os = require('os');
4
4
  const path = require('path');
5
5
  const _ = require('lodash');
6
6
  const isDocker = require('is-docker');
7
- const fetch = require('node-fetch');
8
7
  const ciEnv = require('ci-info');
9
8
  const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
10
9
  const { env } = require('@strapi/utils');
@@ -82,7 +81,7 @@ module.exports = (strapi) => {
82
81
  };
83
82
 
84
83
  try {
85
- const res = await fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
84
+ const res = await strapi.fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
86
85
  return res.ok;
87
86
  } catch (err) {
88
87
  return false;
@@ -6,7 +6,6 @@
6
6
 
7
7
  const debug = require('debug')('strapi:webhook');
8
8
  const _ = require('lodash');
9
- const fetch = require('node-fetch');
10
9
 
11
10
  const WorkerQueue = require('./worker-queue');
12
11
 
@@ -15,12 +14,13 @@ const defaultConfiguration = {
15
14
  };
16
15
 
17
16
  class WebhookRunner {
18
- constructor({ eventHub, logger, configuration = {} }) {
19
- debug('Initialized webhook runer');
17
+ constructor({ eventHub, logger, configuration = {}, fetch }) {
18
+ debug('Initialized webhook runner');
20
19
  this.eventHub = eventHub;
21
20
  this.logger = logger;
22
21
  this.webhooksMap = new Map();
23
22
  this.listeners = new Map();
23
+ this.fetch = fetch;
24
24
 
25
25
  if (typeof configuration !== 'object') {
26
26
  throw new Error(
@@ -76,7 +76,7 @@ class WebhookRunner {
76
76
  run(webhook, event, info = {}) {
77
77
  const { url, headers } = webhook;
78
78
 
79
- return fetch(url, {
79
+ return this.fetch(url, {
80
80
  method: 'post',
81
81
  body: JSON.stringify({
82
82
  event,
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+
3
+ export type AddCommandOptions = {
4
+ command: Command;
5
+ argv: Record<number, string>;
6
+ };
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ const convertCustomFieldType = require('../convert-custom-field-type');
4
+
5
+ describe('format attributes', () => {
6
+ it('replaces type customField with the underlying data type', () => {
7
+ global.strapi = {
8
+ container: {
9
+ // mock container.get('custom-fields')
10
+ get: jest.fn(() => ({
11
+ // mock container.get('custom-fields').get(uid)
12
+ get: jest.fn(() => ({
13
+ name: 'color',
14
+ plugin: 'mycustomfields',
15
+ type: 'text',
16
+ })),
17
+ })),
18
+ },
19
+ contentTypes: {
20
+ test: {
21
+ attributes: {
22
+ color: {
23
+ type: 'customField',
24
+ customField: 'plugin::mycustomfields.color',
25
+ },
26
+ },
27
+ },
28
+ },
29
+ components: {
30
+ 'default.test': {
31
+ attributes: {
32
+ color: {
33
+ type: 'customField',
34
+ customField: 'plugin::mycustomfields.color',
35
+ },
36
+ },
37
+ },
38
+ },
39
+ };
40
+
41
+ convertCustomFieldType(global.strapi);
42
+
43
+ const expected = {
44
+ ...global.strapi,
45
+ contentTypes: {
46
+ test: {
47
+ attributes: {
48
+ color: {
49
+ type: 'text',
50
+ customField: 'plugin::mycustomfields.color',
51
+ },
52
+ },
53
+ },
54
+ },
55
+ components: {
56
+ 'default.test': {
57
+ attributes: {
58
+ color: {
59
+ type: 'text',
60
+ customField: 'plugin::mycustomfields.color',
61
+ },
62
+ },
63
+ },
64
+ },
65
+ };
66
+
67
+ expect(global.strapi).toEqual(expected);
68
+ });
69
+ });
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const getUrlFromSegments = require('../url-from-segments');
4
+
5
+ describe('getUrlFromSegments', () => {
6
+ test('Handles hostname', () => {
7
+ expect(getUrlFromSegments({ hostname: 'localhost' })).toEqual('http://localhost');
8
+ expect(getUrlFromSegments({ hostname: 'otherhost.com' })).toEqual('http://otherhost.com');
9
+ });
10
+
11
+ test('Handles port', () => {
12
+ expect(getUrlFromSegments({ hostname: 'localhost', port: '80' })).toEqual('http://localhost');
13
+ expect(getUrlFromSegments({ hostname: 'localhost', port: '8000' })).toEqual(
14
+ 'http://localhost:8000'
15
+ );
16
+ expect(getUrlFromSegments({ hostname: 'otherhost.com', port: 5421 })).toEqual(
17
+ 'http://otherhost.com:5421'
18
+ );
19
+ });
20
+
21
+ test('Handles ssl and ports', () => {
22
+ expect(getUrlFromSegments({ hostname: 'localhost', ssl: true })).toEqual('https://localhost');
23
+
24
+ expect(getUrlFromSegments({ hostname: 'localhost', ssl: true, port: 532 })).toEqual(
25
+ 'https://localhost:532'
26
+ );
27
+
28
+ expect(getUrlFromSegments({ hostname: 'localhost', ssl: true, port: 443 })).toEqual(
29
+ 'https://localhost'
30
+ );
31
+
32
+ expect(getUrlFromSegments({ hostname: 'otherhost.com', ssl: true })).toEqual(
33
+ 'https://otherhost.com'
34
+ );
35
+
36
+ expect(getUrlFromSegments({ hostname: 'otherhost.com', ssl: true, port: 7263 })).toEqual(
37
+ 'https://otherhost.com:7263'
38
+ );
39
+ });
40
+ });
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const nodeFetch = require('node-fetch');
4
+ const HttpsProxyAgent = require('https-proxy-agent');
5
+
6
+ function createStrapiFetch(strapi) {
7
+ function fetch(url, options) {
8
+ return nodeFetch(url, {
9
+ ...(fetch.agent ? { agent: fetch.agent } : {}),
10
+ ...options,
11
+ });
12
+ }
13
+
14
+ const { globalProxy: proxy } = strapi.config.get('server');
15
+
16
+ if (proxy) {
17
+ fetch.agent = new HttpsProxyAgent(proxy);
18
+ }
19
+
20
+ return fetch;
21
+ }
22
+
23
+ module.exports = createStrapiFetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "4.10.0-beta.1",
3
+ "version": "4.10.1-experimental.0",
4
4
  "description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
5
5
  "keywords": [
6
6
  "strapi",
@@ -81,19 +81,19 @@
81
81
  "dependencies": {
82
82
  "@koa/cors": "3.4.3",
83
83
  "@koa/router": "10.1.1",
84
- "@strapi/admin": "4.10.0-beta.1",
85
- "@strapi/data-transfer": "4.10.0-beta.1",
86
- "@strapi/database": "4.10.0-beta.1",
87
- "@strapi/generate-new": "4.10.0-beta.1",
88
- "@strapi/generators": "4.10.0-beta.1",
89
- "@strapi/logger": "4.10.0-beta.1",
90
- "@strapi/permissions": "4.10.0-beta.1",
91
- "@strapi/plugin-content-manager": "4.10.0-beta.1",
92
- "@strapi/plugin-content-type-builder": "4.10.0-beta.1",
93
- "@strapi/plugin-email": "4.10.0-beta.1",
94
- "@strapi/plugin-upload": "4.10.0-beta.1",
95
- "@strapi/typescript-utils": "4.10.0-beta.1",
96
- "@strapi/utils": "4.10.0-beta.1",
84
+ "@strapi/admin": "4.10.1-experimental.0",
85
+ "@strapi/data-transfer": "4.10.1-experimental.0",
86
+ "@strapi/database": "4.10.1-experimental.0",
87
+ "@strapi/generate-new": "4.10.1-experimental.0",
88
+ "@strapi/generators": "4.10.1-experimental.0",
89
+ "@strapi/logger": "4.10.1-experimental.0",
90
+ "@strapi/permissions": "4.10.1-experimental.0",
91
+ "@strapi/plugin-content-manager": "4.10.1-experimental.0",
92
+ "@strapi/plugin-content-type-builder": "4.10.1-experimental.0",
93
+ "@strapi/plugin-email": "4.10.1-experimental.0",
94
+ "@strapi/plugin-upload": "4.10.1-experimental.0",
95
+ "@strapi/typescript-utils": "4.10.1-experimental.0",
96
+ "@strapi/utils": "4.10.1-experimental.0",
97
97
  "bcryptjs": "2.4.3",
98
98
  "boxen": "5.1.2",
99
99
  "chalk": "4.1.2",
@@ -109,6 +109,7 @@
109
109
  "fs-extra": "10.0.0",
110
110
  "glob": "7.2.0",
111
111
  "http-errors": "1.8.1",
112
+ "https-proxy-agent": "5.0.1",
112
113
  "inquirer": "8.2.5",
113
114
  "is-docker": "2.2.1",
114
115
  "koa": "2.13.4",
@@ -136,11 +137,11 @@
136
137
  },
137
138
  "devDependencies": {
138
139
  "supertest": "6.3.3",
139
- "typescript": "4.6.2"
140
+ "typescript": "5.0.4"
140
141
  },
141
142
  "engines": {
142
143
  "node": ">=14.19.1 <=18.x.x",
143
144
  "npm": ">=6.0.0"
144
145
  },
145
- "gitHead": "95d581b31bee464af42e5d8db408fa578d8532c7"
146
+ "gitHead": "ce60415a0779e850da2c2edd80799f98918c000c"
146
147
  }