@strapi/strapi 4.10.1 → 4.10.2
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.
- package/lib/commands/actions/{build → build-command}/command.js +1 -1
- package/lib/commands/actions/develop/action.js +22 -3
- package/lib/commands/actions/telemetry/enable/action.js +3 -3
- package/lib/commands/index.js +1 -1
- package/lib/core/loaders/apis.js +5 -0
- package/lib/utils/machine-id.js +2 -2
- package/package.json +16 -17
- package/coverage/clover.xml +0 -1613
- package/coverage/coverage-final.json +0 -48
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/commands/__tests__/data-transfer/shared/index.html +0 -116
- package/coverage/lcov-report/commands/__tests__/data-transfer/shared/transfer.test.utils.js.html +0 -133
- package/coverage/lcov-report/commands/admin-create.js.html +0 -424
- package/coverage/lcov-report/commands/admin-reset.js.html +0 -241
- package/coverage/lcov-report/commands/generate-template.js.html +0 -373
- package/coverage/lcov-report/commands/index.html +0 -146
- package/coverage/lcov-report/commands/transfer/export.js.html +0 -619
- package/coverage/lcov-report/commands/transfer/import.js.html +0 -562
- package/coverage/lcov-report/commands/transfer/index.html +0 -146
- package/coverage/lcov-report/commands/transfer/transfer.js.html +0 -532
- package/coverage/lcov-report/commands/utils/helpers.js.html +0 -430
- package/coverage/lcov-report/commands/utils/index.html +0 -116
- package/coverage/lcov-report/core/registries/custom-fields.js.html +0 -301
- package/coverage/lcov-report/core/registries/index.html +0 -116
- package/coverage/lcov-report/core-api/controller/collection-type.js.html +0 -418
- package/coverage/lcov-report/core-api/controller/index.html +0 -161
- package/coverage/lcov-report/core-api/controller/index.js.html +0 -220
- package/coverage/lcov-report/core-api/controller/single-type.js.html +0 -274
- package/coverage/lcov-report/core-api/controller/transform.js.html +0 -376
- package/coverage/lcov-report/core-api/service/collection-type.js.html +0 -325
- package/coverage/lcov-report/core-api/service/index.html +0 -161
- package/coverage/lcov-report/core-api/service/index.js.html +0 -220
- package/coverage/lcov-report/core-api/service/pagination.js.html +0 -460
- package/coverage/lcov-report/core-api/service/single-type.js.html +0 -301
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -386
- package/coverage/lcov-report/load/filepath-to-prop-path.js.html +0 -151
- package/coverage/lcov-report/load/index.html +0 -116
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/services/content-api/index.html +0 -116
- package/coverage/lcov-report/services/content-api/index.js.html +0 -307
- package/coverage/lcov-report/services/content-api/permissions/engine.js.html +0 -100
- package/coverage/lcov-report/services/content-api/permissions/index.html +0 -131
- package/coverage/lcov-report/services/content-api/permissions/index.js.html +0 -529
- package/coverage/lcov-report/services/content-api/permissions/providers/action.js.html +0 -142
- package/coverage/lcov-report/services/content-api/permissions/providers/condition.js.html +0 -142
- package/coverage/lcov-report/services/content-api/permissions/providers/index.html +0 -146
- package/coverage/lcov-report/services/content-api/permissions/providers/index.js.html +0 -112
- package/coverage/lcov-report/services/core-store.js.html +0 -520
- package/coverage/lcov-report/services/entity-service/attributes/index.html +0 -131
- package/coverage/lcov-report/services/entity-service/attributes/index.js.html +0 -178
- package/coverage/lcov-report/services/entity-service/attributes/transforms.js.html +0 -145
- package/coverage/lcov-report/services/entity-service/components.js.html +0 -1246
- package/coverage/lcov-report/services/entity-service/index.html +0 -146
- package/coverage/lcov-report/services/entity-service/index.js.html +0 -1120
- package/coverage/lcov-report/services/entity-service/params.js.html +0 -112
- package/coverage/lcov-report/services/entity-validator/__tests__/relations/utils/index.html +0 -116
- package/coverage/lcov-report/services/entity-validator/__tests__/relations/utils/relations.testdata.js.html +0 -544
- package/coverage/lcov-report/services/entity-validator/index.html +0 -131
- package/coverage/lcov-report/services/entity-validator/index.js.html +0 -1231
- package/coverage/lcov-report/services/entity-validator/validators.js.html +0 -733
- package/coverage/lcov-report/services/event-hub.js.html +0 -319
- package/coverage/lcov-report/services/fs.js.html +0 -259
- package/coverage/lcov-report/services/index.html +0 -161
- package/coverage/lcov-report/services/metrics/admin-user-hash.js.html +0 -148
- package/coverage/lcov-report/services/metrics/index.html +0 -206
- package/coverage/lcov-report/services/metrics/index.js.html +0 -265
- package/coverage/lcov-report/services/metrics/is-truthy.js.html +0 -112
- package/coverage/lcov-report/services/metrics/middleware.js.html +0 -184
- package/coverage/lcov-report/services/metrics/rate-limiter.js.html +0 -166
- package/coverage/lcov-report/services/metrics/sender.js.html +0 -394
- package/coverage/lcov-report/services/metrics/stringify-deep.js.html +0 -151
- package/coverage/lcov-report/services/utils/index.html +0 -116
- package/coverage/lcov-report/services/utils/upload-files.js.html +0 -322
- package/coverage/lcov-report/services/worker-queue.js.html +0 -262
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/utils/convert-custom-field-type.js.html +0 -151
- package/coverage/lcov-report/utils/index.html +0 -146
- package/coverage/lcov-report/utils/machine-id.js.html +0 -127
- package/coverage/lcov-report/utils/url-from-segments.js.html +0 -121
- package/lib/commands/__tests__/commands.test.js +0 -20
- package/lib/commands/__tests__/commands.test.utils.js +0 -16
- package/lib/commands/actions/admin/create-user/__tests__/admin.create-user.test.js +0 -450
- package/lib/commands/actions/admin/reset-user-password/__tests__/admin.reset-user-password.test.js +0 -145
- package/lib/commands/actions/export/__tests__/export.test.js +0 -175
- package/lib/commands/actions/import/__tests__/import.test.js +0 -143
- package/lib/commands/actions/templates/generate/__tests__/templates.generate.js +0 -118
- package/lib/commands/actions/transfer/__tests__/transfer.test.js +0 -178
- package/lib/core/registries/__tests__/custom-fields.test.js +0 -152
- package/lib/core-api/__tests__/controller.test.js +0 -39
- package/lib/core-api/controller/__tests__/transform.test.js +0 -226
- package/lib/core-api/service/__tests__/index.test.js +0 -127
- package/lib/core-api/service/__tests__/pagination.test.js +0 -275
- package/lib/load/__tests__/filepath-to-prop-path.test.js +0 -30
- package/lib/middlewares/__tests__/errors.test.js +0 -21
- package/lib/services/__tests__/content-api-permissions.test.js +0 -291
- package/lib/services/__tests__/core-store.test.js +0 -148
- package/lib/services/__tests__/event-hub.test.js +0 -126
- package/lib/services/__tests__/fs.test.js +0 -78
- package/lib/services/__tests__/worker-queue.test.js +0 -47
- package/lib/services/entity-service/__tests__/entity-service-events.test.js +0 -117
- package/lib/services/entity-service/__tests__/entity-service.test.js +0 -587
- package/lib/services/entity-validator/__tests__/biginteger-validators.test.js +0 -220
- package/lib/services/entity-validator/__tests__/date-validators.test.js +0 -183
- package/lib/services/entity-validator/__tests__/datetime-validators.test.js +0 -183
- package/lib/services/entity-validator/__tests__/email-validators.test.js +0 -56
- package/lib/services/entity-validator/__tests__/enumeration-validators.test.js +0 -43
- package/lib/services/entity-validator/__tests__/float-validators.test.js +0 -278
- package/lib/services/entity-validator/__tests__/index.test.js +0 -609
- package/lib/services/entity-validator/__tests__/integer-validators.test.js +0 -278
- package/lib/services/entity-validator/__tests__/relations/attribute-level.test.js +0 -123
- package/lib/services/entity-validator/__tests__/relations/component-level.test.js +0 -275
- package/lib/services/entity-validator/__tests__/relations/dynamic-zone-level.test.js +0 -159
- package/lib/services/entity-validator/__tests__/relations/media-level.test.js +0 -74
- package/lib/services/entity-validator/__tests__/relations/utils/relations.testdata.js +0 -153
- package/lib/services/entity-validator/__tests__/string-validators.test.js +0 -374
- package/lib/services/entity-validator/__tests__/time-validators.test.js +0 -183
- package/lib/services/entity-validator/__tests__/timestamp-validators.test.js +0 -204
- package/lib/services/entity-validator/__tests__/uid-validators.test.js +0 -229
- package/lib/services/metrics/__tests__/admin-user-hash.test.js +0 -41
- package/lib/services/metrics/__tests__/index.test.js +0 -157
- package/lib/services/metrics/__tests__/is-truthy.js +0 -33
- package/lib/services/metrics/__tests__/middleware.test.js +0 -60
- package/lib/services/metrics/__tests__/rate-limiter.test.js +0 -50
- package/lib/services/metrics/__tests__/stringify-deep.test.js +0 -27
- package/lib/utils/__tests__/convert-custom-field-type.test.js +0 -69
- package/lib/utils/__tests__/url-from-segments.test.js +0 -40
- /package/lib/commands/actions/{build → build-command}/action.js +0 -0
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
});
|
|
File without changes
|