@strapi/strapi 4.6.0-beta.0 → 4.6.0-beta.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/README.md +8 -4
- package/bin/strapi.js +139 -1
- package/lib/Strapi.js +8 -5
- package/lib/commands/opt-in-telemetry.js +2 -2
- package/lib/commands/opt-out-telemetry.js +2 -2
- package/lib/commands/transfer/export.js +158 -0
- package/lib/commands/transfer/import.js +154 -0
- package/lib/commands/transfer/transfer.js +127 -0
- package/lib/commands/transfer/utils.js +132 -0
- package/lib/commands/utils/commander.js +136 -0
- package/lib/commands/utils/helpers.js +108 -0
- package/lib/core-api/service/index.d.ts +1 -1
- package/lib/core-api/service/single-type.js +14 -1
- package/lib/services/entity-service/components.js +10 -4
- package/lib/services/entity-service/index.js +12 -2
- package/lib/services/errors.js +5 -1
- package/lib/services/event-hub.js +70 -8
- package/lib/services/metrics/admin-user-hash.js +21 -0
- package/lib/services/metrics/index.js +6 -4
- package/lib/services/metrics/middleware.js +1 -1
- package/lib/services/metrics/sender.js +17 -9
- package/lib/types/core/attributes/relation.d.ts +9 -12
- package/lib/types/core/schemas/index.d.ts +6 -1
- package/lib/types/core/strapi/index.d.ts +15 -4
- package/lib/types/factories.d.ts +3 -3
- package/lib/utils/ee.js +1 -1
- package/lib/utils/success.js +1 -1
- package/package.json +16 -15
|
@@ -10,7 +10,7 @@ const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
|
|
|
10
10
|
const { env } = require('@strapi/utils');
|
|
11
11
|
const ee = require('../../utils/ee');
|
|
12
12
|
const machineID = require('../../utils/machine-id');
|
|
13
|
-
const
|
|
13
|
+
const { generateAdminUserHash } = require('./admin-user-hash');
|
|
14
14
|
|
|
15
15
|
const defaultQueryOpts = {
|
|
16
16
|
timeout: 1000,
|
|
@@ -42,41 +42,49 @@ module.exports = (strapi) => {
|
|
|
42
42
|
const serverRootPath = strapi.dirs.app.root;
|
|
43
43
|
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const anonymousUserProperties = {
|
|
46
46
|
environment: strapi.config.environment,
|
|
47
47
|
os: os.type(),
|
|
48
48
|
osPlatform: os.platform(),
|
|
49
49
|
osArch: os.arch(),
|
|
50
50
|
osRelease: os.release(),
|
|
51
51
|
nodeVersion: process.versions.node,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const anonymousGroupProperties = {
|
|
52
55
|
docker: process.env.DOCKER || isDocker(),
|
|
53
56
|
isCI: ciEnv.isCI,
|
|
54
57
|
version: strapi.config.get('info.strapi'),
|
|
55
58
|
projectType: isEE ? 'Enterprise' : 'Community',
|
|
56
59
|
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
|
57
60
|
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
|
61
|
+
projectId: uuid,
|
|
58
62
|
isHostedOnStrapiCloud: env('STRAPI_HOSTING', null) === 'strapi.cloud',
|
|
59
63
|
};
|
|
60
64
|
|
|
61
|
-
addPackageJsonStrapiMetadata(
|
|
65
|
+
addPackageJsonStrapiMetadata(anonymousGroupProperties, strapi);
|
|
62
66
|
|
|
63
67
|
return async (event, payload = {}, opts = {}) => {
|
|
68
|
+
const userId = generateAdminUserHash(strapi);
|
|
69
|
+
|
|
64
70
|
const reqParams = {
|
|
65
71
|
method: 'POST',
|
|
66
72
|
body: JSON.stringify({
|
|
67
73
|
event,
|
|
68
|
-
|
|
74
|
+
userId,
|
|
69
75
|
deviceId,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
eventProperties: payload.eventProperties,
|
|
77
|
+
userProperties: userId ? { ...anonymousUserProperties, ...payload.userProperties } : {},
|
|
78
|
+
groupProperties: {
|
|
79
|
+
...anonymousGroupProperties,
|
|
80
|
+
...payload.groupProperties,
|
|
81
|
+
},
|
|
74
82
|
}),
|
|
75
83
|
..._.merge({}, defaultQueryOpts, opts),
|
|
76
84
|
};
|
|
77
85
|
|
|
78
86
|
try {
|
|
79
|
-
const res = await fetch(`${ANALYTICS_URI}/track`, reqParams);
|
|
87
|
+
const res = await fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
|
|
80
88
|
return res.ok;
|
|
81
89
|
} catch (err) {
|
|
82
90
|
return false;
|
|
@@ -3,7 +3,7 @@ import { Attribute, ConfigurableOption, PrivateOption } from './base';
|
|
|
3
3
|
import { GetAttributesByType, GetAttributesValues } from './utils';
|
|
4
4
|
|
|
5
5
|
export type BasicRelationsType = 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany';
|
|
6
|
-
export type PolymorphicRelationsType =
|
|
6
|
+
export type PolymorphicRelationsType = 'morphToOne' | 'morphToMany' | 'morphOne' | 'morphMany';
|
|
7
7
|
export type RelationsType = BasicRelationsType | PolymorphicRelationsType;
|
|
8
8
|
|
|
9
9
|
export interface BasicRelationAttributeProperties<
|
|
@@ -17,16 +17,14 @@ export interface BasicRelationAttributeProperties<
|
|
|
17
17
|
mappedBy?: RelationsKeysFromTo<T, S>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export interface PolymorphicRelationAttributeProperties<
|
|
21
|
-
R extends RelationsType,
|
|
22
|
-
> {
|
|
20
|
+
export interface PolymorphicRelationAttributeProperties<R extends RelationsType> {
|
|
23
21
|
relation: R;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
export type RelationAttribute<
|
|
27
25
|
S extends SchemaUID,
|
|
28
26
|
R extends RelationsType,
|
|
29
|
-
T extends R extends PolymorphicRelationsType ? never: SchemaUID = never
|
|
27
|
+
T extends R extends PolymorphicRelationsType ? never : SchemaUID = never
|
|
30
28
|
> = Attribute<'relation'> &
|
|
31
29
|
// Properties
|
|
32
30
|
(R extends BasicRelationsType
|
|
@@ -34,22 +32,21 @@ export type RelationAttribute<
|
|
|
34
32
|
: PolymorphicRelationAttributeProperties<R>) &
|
|
35
33
|
// Options
|
|
36
34
|
ConfigurableOption &
|
|
37
|
-
PrivateOption
|
|
35
|
+
PrivateOption;
|
|
38
36
|
|
|
39
37
|
export type RelationsKeysFromTo<
|
|
40
38
|
TTarget extends SchemaUID,
|
|
41
39
|
TSource extends SchemaUID
|
|
42
40
|
> = keyof PickRelationsFromTo<TTarget, TSource>;
|
|
43
41
|
|
|
44
|
-
export type PickRelationsFromTo<
|
|
45
|
-
TTarget,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
>;
|
|
42
|
+
export type PickRelationsFromTo<
|
|
43
|
+
TTarget extends SchemaUID,
|
|
44
|
+
TSource extends SchemaUID
|
|
45
|
+
> = GetAttributesByType<TTarget, 'relation', { target: TSource }>;
|
|
49
46
|
|
|
50
47
|
export type RelationPluralityModifier<
|
|
51
48
|
TRelation extends RelationsType,
|
|
52
|
-
TValue extends
|
|
49
|
+
TValue extends Record<string, unknown>
|
|
53
50
|
> = TRelation extends `${string}Many` ? TValue[] : TValue;
|
|
54
51
|
|
|
55
52
|
export type RelationValue<
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attribute, ComponentAttribute } from '../attributes';
|
|
2
|
-
import { KeysBy, StringRecord } from '../../utils';
|
|
2
|
+
import { KeysBy, SchemaUID, StringRecord } from '../../utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Literal union type representing the possible natures of a content type
|
|
@@ -98,6 +98,11 @@ export interface PluginOptions {}
|
|
|
98
98
|
export interface ContentTypeSchema extends Schema {
|
|
99
99
|
modelType: 'contentType';
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Unique identifier of the schema
|
|
103
|
+
*/
|
|
104
|
+
uid: SchemaUID;
|
|
105
|
+
|
|
101
106
|
/**
|
|
102
107
|
* Determine the type of the content type (single-type or collection-type)
|
|
103
108
|
*/
|
|
@@ -2,8 +2,8 @@ import type Koa from 'koa';
|
|
|
2
2
|
import { Database } from '@strapi/database';
|
|
3
3
|
|
|
4
4
|
import type { StringMap } from './utils';
|
|
5
|
-
import type { GenericController } from '../../../core-api/controller'
|
|
6
|
-
import type { GenericService } from '../../../core-api/service'
|
|
5
|
+
import type { GenericController } from '../../../core-api/controller';
|
|
6
|
+
import type { GenericService } from '../../../core-api/service';
|
|
7
7
|
|
|
8
8
|
// TODO move custom fields types to a separate file
|
|
9
9
|
interface CustomFieldServerOptions {
|
|
@@ -92,9 +92,16 @@ export interface Strapi {
|
|
|
92
92
|
*/
|
|
93
93
|
contentType(uid: string): any;
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Getter for the Strapi component container
|
|
97
|
+
*
|
|
98
|
+
* It returns all the registered components
|
|
99
|
+
*/
|
|
100
|
+
readonly components: any;
|
|
101
|
+
|
|
95
102
|
/**
|
|
96
103
|
* The custom fields registry
|
|
97
|
-
*
|
|
104
|
+
*
|
|
98
105
|
* It returns the custom fields interface
|
|
99
106
|
*/
|
|
100
107
|
readonly customFields: CustomFields;
|
|
@@ -361,7 +368,6 @@ export interface Strapi {
|
|
|
361
368
|
*/
|
|
362
369
|
log: any;
|
|
363
370
|
|
|
364
|
-
|
|
365
371
|
/**
|
|
366
372
|
* Used to manage cron within Strapi
|
|
367
373
|
*/
|
|
@@ -372,6 +378,11 @@ export interface Strapi {
|
|
|
372
378
|
*/
|
|
373
379
|
telemetry: any;
|
|
374
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Used to access ctx from anywhere within the Strapi application
|
|
383
|
+
*/
|
|
384
|
+
requestContext: any;
|
|
385
|
+
|
|
375
386
|
/**
|
|
376
387
|
* Strapi DB layer instance
|
|
377
388
|
*/
|
package/lib/types/factories.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Service,GenericService } from '../core-api/service';
|
|
1
|
+
import { Service, GenericService } from '../core-api/service';
|
|
2
2
|
import { Controller, GenericController } from '../core-api/controller';
|
|
3
3
|
import { Middleware } from '../middlewares';
|
|
4
4
|
import { Policy } from '../core/registries/policies';
|
|
5
|
-
import { Strapi } from '
|
|
5
|
+
import { Strapi } from './core/strapi';
|
|
6
6
|
|
|
7
7
|
type ControllerConfig<T extends Controller = Controller> = T;
|
|
8
8
|
|
|
@@ -30,7 +30,7 @@ type CollectionTypeRouterConfig = {
|
|
|
30
30
|
|
|
31
31
|
type RouterConfig = {
|
|
32
32
|
prefix?: string;
|
|
33
|
-
only
|
|
33
|
+
only?: string[];
|
|
34
34
|
except?: string[];
|
|
35
35
|
config: SingleTypeRouterConfig | CollectionTypeRouterConfig;
|
|
36
36
|
};
|
package/lib/utils/ee.js
CHANGED
package/lib/utils/success.js
CHANGED
|
@@ -17,7 +17,7 @@ try {
|
|
|
17
17
|
process.env.npm_config_global === 'true' ||
|
|
18
18
|
JSON.parse(process.env.npm_config_argv).original.includes('global')
|
|
19
19
|
) {
|
|
20
|
-
fetch('https://analytics.strapi.io/track', {
|
|
20
|
+
fetch('https://analytics.strapi.io/api/v2/track', {
|
|
21
21
|
method: 'POST',
|
|
22
22
|
body: JSON.stringify({
|
|
23
23
|
event: 'didInstallStrapi',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.6.0-beta.
|
|
3
|
+
"version": "4.6.0-beta.2",
|
|
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",
|
|
@@ -80,18 +80,19 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@koa/cors": "3.4.3",
|
|
82
82
|
"@koa/router": "10.1.1",
|
|
83
|
-
"@strapi/admin": "4.6.0-beta.
|
|
84
|
-
"@strapi/
|
|
85
|
-
"@strapi/
|
|
86
|
-
"@strapi/
|
|
87
|
-
"@strapi/
|
|
88
|
-
"@strapi/
|
|
89
|
-
"@strapi/
|
|
90
|
-
"@strapi/plugin-content-
|
|
91
|
-
"@strapi/plugin-
|
|
92
|
-
"@strapi/plugin-
|
|
93
|
-
"@strapi/
|
|
94
|
-
"@strapi/utils": "4.6.0-beta.
|
|
83
|
+
"@strapi/admin": "4.6.0-beta.2",
|
|
84
|
+
"@strapi/data-transfer": "4.6.0-beta.2",
|
|
85
|
+
"@strapi/database": "4.6.0-beta.2",
|
|
86
|
+
"@strapi/generate-new": "4.6.0-beta.2",
|
|
87
|
+
"@strapi/generators": "4.6.0-beta.2",
|
|
88
|
+
"@strapi/logger": "4.6.0-beta.2",
|
|
89
|
+
"@strapi/permissions": "4.6.0-beta.2",
|
|
90
|
+
"@strapi/plugin-content-manager": "4.6.0-beta.2",
|
|
91
|
+
"@strapi/plugin-content-type-builder": "4.6.0-beta.2",
|
|
92
|
+
"@strapi/plugin-email": "4.6.0-beta.2",
|
|
93
|
+
"@strapi/plugin-upload": "4.6.0-beta.2",
|
|
94
|
+
"@strapi/typescript-utils": "4.6.0-beta.2",
|
|
95
|
+
"@strapi/utils": "4.6.0-beta.2",
|
|
95
96
|
"bcryptjs": "2.4.3",
|
|
96
97
|
"boxen": "5.1.2",
|
|
97
98
|
"chalk": "4.1.2",
|
|
@@ -126,7 +127,7 @@
|
|
|
126
127
|
"open": "8.4.0",
|
|
127
128
|
"ora": "5.4.1",
|
|
128
129
|
"package-json": "7.0.0",
|
|
129
|
-
"qs": "6.
|
|
130
|
+
"qs": "6.11.0",
|
|
130
131
|
"resolve-cwd": "3.0.0",
|
|
131
132
|
"semver": "7.3.8",
|
|
132
133
|
"statuses": "2.0.1",
|
|
@@ -140,5 +141,5 @@
|
|
|
140
141
|
"node": ">=14.19.1 <=18.x.x",
|
|
141
142
|
"npm": ">=6.0.0"
|
|
142
143
|
},
|
|
143
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "b852090f931cd21868c4016f24db2f9fdfc7a7ab"
|
|
144
145
|
}
|