@strapi/strapi 4.2.3 → 4.3.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.
- package/bin/strapi.js +13 -0
- package/lib/Strapi.js +41 -10
- package/lib/commands/admin-create.js +2 -1
- package/lib/commands/admin-reset.js +2 -1
- package/lib/commands/build.js +8 -46
- package/lib/commands/builders/admin.js +56 -0
- package/lib/commands/builders/index.js +9 -0
- package/lib/commands/builders/typescript.js +32 -0
- package/lib/commands/configurationDump.js +2 -1
- package/lib/commands/configurationRestore.js +3 -1
- package/lib/commands/console.js +4 -3
- package/lib/commands/content-types/list.js +2 -1
- package/lib/commands/controllers/list.js +2 -1
- package/lib/commands/develop.js +111 -74
- package/lib/commands/hooks/list.js +2 -1
- package/lib/commands/middlewares/list.js +2 -1
- package/lib/commands/policies/list.js +2 -1
- package/lib/commands/routes/list.js +2 -1
- package/lib/commands/services/list.js +2 -1
- package/lib/commands/start.js +18 -2
- package/lib/commands/ts/generate-types.js +26 -0
- package/lib/commands/watchAdmin.js +5 -10
- package/lib/compile.js +20 -0
- package/lib/core/app-configuration/index.js +4 -3
- package/lib/core/app-configuration/load-config-file.js +3 -1
- package/lib/core/bootstrap.js +2 -2
- package/lib/core/domain/content-type/validator.js +29 -8
- package/lib/core/loaders/apis.js +6 -5
- package/lib/core/loaders/components.js +5 -4
- package/lib/core/loaders/middlewares.js +4 -2
- package/lib/core/loaders/plugins/get-enabled-plugins.js +2 -1
- package/lib/core/loaders/plugins/get-user-plugins-config.js +2 -2
- package/lib/core/loaders/plugins/index.js +1 -1
- package/lib/core/loaders/policies.js +4 -2
- package/lib/core/loaders/src-index.js +6 -4
- package/lib/core/registries/policies.d.ts +1 -1
- package/lib/core-api/controller/index.d.ts +16 -14
- package/lib/core-api/service/index.d.ts +10 -9
- package/lib/global.d.ts +61 -0
- package/lib/index.d.ts +2 -24
- package/lib/index.js +1 -0
- package/lib/load/load-files.js +3 -1
- package/lib/middlewares/favicon.js +1 -1
- package/lib/middlewares/public/index.js +1 -1
- package/lib/services/cron.js +7 -3
- package/lib/services/entity-service/index.d.ts +7 -1
- package/lib/services/entity-service/index.js +11 -1
- package/lib/services/fs.js +1 -1
- package/lib/services/metrics/index.js +5 -1
- package/lib/services/metrics/sender.js +7 -0
- package/lib/services/server/middleware.js +1 -1
- package/lib/services/utils/upload-files.js +1 -1
- package/lib/types/core/attributes/base.d.ts +74 -0
- package/lib/types/core/attributes/biginteger.d.ts +22 -0
- package/lib/types/core/attributes/boolean.d.ts +20 -0
- package/lib/types/core/attributes/common.d.ts +42 -0
- package/lib/types/core/attributes/component.d.ts +41 -0
- package/lib/types/core/attributes/date-time.d.ts +22 -0
- package/lib/types/core/attributes/date.d.ts +22 -0
- package/lib/types/core/attributes/decimal.d.ts +22 -0
- package/lib/types/core/attributes/dynamic-zone.d.ts +29 -0
- package/lib/types/core/attributes/email.d.ts +24 -0
- package/lib/types/core/attributes/enumeration.d.ts +28 -0
- package/lib/types/core/attributes/float.d.ts +22 -0
- package/lib/types/core/attributes/index.d.ts +26 -0
- package/lib/types/core/attributes/integer.d.ts +22 -0
- package/lib/types/core/attributes/json.d.ts +14 -0
- package/lib/types/core/attributes/media.d.ts +36 -0
- package/lib/types/core/attributes/password.d.ts +22 -0
- package/lib/types/core/attributes/relation.d.ts +66 -0
- package/lib/types/core/attributes/richtext.d.ts +22 -0
- package/lib/types/core/attributes/string.d.ts +30 -0
- package/lib/types/core/attributes/text.d.ts +30 -0
- package/lib/types/core/attributes/time.d.ts +22 -0
- package/lib/types/core/attributes/timestamp.d.ts +22 -0
- package/lib/types/core/attributes/uid.d.ts +57 -0
- package/lib/types/core/attributes/utils.d.ts +99 -0
- package/lib/types/core/index.d.ts +3 -0
- package/lib/types/core/schemas/index.d.ts +126 -0
- package/lib/types/core/strapi/index.d.ts +391 -0
- package/lib/types/factories.d.ts +60 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/utils.d.ts +95 -0
- package/lib/utils/get-dirs.js +24 -10
- package/lib/utils/import-default.js +10 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/lifecycles.js +15 -0
- package/lib/utils/machine-id.js +2 -2
- package/lib/utils/update-notifier/index.js +1 -1
- package/package.json +18 -16
- package/lib/factories.d.ts +0 -48
package/lib/services/cron.js
CHANGED
|
@@ -5,6 +5,7 @@ const { isFunction } = require('lodash/fp');
|
|
|
5
5
|
|
|
6
6
|
const createCronService = () => {
|
|
7
7
|
let jobsSpecs = [];
|
|
8
|
+
let running = false;
|
|
8
9
|
|
|
9
10
|
return {
|
|
10
11
|
add(tasks = {}) {
|
|
@@ -29,18 +30,21 @@ const createCronService = () => {
|
|
|
29
30
|
|
|
30
31
|
const job = new Job(null, fnWithStrapi);
|
|
31
32
|
jobsSpecs.push({ job, options });
|
|
33
|
+
|
|
34
|
+
if (running) {
|
|
35
|
+
job.schedule(options);
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
return this;
|
|
34
39
|
},
|
|
35
40
|
start() {
|
|
36
|
-
if (!strapi.config.get('server.cron.enabled')) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
41
|
jobsSpecs.forEach(({ job, options }) => job.schedule(options));
|
|
42
|
+
running = true;
|
|
40
43
|
return this;
|
|
41
44
|
},
|
|
42
45
|
stop() {
|
|
43
46
|
jobsSpecs.forEach(({ job }) => job.cancel());
|
|
47
|
+
running = false;
|
|
44
48
|
return this;
|
|
45
49
|
},
|
|
46
50
|
destroy() {
|
|
@@ -6,6 +6,7 @@ type ID = number | string;
|
|
|
6
6
|
type EntityServiceAction =
|
|
7
7
|
| 'findMany'
|
|
8
8
|
| 'findPage'
|
|
9
|
+
| 'findWithRelationCountsPage'
|
|
9
10
|
| 'findWithRelationCounts'
|
|
10
11
|
| 'findOne'
|
|
11
12
|
| 'count'
|
|
@@ -54,7 +55,7 @@ export interface EntityService {
|
|
|
54
55
|
pagination: PaginationInfo;
|
|
55
56
|
}>;
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
findWithRelationCountsPage<K extends keyof AllTypes, T extends AllTypes[K]>(
|
|
58
59
|
uid: K,
|
|
59
60
|
params: Params<T>
|
|
60
61
|
): Promise<{
|
|
@@ -62,6 +63,11 @@ export interface EntityService {
|
|
|
62
63
|
pagination: PaginationInfo;
|
|
63
64
|
}>;
|
|
64
65
|
|
|
66
|
+
findWithRelationCounts<K extends keyof AllTypes, T extends AllTypes[K]>(
|
|
67
|
+
uid: K,
|
|
68
|
+
params: Params<T>
|
|
69
|
+
): Promise<T[]>;
|
|
70
|
+
|
|
65
71
|
findOne<K extends keyof AllTypes, T extends AllTypes[K]>(
|
|
66
72
|
uid: K,
|
|
67
73
|
entityId: ID,
|
|
@@ -125,7 +125,7 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
125
125
|
},
|
|
126
126
|
|
|
127
127
|
// TODO: streamline the logic based on the populate option
|
|
128
|
-
async
|
|
128
|
+
async findWithRelationCountsPage(uid, opts) {
|
|
129
129
|
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findWithRelationCounts' });
|
|
130
130
|
|
|
131
131
|
const query = transformParamsToQuery(uid, wrappedParams);
|
|
@@ -138,6 +138,16 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
138
138
|
};
|
|
139
139
|
},
|
|
140
140
|
|
|
141
|
+
async findWithRelationCounts(uid, opts) {
|
|
142
|
+
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findWithRelationCounts' });
|
|
143
|
+
|
|
144
|
+
const query = transformParamsToQuery(uid, wrappedParams);
|
|
145
|
+
|
|
146
|
+
const results = await db.query(uid).findMany(query);
|
|
147
|
+
|
|
148
|
+
return results;
|
|
149
|
+
},
|
|
150
|
+
|
|
141
151
|
async findOne(uid, entityId, opts) {
|
|
142
152
|
const wrappedParams = await this.wrapParams(opts, { uid, action: 'findOne' });
|
|
143
153
|
|
package/lib/services/fs.js
CHANGED
|
@@ -12,7 +12,7 @@ module.exports = strapi => {
|
|
|
12
12
|
|
|
13
13
|
const normalizedPath = path.normalize(filePath).replace(/^\/?(\.\/|\.\.\/)+/, '');
|
|
14
14
|
|
|
15
|
-
return path.resolve(strapi.dirs.root, normalizedPath);
|
|
15
|
+
return path.resolve(strapi.dirs.app.root, normalizedPath);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const strapiFS = {
|
|
@@ -33,6 +33,10 @@ const createTelemetryInstance = strapi => {
|
|
|
33
33
|
const sendEvent = wrapWithRateLimit(sender, { limitedEvents: LIMITED_EVENTS });
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
|
+
get isDisabled() {
|
|
37
|
+
return isDisabled;
|
|
38
|
+
},
|
|
39
|
+
|
|
36
40
|
register() {
|
|
37
41
|
if (!isDisabled) {
|
|
38
42
|
const pingCron = scheduleJob('0 0 12 * * *', () => sendEvent('ping'));
|
|
@@ -92,7 +96,7 @@ const hashProject = strapi =>
|
|
|
92
96
|
|
|
93
97
|
const hashDep = strapi => {
|
|
94
98
|
const depStr = JSON.stringify(strapi.config.info.dependencies);
|
|
95
|
-
const readmePath = path.join(strapi.dirs.root, 'README.md');
|
|
99
|
+
const readmePath = path.join(strapi.dirs.app.root, 'README.md');
|
|
96
100
|
|
|
97
101
|
try {
|
|
98
102
|
if (fs.existsSync(readmePath)) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
const _ = require('lodash');
|
|
5
6
|
const isDocker = require('is-docker');
|
|
6
7
|
const fetch = require('node-fetch');
|
|
7
8
|
const ciEnv = require('ci-info');
|
|
9
|
+
const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
|
|
8
10
|
const ee = require('../../utils/ee');
|
|
9
11
|
const machineID = require('../../utils/machine-id');
|
|
10
12
|
const stringifyDeep = require('./stringify-deep');
|
|
@@ -36,6 +38,9 @@ module.exports = strapi => {
|
|
|
36
38
|
const deviceId = machineID();
|
|
37
39
|
const isEE = strapi.EE === true && ee.isEE === true;
|
|
38
40
|
|
|
41
|
+
const serverRootPath = strapi.dirs.app.root;
|
|
42
|
+
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
|
43
|
+
|
|
39
44
|
const anonymous_metadata = {
|
|
40
45
|
environment: strapi.config.environment,
|
|
41
46
|
os: os.type(),
|
|
@@ -47,6 +52,8 @@ module.exports = strapi => {
|
|
|
47
52
|
version: strapi.config.get('info.strapi'),
|
|
48
53
|
strapiVersion: strapi.config.get('info.strapi'),
|
|
49
54
|
projectType: isEE ? 'Enterprise' : 'Community',
|
|
55
|
+
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
|
56
|
+
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
|
50
57
|
};
|
|
51
58
|
|
|
52
59
|
addPackageJsonStrapiMetadata(anonymous_metadata, strapi);
|
|
@@ -112,7 +112,7 @@ const resolveCustomMiddleware = (resolve, strapi) => {
|
|
|
112
112
|
modulePath = require.resolve(resolve);
|
|
113
113
|
} catch (error) {
|
|
114
114
|
if (error.code === 'MODULE_NOT_FOUND') {
|
|
115
|
-
modulePath = path.resolve(strapi.dirs.root, resolve);
|
|
115
|
+
modulePath = path.resolve(strapi.dirs.dist.root, resolve);
|
|
116
116
|
} else {
|
|
117
117
|
throw error;
|
|
118
118
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GetAttributeValue } from './utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* List of all the Strapi attribute types
|
|
5
|
+
*/
|
|
6
|
+
export type AttributeType =
|
|
7
|
+
| 'string'
|
|
8
|
+
| 'text'
|
|
9
|
+
| 'richtext'
|
|
10
|
+
| 'email'
|
|
11
|
+
| 'password'
|
|
12
|
+
| 'date'
|
|
13
|
+
| 'time'
|
|
14
|
+
| 'datetime'
|
|
15
|
+
| 'timestamp'
|
|
16
|
+
| 'integer'
|
|
17
|
+
| 'biginteger'
|
|
18
|
+
| 'float'
|
|
19
|
+
| 'decimal'
|
|
20
|
+
| 'uid'
|
|
21
|
+
| 'enumeration'
|
|
22
|
+
| 'boolean'
|
|
23
|
+
| 'json'
|
|
24
|
+
| 'media'
|
|
25
|
+
| 'relation'
|
|
26
|
+
| 'component'
|
|
27
|
+
| 'dynamiczone';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Most basic shape of a schema attribute
|
|
31
|
+
*/
|
|
32
|
+
export interface Attribute<T extends AttributeType = AttributeType> {
|
|
33
|
+
/**
|
|
34
|
+
* Type of the attribute
|
|
35
|
+
*/
|
|
36
|
+
type: T;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Options defined and used by the plugins
|
|
40
|
+
*/
|
|
41
|
+
pluginOptions?: object;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Common attributes Options
|
|
45
|
+
|
|
46
|
+
export interface RequiredOption {
|
|
47
|
+
required?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface PrivateOption {
|
|
51
|
+
private?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface UniqueOption {
|
|
55
|
+
unique?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface DefaultOption<T> {
|
|
59
|
+
default?: T;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ConfigurableOption {
|
|
63
|
+
configurable?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface MinMaxOption<T = number> {
|
|
67
|
+
min?: T;
|
|
68
|
+
max?: T;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface MinMaxLengthOption {
|
|
72
|
+
minLength?: number;
|
|
73
|
+
maxLength?: number;
|
|
74
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
MinMaxOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type BigIntegerAttribute = Attribute<'biginteger'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<BigIntegerValue> &
|
|
14
|
+
MinMaxOption<string> &
|
|
15
|
+
PrivateOption &
|
|
16
|
+
RequiredOption;
|
|
17
|
+
|
|
18
|
+
export type BigIntegerValue = string;
|
|
19
|
+
|
|
20
|
+
export type GetBigIntegerAttributeValue<T extends Attribute> = T extends BigIntegerAttribute
|
|
21
|
+
? BigIntegerValue
|
|
22
|
+
: never;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
PrivateOption,
|
|
6
|
+
RequiredOption,
|
|
7
|
+
} from './base';
|
|
8
|
+
|
|
9
|
+
export type BooleanAttribute = Attribute<'boolean'> &
|
|
10
|
+
// Options
|
|
11
|
+
ConfigurableOption &
|
|
12
|
+
DefaultOption<BooleanValue> &
|
|
13
|
+
PrivateOption &
|
|
14
|
+
RequiredOption;
|
|
15
|
+
|
|
16
|
+
export type BooleanValue = boolean;
|
|
17
|
+
|
|
18
|
+
export type GetBooleanAttributeValue<T extends Attribute> = T extends BooleanAttribute
|
|
19
|
+
? BooleanValue
|
|
20
|
+
: never;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strapi custom scalar types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { MinMaxLengthOption, MinMaxOption } from './base';
|
|
6
|
+
import { StringAttribute } from './string';
|
|
7
|
+
|
|
8
|
+
export type JSON<T extends object = object> = T;
|
|
9
|
+
|
|
10
|
+
export type Media = any;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Setters for the attributes options
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// required
|
|
17
|
+
export type RequiredAttribute = { required: true };
|
|
18
|
+
export type NonRequiredAttribute = { required: false };
|
|
19
|
+
|
|
20
|
+
// private
|
|
21
|
+
export type PrivateAttribute = { private: true };
|
|
22
|
+
export type NonPrivateAttribute = { private: false };
|
|
23
|
+
|
|
24
|
+
// unique
|
|
25
|
+
export type UniqueAttribute = { unique: true };
|
|
26
|
+
export type NonUniqueAttribute = { unique: false };
|
|
27
|
+
|
|
28
|
+
// configurable
|
|
29
|
+
export type ConfigurableAttribute = { configurable: true };
|
|
30
|
+
export type NonConfigurableAttribute = { configurable: false };
|
|
31
|
+
|
|
32
|
+
// min/max
|
|
33
|
+
export type SetMinMax<T extends MinMaxOption<U>, U = number> = T;
|
|
34
|
+
|
|
35
|
+
// minLength/maxLength
|
|
36
|
+
export type SetMinMaxLength<T extends MinMaxLengthOption> = T;
|
|
37
|
+
|
|
38
|
+
// pluginOptions
|
|
39
|
+
export type SetPluginOptions<T extends object = object> = { pluginOptions?: T };
|
|
40
|
+
|
|
41
|
+
// default
|
|
42
|
+
export type DefaultTo<T> = { default: T };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Attribute, ConfigurableOption, MinMaxOption, PrivateOption, RequiredOption } from './base';
|
|
2
|
+
import { GetAttributesValues } from './utils';
|
|
3
|
+
|
|
4
|
+
export interface ComponentAttributeProperties<
|
|
5
|
+
// Targeted component
|
|
6
|
+
T extends Strapi.ComponentUIDs,
|
|
7
|
+
// Repeatable
|
|
8
|
+
R extends boolean = false
|
|
9
|
+
> {
|
|
10
|
+
component: T;
|
|
11
|
+
repeatable?: R;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ComponentAttribute<
|
|
15
|
+
// Targeted component
|
|
16
|
+
T extends Strapi.ComponentUIDs,
|
|
17
|
+
// Repeatable
|
|
18
|
+
R extends boolean = false
|
|
19
|
+
> = Attribute<'component'> &
|
|
20
|
+
// Component Properties
|
|
21
|
+
ComponentAttributeProperties<T, R> &
|
|
22
|
+
// Options
|
|
23
|
+
ConfigurableOption &
|
|
24
|
+
MinMaxOption &
|
|
25
|
+
PrivateOption &
|
|
26
|
+
RequiredOption;
|
|
27
|
+
|
|
28
|
+
export type ComponentValue<T extends Strapi.ComponentUIDs, R extends boolean> = GetAttributesValues<
|
|
29
|
+
T
|
|
30
|
+
> extends infer V
|
|
31
|
+
? R extends true
|
|
32
|
+
? V[]
|
|
33
|
+
: V
|
|
34
|
+
: never;
|
|
35
|
+
|
|
36
|
+
export type GetComponentAttributeValue<T extends Attribute> = T extends ComponentAttribute<
|
|
37
|
+
infer U,
|
|
38
|
+
infer R
|
|
39
|
+
>
|
|
40
|
+
? ComponentValue<U, R>
|
|
41
|
+
: never;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
PrivateOption,
|
|
6
|
+
RequiredOption,
|
|
7
|
+
UniqueOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type DateTimeAttribute = Attribute<'datetime'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<DateTimeValue> &
|
|
14
|
+
PrivateOption &
|
|
15
|
+
RequiredOption &
|
|
16
|
+
UniqueOption;
|
|
17
|
+
|
|
18
|
+
export type DateTimeValue = string;
|
|
19
|
+
|
|
20
|
+
export type GetDateTimeAttributeValue<T extends Attribute> = T extends DateTimeAttribute
|
|
21
|
+
? DateTimeValue
|
|
22
|
+
: never;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
PrivateOption,
|
|
6
|
+
RequiredOption,
|
|
7
|
+
UniqueOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type DateAttribute = Attribute<'date'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<DateValue> &
|
|
14
|
+
PrivateOption &
|
|
15
|
+
RequiredOption &
|
|
16
|
+
UniqueOption;
|
|
17
|
+
|
|
18
|
+
export type DateValue = Date;
|
|
19
|
+
|
|
20
|
+
export type GetDateAttributeValue<T extends Attribute> = T extends DateAttribute
|
|
21
|
+
? DateValue
|
|
22
|
+
: never;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
MinMaxOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type DecimalAttribute = Attribute<'decimal'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<DecimalValue> &
|
|
14
|
+
MinMaxOption &
|
|
15
|
+
PrivateOption &
|
|
16
|
+
RequiredOption;
|
|
17
|
+
|
|
18
|
+
export type DecimalValue = number;
|
|
19
|
+
|
|
20
|
+
export type GetDecimalAttributeValue<T extends Attribute> = T extends DecimalAttribute
|
|
21
|
+
? DecimalValue
|
|
22
|
+
: never;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SchemaUID, GetArrayValues } from '../../utils';
|
|
2
|
+
import { Attribute, ConfigurableOption, MinMaxOption, RequiredOption } from './base';
|
|
3
|
+
import { GetAttributesValues } from './utils';
|
|
4
|
+
|
|
5
|
+
export interface DynamicZoneAttributeProperties<T extends Strapi.ComponentUIDs[] = []> {
|
|
6
|
+
components: T;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type DynamicZoneAttribute<T extends Strapi.ComponentUIDs[] = []> = Attribute<'dynamiczone'> &
|
|
10
|
+
// Properties
|
|
11
|
+
DynamicZoneAttributeProperties<T> &
|
|
12
|
+
// Options
|
|
13
|
+
ConfigurableOption &
|
|
14
|
+
MinMaxOption &
|
|
15
|
+
RequiredOption;
|
|
16
|
+
|
|
17
|
+
type DynamicZoneValue<T extends Strapi.ComponentUIDs[]> = Array<
|
|
18
|
+
GetArrayValues<T> extends infer P
|
|
19
|
+
? P extends SchemaUID
|
|
20
|
+
? GetAttributesValues<P> & { __component: P }
|
|
21
|
+
: never
|
|
22
|
+
: never
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export type GetDynamicZoneAttributeValue<T extends Attribute> = T extends DynamicZoneAttribute<
|
|
26
|
+
infer U
|
|
27
|
+
>
|
|
28
|
+
? DynamicZoneValue<U>
|
|
29
|
+
: never;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
MinMaxLengthOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
UniqueOption,
|
|
9
|
+
} from './base';
|
|
10
|
+
|
|
11
|
+
export type EmailAttribute = Attribute<'email'> &
|
|
12
|
+
// Options
|
|
13
|
+
ConfigurableOption &
|
|
14
|
+
DefaultOption<EmailValue> &
|
|
15
|
+
MinMaxLengthOption &
|
|
16
|
+
PrivateOption &
|
|
17
|
+
RequiredOption &
|
|
18
|
+
UniqueOption;
|
|
19
|
+
|
|
20
|
+
export type EmailValue = string;
|
|
21
|
+
|
|
22
|
+
export type GetEmailAttributeValue<T extends Attribute> = T extends EmailAttribute
|
|
23
|
+
? EmailValue
|
|
24
|
+
: never;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GetArrayValues } from '../../utils';
|
|
2
|
+
import {
|
|
3
|
+
Attribute,
|
|
4
|
+
ConfigurableOption,
|
|
5
|
+
DefaultOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export interface EnumerationAttributeProperties<T extends string[] = []> {
|
|
11
|
+
enum: T;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type EnumerationAttribute<T extends string[] = []> = Attribute<'enumeration'> &
|
|
15
|
+
EnumerationAttributeProperties<T> &
|
|
16
|
+
// Options
|
|
17
|
+
ConfigurableOption &
|
|
18
|
+
DefaultOption<T> &
|
|
19
|
+
PrivateOption &
|
|
20
|
+
RequiredOption;
|
|
21
|
+
|
|
22
|
+
export type EnumerationValue<T extends string[]> = GetArrayValues<T>;
|
|
23
|
+
|
|
24
|
+
export type GetEnumerationAttributeValue<T extends Attribute> = T extends EnumerationAttribute<
|
|
25
|
+
infer U
|
|
26
|
+
>
|
|
27
|
+
? EnumerationValue<U>
|
|
28
|
+
: never;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
MinMaxOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type FloatAttribute = Attribute<'float'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<FloatValue> &
|
|
14
|
+
MinMaxOption &
|
|
15
|
+
PrivateOption &
|
|
16
|
+
RequiredOption;
|
|
17
|
+
|
|
18
|
+
export type FloatValue = number;
|
|
19
|
+
|
|
20
|
+
export type GetFloatAttributeValue<T extends Attribute> = T extends FloatAttribute
|
|
21
|
+
? FloatValue
|
|
22
|
+
: never;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './base';
|
|
2
|
+
|
|
3
|
+
export * from './biginteger';
|
|
4
|
+
export * from './boolean';
|
|
5
|
+
export * from './component';
|
|
6
|
+
export * from './decimal';
|
|
7
|
+
export * from './dynamic-zone';
|
|
8
|
+
export * from './enumeration';
|
|
9
|
+
export * from './float';
|
|
10
|
+
export * from './integer';
|
|
11
|
+
export * from './json';
|
|
12
|
+
export * from './media';
|
|
13
|
+
export * from './password';
|
|
14
|
+
export * from './relation';
|
|
15
|
+
export * from './richtext';
|
|
16
|
+
export * from './string';
|
|
17
|
+
export * from './text';
|
|
18
|
+
export * from './uid';
|
|
19
|
+
export * from './email';
|
|
20
|
+
export * from './date';
|
|
21
|
+
export * from './date-time';
|
|
22
|
+
export * from './timestamp';
|
|
23
|
+
export * from './time';
|
|
24
|
+
|
|
25
|
+
export * from './common';
|
|
26
|
+
export * from './utils';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
MinMaxOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type IntegerAttribute = Attribute<'integer'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<IntegerValue> &
|
|
14
|
+
MinMaxOption &
|
|
15
|
+
PrivateOption &
|
|
16
|
+
RequiredOption;
|
|
17
|
+
|
|
18
|
+
export type IntegerValue = number;
|
|
19
|
+
|
|
20
|
+
export type GetIntegerAttributeValue<T extends Attribute> = T extends IntegerAttribute
|
|
21
|
+
? IntegerValue
|
|
22
|
+
: never;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Attribute, ConfigurableOption, PrivateOption, RequiredOption } from './base';
|
|
2
|
+
import { JSON } from './common';
|
|
3
|
+
|
|
4
|
+
export type JSONAttribute = Attribute<'json'> &
|
|
5
|
+
//Options
|
|
6
|
+
ConfigurableOption &
|
|
7
|
+
RequiredOption &
|
|
8
|
+
PrivateOption;
|
|
9
|
+
|
|
10
|
+
export type JsonValue = JSON;
|
|
11
|
+
|
|
12
|
+
export type GetJsonAttributeValue<T extends Attribute> = T extends JSONAttribute
|
|
13
|
+
? JsonValue
|
|
14
|
+
: never;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Attribute, ConfigurableOption, PrivateOption, RequiredOption } from './base';
|
|
2
|
+
import { Media } from './common';
|
|
3
|
+
|
|
4
|
+
export type AllowedMediaTypes = 'images' | 'videos' | 'files' | 'audios';
|
|
5
|
+
|
|
6
|
+
export interface MediaAttributeProperties<
|
|
7
|
+
// Media Type
|
|
8
|
+
T extends AllowedMediaTypes = undefined,
|
|
9
|
+
// Multiple
|
|
10
|
+
U extends boolean = false
|
|
11
|
+
> {
|
|
12
|
+
allowedTypes?: T;
|
|
13
|
+
multiple?: U;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type MediaAttribute<
|
|
17
|
+
// Media Type
|
|
18
|
+
T extends AllowedMediaTypes = undefined,
|
|
19
|
+
// Multiple
|
|
20
|
+
U extends boolean = false
|
|
21
|
+
> = Attribute<'media'> &
|
|
22
|
+
// Properties
|
|
23
|
+
MediaAttributeProperties<T, U> &
|
|
24
|
+
// Options
|
|
25
|
+
ConfigurableOption &
|
|
26
|
+
RequiredOption &
|
|
27
|
+
PrivateOption;
|
|
28
|
+
|
|
29
|
+
export type MediaValue<T extends boolean = false> = T extends true ? Media[] : Media;
|
|
30
|
+
|
|
31
|
+
export type GetMediaAttributeValue<T extends Attribute> = T extends MediaAttribute<
|
|
32
|
+
infer _U,
|
|
33
|
+
infer S
|
|
34
|
+
>
|
|
35
|
+
? MediaValue<S>
|
|
36
|
+
: never;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attribute,
|
|
3
|
+
ConfigurableOption,
|
|
4
|
+
DefaultOption,
|
|
5
|
+
MinMaxLengthOption,
|
|
6
|
+
PrivateOption,
|
|
7
|
+
RequiredOption,
|
|
8
|
+
} from './base';
|
|
9
|
+
|
|
10
|
+
export type PasswordAttribute = Attribute<'password'> &
|
|
11
|
+
// Options
|
|
12
|
+
ConfigurableOption &
|
|
13
|
+
DefaultOption<PasswordValue> &
|
|
14
|
+
MinMaxLengthOption &
|
|
15
|
+
PrivateOption &
|
|
16
|
+
RequiredOption;
|
|
17
|
+
|
|
18
|
+
export type PasswordValue = string;
|
|
19
|
+
|
|
20
|
+
export type GetPasswordAttributeValue<T extends Attribute> = T extends PasswordAttribute
|
|
21
|
+
? PasswordValue
|
|
22
|
+
: never;
|