@strapi/strapi 4.11.0 → 4.11.1-beta.1
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/develop/action.js +5 -6
- package/lib/commands/actions/ts/generate-types/action.js +12 -9
- package/lib/commands/actions/ts/generate-types/command.js +4 -4
- package/lib/factories.d.ts +21 -0
- package/lib/global.d.ts +0 -44
- package/lib/index.d.ts +2 -1
- package/lib/types/core/attributes/base.d.ts +8 -5
- package/lib/types/core/attributes/biginteger.d.ts +8 -15
- package/lib/types/core/attributes/boolean.d.ts +7 -13
- package/lib/types/core/attributes/common.d.ts +46 -20
- package/lib/types/core/attributes/component.d.ts +24 -29
- package/lib/types/core/attributes/date-time.d.ts +8 -15
- package/lib/types/core/attributes/date.d.ts +8 -17
- package/lib/types/core/attributes/decimal.d.ts +8 -15
- package/lib/types/core/attributes/dynamic-zone.d.ts +18 -21
- package/lib/types/core/attributes/email.d.ts +9 -19
- package/lib/types/core/attributes/enumeration.d.ts +12 -22
- package/lib/types/core/attributes/float.d.ts +8 -17
- package/lib/types/core/attributes/integer.d.ts +8 -15
- package/lib/types/core/attributes/json.d.ts +8 -11
- package/lib/types/core/attributes/media.d.ts +23 -25
- package/lib/types/core/attributes/password.d.ts +8 -15
- package/lib/types/core/attributes/relation.d.ts +96 -48
- package/lib/types/core/attributes/richtext.d.ts +8 -15
- package/lib/types/core/attributes/string.d.ts +11 -21
- package/lib/types/core/attributes/text.d.ts +11 -21
- package/lib/types/core/attributes/time.d.ts +8 -17
- package/lib/types/core/attributes/timestamp.d.ts +8 -15
- package/lib/types/core/attributes/uid.d.ts +35 -39
- package/lib/types/core/attributes/utils.d.ts +69 -79
- package/lib/types/core/common/controller.d.ts +8 -0
- package/lib/types/core/common/index.d.ts +4 -0
- package/lib/types/core/common/schema.d.ts +3 -0
- package/lib/types/core/common/service.d.ts +3 -0
- package/lib/types/core/common/uid.d.ts +62 -0
- package/lib/types/core/index.d.ts +7 -2
- package/lib/types/core/namespace.d.ts +99 -0
- package/lib/types/core/registry.d.ts +68 -0
- package/lib/types/core/schemas/index.d.ts +16 -15
- package/lib/types/core/strapi/index.d.ts +6 -10
- package/lib/types/core/uid.d.ts +167 -0
- package/lib/types/core-api/controller.d.ts +52 -0
- package/lib/types/core-api/index.d.ts +3 -0
- package/lib/types/core-api/router.d.ts +65 -0
- package/lib/types/core-api/service.d.ts +50 -0
- package/lib/types/index.d.ts +4 -2
- package/lib/types/shared/index.d.ts +1 -0
- package/lib/types/shared/registries.d.ts +45 -0
- package/lib/types/utils/array.d.ts +25 -0
- package/lib/types/utils/expression.d.ts +68 -0
- package/lib/types/utils/guard.d.ts +14 -0
- package/lib/types/utils/index.d.ts +19 -0
- package/lib/types/utils/object.d.ts +29 -0
- package/lib/types/utils/string.d.ts +41 -0
- package/lib/types/utils/tuple.d.ts +13 -0
- package/package.json +16 -16
- package/lib/core/registries/services.d.ts +0 -7
- package/lib/core-api/controller/index.d.ts +0 -27
- package/lib/core-api/service/index.d.ts +0 -25
- package/lib/types/factories.d.ts +0 -60
- package/lib/types/utils.d.ts +0 -95
|
@@ -121,13 +121,12 @@ const workerProcess = async ({ appDir, distDir, watchAdmin, polling, isTSProject
|
|
|
121
121
|
const shouldGenerateTypeScriptTypes = strapiInstance.config.get('typescript.autogenerate', false);
|
|
122
122
|
|
|
123
123
|
if (shouldGenerateTypeScriptTypes) {
|
|
124
|
-
|
|
125
|
-
// NOTE: We should probably add some configuration options to manage the file structure output or the verbosity level
|
|
126
|
-
tsUtils.generators.generateSchemasDefinitions({
|
|
124
|
+
await tsUtils.generators.generate({
|
|
127
125
|
strapi: strapiInstance,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
silent: true,
|
|
126
|
+
pwd: appDir,
|
|
127
|
+
rootDir: undefined,
|
|
128
|
+
logger: { silent: true, debug: false },
|
|
129
|
+
artifacts: { contentTypes: true, components: true },
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
132
|
|
|
@@ -4,22 +4,25 @@ const tsUtils = require('@strapi/typescript-utils');
|
|
|
4
4
|
|
|
5
5
|
const strapi = require('../../../../index');
|
|
6
6
|
|
|
7
|
-
module.exports = async ({
|
|
8
|
-
if (verbose && silent) {
|
|
9
|
-
console.error('
|
|
7
|
+
module.exports = async ({ debug, silent, verbose, outDir }) => {
|
|
8
|
+
if ((debug || verbose) && silent) {
|
|
9
|
+
console.error('Flags conflict: both silent and debug mode are enabled, exiting...');
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const appContext = await strapi.compile();
|
|
14
14
|
const app = await strapi(appContext).register();
|
|
15
15
|
|
|
16
|
-
await tsUtils.generators.
|
|
16
|
+
await tsUtils.generators.generate({
|
|
17
17
|
strapi: app,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
pwd: appContext.appDir,
|
|
19
|
+
rootDir: outDir ?? undefined,
|
|
20
|
+
logger: {
|
|
21
|
+
silent,
|
|
22
|
+
// TODO V5: verbose is deprecated and should be removed
|
|
23
|
+
debug: debug || verbose,
|
|
24
|
+
},
|
|
25
|
+
artifacts: { contentTypes: true, components: true },
|
|
23
26
|
});
|
|
24
27
|
|
|
25
28
|
app.destroy();
|
|
@@ -10,12 +10,12 @@ module.exports = ({ command }) => {
|
|
|
10
10
|
command
|
|
11
11
|
.command('ts:generate-types')
|
|
12
12
|
.description(`Generate TypeScript typings for your schemas`)
|
|
13
|
+
.option('--verbose', `[DEPRECATED] The verbose option has been replaced by debug`, false)
|
|
14
|
+
.option('-d, --debug', `Run the generation with debug messages`, false)
|
|
15
|
+
.option('-s, --silent', `Run the generation silently, without any output`, false)
|
|
13
16
|
.option(
|
|
14
17
|
'-o, --out-dir <outDir>',
|
|
15
|
-
'Specify a relative directory in which the
|
|
18
|
+
'Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types.'
|
|
16
19
|
)
|
|
17
|
-
.option('-f, --file <file>', 'Specify a filename to store the schemas definitions')
|
|
18
|
-
.option('--verbose', `Display more information about the types generation`, false)
|
|
19
|
-
.option('-s, --silent', `Run the generation silently, without any output`, false)
|
|
20
20
|
.action(getLocalScript('ts/generate-types'));
|
|
21
21
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Common, CoreApi, Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
type WithStrapiCallback<T> = <S extends { strapi: Strapi }>(params: S) => T;
|
|
4
|
+
|
|
5
|
+
export declare function createCoreRouter<T extends Common.UID.ContentType>(
|
|
6
|
+
uid: T,
|
|
7
|
+
cfg?: CoreApi.Router.RouterConfig<T>
|
|
8
|
+
): () => CoreApi.Router.Router;
|
|
9
|
+
|
|
10
|
+
export declare function createCoreController<
|
|
11
|
+
T extends Common.UID.ContentType,
|
|
12
|
+
S extends Partial<CoreApi.Controller.Extendable<T>>
|
|
13
|
+
>(
|
|
14
|
+
uid: T,
|
|
15
|
+
config?: WithStrapiCallback<S> | S
|
|
16
|
+
): () => Required<S & CoreApi.Controller.ContentType<T>>;
|
|
17
|
+
|
|
18
|
+
export declare function createCoreService<
|
|
19
|
+
T extends Common.UID.ContentType,
|
|
20
|
+
S extends Partial<CoreApi.Service.Extendable<T>>
|
|
21
|
+
>(uid: T, config?: WithStrapiCallback<S> | S): () => Required<S & CoreApi.Service.ContentType<T>>;
|
package/lib/global.d.ts
CHANGED
|
@@ -1,51 +1,7 @@
|
|
|
1
1
|
import type { Strapi as StrapiInterface } from './types/core';
|
|
2
|
-
import type {
|
|
3
|
-
CollectionTypeSchema,
|
|
4
|
-
SingleTypeSchema,
|
|
5
|
-
ComponentSchema,
|
|
6
|
-
ContentTypeSchema,
|
|
7
|
-
} from './types/core/schemas';
|
|
8
|
-
import type { KeysBy } from './types/utils';
|
|
9
2
|
|
|
10
3
|
declare global {
|
|
11
4
|
namespace Strapi {
|
|
12
|
-
/**
|
|
13
|
-
* Map of UID / schemas used as a schemas database for other types.
|
|
14
|
-
* It must be extended by the user application or plugins.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* declare global {
|
|
19
|
-
* namespace Strapi {
|
|
20
|
-
* interface Schemas {
|
|
21
|
-
* 'xxx::xxx.uid: ContentTypeSchema | ComponentSchema;
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
interface Schemas {}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Literal union type of every content type registered in Strapi.Schemas
|
|
31
|
-
*/
|
|
32
|
-
type ContentTypeUIDs = KeysBy<Schemas, ContentTypeSchema>;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Literal union type of every collection type registered in Strapi.Schemas
|
|
36
|
-
*/
|
|
37
|
-
type CollectionTypeUIDs = KeysBy<Schemas, CollectionTypeSchema>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Literal union type of every single type registered in Strapi.Schemas
|
|
41
|
-
*/
|
|
42
|
-
type SingleTypeUIDs = KeysBy<Schemas, SingleTypeSchema>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Literal union type of every component registered in Strapi.Schemas
|
|
46
|
-
*/
|
|
47
|
-
type ComponentUIDs = KeysBy<Schemas, ComponentSchema>;
|
|
48
|
-
|
|
49
5
|
/**
|
|
50
6
|
* Global shorthand to access the `StrapiInterface` type
|
|
51
7
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { GetAttributeValue } from './utils';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* List of all the Strapi attribute types
|
|
5
3
|
*/
|
|
6
|
-
export type
|
|
4
|
+
export type Kind =
|
|
7
5
|
| 'string'
|
|
8
6
|
| 'text'
|
|
9
7
|
| 'richtext'
|
|
@@ -29,11 +27,11 @@ export type AttributeType =
|
|
|
29
27
|
/**
|
|
30
28
|
* Most basic shape of a schema attribute
|
|
31
29
|
*/
|
|
32
|
-
export interface Attribute<
|
|
30
|
+
export interface Attribute<TKind extends Kind = Kind> {
|
|
33
31
|
/**
|
|
34
32
|
* Type of the attribute
|
|
35
33
|
*/
|
|
36
|
-
type:
|
|
34
|
+
type: TKind;
|
|
37
35
|
|
|
38
36
|
/**
|
|
39
37
|
* Options defined and used by the plugins
|
|
@@ -41,6 +39,11 @@ export interface Attribute<T extends AttributeType = AttributeType> {
|
|
|
41
39
|
pluginOptions?: object;
|
|
42
40
|
}
|
|
43
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Creates a basic Attribute of type T
|
|
44
|
+
*/
|
|
45
|
+
export type OfType<T extends Kind> = Attribute<T>;
|
|
46
|
+
|
|
44
47
|
// Common attributes Options
|
|
45
48
|
|
|
46
49
|
export interface RequiredOption {
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
MinMaxOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export type
|
|
3
|
+
export type BigInteger = Attribute.OfType<'biginteger'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<BigIntegerValue> &
|
|
14
|
-
MinMaxOption<string> &
|
|
15
|
-
PrivateOption &
|
|
16
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<BigIntegerValue> &
|
|
7
|
+
Attribute.MinMaxOption<string> &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption;
|
|
17
10
|
|
|
18
11
|
export type BigIntegerValue = string;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetBigIntegerValue<T extends Attribute.Attribute> = T extends BigInteger
|
|
21
14
|
? BigIntegerValue
|
|
22
15
|
: never;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
PrivateOption,
|
|
6
|
-
RequiredOption,
|
|
7
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
8
2
|
|
|
9
|
-
export type
|
|
3
|
+
export type Boolean = Attribute.OfType<'boolean'> &
|
|
10
4
|
// Options
|
|
11
|
-
ConfigurableOption &
|
|
12
|
-
DefaultOption<BooleanValue> &
|
|
13
|
-
PrivateOption &
|
|
14
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<BooleanValue> &
|
|
7
|
+
Attribute.PrivateOption &
|
|
8
|
+
Attribute.RequiredOption;
|
|
15
9
|
|
|
16
10
|
export type BooleanValue = boolean;
|
|
17
11
|
|
|
18
|
-
export type
|
|
12
|
+
export type GetBooleanValue<T extends Attribute.Attribute> = T extends Boolean
|
|
19
13
|
? BooleanValue
|
|
20
14
|
: never;
|
|
@@ -2,47 +2,73 @@
|
|
|
2
2
|
* Strapi custom scalar types
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { StringAttribute } from './string';
|
|
7
|
-
|
|
8
|
-
export type JSON<T extends object = object> = T;
|
|
9
|
-
|
|
10
|
-
export type Media = any;
|
|
5
|
+
import { Attribute, Common } from '@strapi/strapi';
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Setters for the attributes options
|
|
14
9
|
*/
|
|
15
10
|
|
|
16
11
|
// required
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
12
|
+
export type Required = { required: true };
|
|
13
|
+
export type NonRequired = { required: false };
|
|
19
14
|
|
|
20
15
|
// private
|
|
21
|
-
export type
|
|
22
|
-
export type
|
|
16
|
+
export type Private = { private: true };
|
|
17
|
+
export type NonPrivate = { private: false };
|
|
23
18
|
|
|
24
19
|
// unique
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
20
|
+
export type Unique = { unique: true };
|
|
21
|
+
export type NonUnique = { unique: false };
|
|
27
22
|
|
|
28
23
|
// configurable
|
|
29
|
-
export type
|
|
30
|
-
export type
|
|
24
|
+
export type Configurable = { configurable: true };
|
|
25
|
+
export type NonConfigurable = { configurable: false };
|
|
31
26
|
|
|
32
27
|
// custom field
|
|
33
|
-
export type CustomField<
|
|
34
|
-
customField:
|
|
35
|
-
options?:
|
|
28
|
+
export type CustomField<TKind extends string, TOptions extends object | undefined = undefined> = {
|
|
29
|
+
customField: TKind;
|
|
30
|
+
options?: TOptions;
|
|
36
31
|
};
|
|
37
32
|
|
|
38
33
|
// min/max
|
|
39
|
-
export type SetMinMax<
|
|
34
|
+
export type SetMinMax<TConfig extends Attribute.MinMaxOption<TType>, TType = number> = TConfig;
|
|
40
35
|
|
|
41
36
|
// minLength/maxLength
|
|
42
|
-
export type SetMinMaxLength<
|
|
37
|
+
export type SetMinMaxLength<TConfig extends Attribute.MinMaxLengthOption> = TConfig;
|
|
43
38
|
|
|
44
39
|
// pluginOptions
|
|
45
|
-
export type SetPluginOptions<
|
|
40
|
+
export type SetPluginOptions<TConfig extends object = object> = { pluginOptions?: TConfig };
|
|
46
41
|
|
|
47
42
|
// default
|
|
48
43
|
export type DefaultTo<T> = { default: T };
|
|
44
|
+
|
|
45
|
+
// Any Attribute
|
|
46
|
+
export type Any =
|
|
47
|
+
| Attribute.BigInteger
|
|
48
|
+
| Attribute.Boolean
|
|
49
|
+
| Attribute.Component<Common.UID.Component, boolean>
|
|
50
|
+
| Attribute.DateTime
|
|
51
|
+
| Attribute.Date
|
|
52
|
+
| Attribute.Decimal
|
|
53
|
+
| Attribute.DynamicZone
|
|
54
|
+
| Attribute.Email
|
|
55
|
+
| Attribute.Enumeration<string[]>
|
|
56
|
+
| Attribute.Float
|
|
57
|
+
| Attribute.Integer
|
|
58
|
+
| Attribute.JSON
|
|
59
|
+
| Attribute.Media<Attribute.MediaKind | undefined, boolean>
|
|
60
|
+
| Attribute.Password
|
|
61
|
+
| (
|
|
62
|
+
| Attribute.Relation<
|
|
63
|
+
Common.UID.Schema,
|
|
64
|
+
Attribute.RelationKind.BiDirectional,
|
|
65
|
+
Common.UID.Schema
|
|
66
|
+
>
|
|
67
|
+
| Attribute.Relation<Common.UID.Schema, Attribute.RelationKind.UniDirectional>
|
|
68
|
+
)
|
|
69
|
+
| Attribute.RichText
|
|
70
|
+
| Attribute.String
|
|
71
|
+
| Attribute.Text
|
|
72
|
+
| Attribute.Time
|
|
73
|
+
| Attribute.Timestamp
|
|
74
|
+
| Attribute.UID<Common.UID.Schema | undefined>;
|
|
@@ -1,38 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GetAttributesValues } from './utils';
|
|
1
|
+
import type { Common, Attribute, Utils } from '@strapi/strapi';
|
|
3
2
|
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Repeatable
|
|
8
|
-
R extends boolean = false
|
|
3
|
+
export interface ComponentProperties<
|
|
4
|
+
TComponentUID extends Common.UID.Component,
|
|
5
|
+
TRepeatable extends Utils.Expression.BooleanValue = Utils.Expression.False
|
|
9
6
|
> {
|
|
10
|
-
component:
|
|
11
|
-
repeatable?:
|
|
7
|
+
component: TComponentUID;
|
|
8
|
+
repeatable?: TRepeatable;
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
R extends boolean = false
|
|
19
|
-
> = Attribute<'component'> &
|
|
11
|
+
export type Component<
|
|
12
|
+
TComponentUID extends Common.UID.Component = Common.UID.Component,
|
|
13
|
+
TRepeatable extends Utils.Expression.BooleanValue = Utils.Expression.False
|
|
14
|
+
> = Attribute.OfType<'component'> &
|
|
20
15
|
// Component Properties
|
|
21
|
-
|
|
16
|
+
ComponentProperties<TComponentUID, TRepeatable> &
|
|
22
17
|
// Options
|
|
23
|
-
ConfigurableOption &
|
|
24
|
-
MinMaxOption &
|
|
25
|
-
PrivateOption &
|
|
26
|
-
RequiredOption;
|
|
18
|
+
Attribute.ConfigurableOption &
|
|
19
|
+
Attribute.MinMaxOption &
|
|
20
|
+
Attribute.PrivateOption &
|
|
21
|
+
Attribute.RequiredOption;
|
|
27
22
|
|
|
28
23
|
export type ComponentValue<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
> =
|
|
32
|
-
|
|
33
|
-
export type GetComponentAttributeValue<T extends Attribute> = T extends ComponentAttribute<
|
|
34
|
-
infer U,
|
|
35
|
-
infer R
|
|
36
|
-
>
|
|
37
|
-
? ComponentValue<U, R>
|
|
24
|
+
TComponentUID extends Common.UID.Component,
|
|
25
|
+
TRepeatable extends Utils.Expression.BooleanValue
|
|
26
|
+
> = Attribute.GetValues<TComponentUID> extends infer TValues
|
|
27
|
+
? Utils.Expression.If<TRepeatable, TValues[], TValues>
|
|
38
28
|
: never;
|
|
29
|
+
|
|
30
|
+
export type GetComponentValue<TAttribute extends Attribute.Attribute> =
|
|
31
|
+
TAttribute extends Component<infer TComponentUID, infer TRepeatable>
|
|
32
|
+
? ComponentValue<TComponentUID, TRepeatable>
|
|
33
|
+
: never;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
PrivateOption,
|
|
6
|
-
RequiredOption,
|
|
7
|
-
UniqueOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export type
|
|
3
|
+
export type DateTime = Attribute.OfType<'datetime'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<DateTimeValue> &
|
|
14
|
-
PrivateOption &
|
|
15
|
-
RequiredOption &
|
|
16
|
-
UniqueOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<DateTimeValue> &
|
|
7
|
+
Attribute.PrivateOption &
|
|
8
|
+
Attribute.RequiredOption &
|
|
9
|
+
Attribute.UniqueOption;
|
|
17
10
|
|
|
18
11
|
export type DateTimeValue = string;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetDateTimeValue<T extends Attribute.Attribute> = T extends DateTime
|
|
21
14
|
? DateTimeValue
|
|
22
15
|
: never;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
PrivateOption,
|
|
6
|
-
RequiredOption,
|
|
7
|
-
UniqueOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export type
|
|
3
|
+
export type Date = Attribute.OfType<'date'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<DateValue> &
|
|
14
|
-
PrivateOption &
|
|
15
|
-
RequiredOption &
|
|
16
|
-
UniqueOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<DateValue> &
|
|
7
|
+
Attribute.PrivateOption &
|
|
8
|
+
Attribute.RequiredOption &
|
|
9
|
+
Attribute.UniqueOption;
|
|
17
10
|
|
|
18
11
|
export type DateValue = Date;
|
|
19
12
|
|
|
20
|
-
export type
|
|
21
|
-
? DateValue
|
|
22
|
-
: never;
|
|
13
|
+
export type GetDateValue<T extends Attribute.Attribute> = T extends Date ? DateValue : never;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
MinMaxOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export type
|
|
3
|
+
export type Decimal = Attribute.OfType<'decimal'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<DecimalValue> &
|
|
14
|
-
MinMaxOption &
|
|
15
|
-
PrivateOption &
|
|
16
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<DecimalValue> &
|
|
7
|
+
Attribute.MinMaxOption &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption;
|
|
17
10
|
|
|
18
11
|
export type DecimalValue = number;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetDecimalValue<T extends Attribute.Attribute> = T extends Decimal
|
|
21
14
|
? DecimalValue
|
|
22
15
|
: never;
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Attribute, ConfigurableOption, MinMaxOption, RequiredOption } from './base';
|
|
3
|
-
import { GetAttributesValues } from './utils';
|
|
1
|
+
import type { Utils, Attribute, Common } from '@strapi/strapi';
|
|
4
2
|
|
|
5
|
-
export interface
|
|
6
|
-
components:
|
|
3
|
+
export interface DynamicZoneProperties<TComponentsUIDs extends Common.UID.Component[]> {
|
|
4
|
+
components: TComponentsUIDs;
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
export type DynamicZone<TComponentsUIDs extends Common.UID.Component[] = Common.UID.Component[]> =
|
|
8
|
+
Attribute.OfType<'dynamiczone'> &
|
|
9
|
+
// Properties
|
|
10
|
+
DynamicZoneProperties<TComponentsUIDs> &
|
|
11
|
+
// Options
|
|
12
|
+
Attribute.ConfigurableOption &
|
|
13
|
+
Attribute.MinMaxOption &
|
|
14
|
+
Attribute.RequiredOption;
|
|
16
15
|
|
|
17
|
-
type DynamicZoneValue<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
type DynamicZoneValue<TComponentsUIDs extends Common.UID.Component[]> = Array<
|
|
17
|
+
// Extract tuple values to a component uid union type
|
|
18
|
+
Utils.Array.Values<TComponentsUIDs> extends infer TComponentUID
|
|
19
|
+
? TComponentUID extends Common.UID.Component
|
|
20
|
+
? Attribute.GetValues<TComponentUID> & { __component: TComponentUID }
|
|
21
21
|
: never
|
|
22
22
|
: never
|
|
23
23
|
>;
|
|
24
24
|
|
|
25
|
-
export type
|
|
26
|
-
infer
|
|
27
|
-
>
|
|
28
|
-
? DynamicZoneValue<U>
|
|
29
|
-
: never;
|
|
25
|
+
export type GetDynamicZoneValue<TAttribute extends Attribute.Attribute> =
|
|
26
|
+
TAttribute extends DynamicZone<infer TComponentsUIDs> ? DynamicZoneValue<TComponentsUIDs> : never;
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
MinMaxLengthOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
UniqueOption,
|
|
9
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
10
2
|
|
|
11
|
-
export type
|
|
3
|
+
export type Email = Attribute.OfType<'email'> &
|
|
12
4
|
// Options
|
|
13
|
-
ConfigurableOption &
|
|
14
|
-
DefaultOption<EmailValue> &
|
|
15
|
-
MinMaxLengthOption &
|
|
16
|
-
PrivateOption &
|
|
17
|
-
RequiredOption &
|
|
18
|
-
UniqueOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<EmailValue> &
|
|
7
|
+
Attribute.MinMaxLengthOption &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption &
|
|
10
|
+
Attribute.UniqueOption;
|
|
19
11
|
|
|
20
12
|
export type EmailValue = string;
|
|
21
13
|
|
|
22
|
-
export type
|
|
23
|
-
? EmailValue
|
|
24
|
-
: never;
|
|
14
|
+
export type GetEmailValue<T extends Attribute.Attribute> = T extends Email ? EmailValue : never;
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
Attribute,
|
|
4
|
-
ConfigurableOption,
|
|
5
|
-
DefaultOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute, Utils } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export interface
|
|
11
|
-
enum:
|
|
3
|
+
export interface EnumerationProperties<TValues extends string[] = []> {
|
|
4
|
+
enum: TValues;
|
|
12
5
|
}
|
|
13
6
|
|
|
14
|
-
export type
|
|
15
|
-
|
|
7
|
+
export type Enumeration<TValues extends string[] = []> = Attribute.OfType<'enumeration'> &
|
|
8
|
+
EnumerationProperties<TValues> &
|
|
16
9
|
// Options
|
|
17
|
-
ConfigurableOption &
|
|
18
|
-
DefaultOption<
|
|
19
|
-
PrivateOption &
|
|
20
|
-
RequiredOption;
|
|
10
|
+
Attribute.ConfigurableOption &
|
|
11
|
+
Attribute.DefaultOption<TValues> &
|
|
12
|
+
Attribute.PrivateOption &
|
|
13
|
+
Attribute.RequiredOption;
|
|
21
14
|
|
|
22
|
-
export type EnumerationValue<
|
|
15
|
+
export type EnumerationValue<TValues extends string[]> = Utils.Array.Values<TValues>;
|
|
23
16
|
|
|
24
|
-
export type
|
|
25
|
-
infer
|
|
26
|
-
>
|
|
27
|
-
? EnumerationValue<U>
|
|
28
|
-
: never;
|
|
17
|
+
export type GetEnumerationValue<TAttribute extends Attribute.Attribute> =
|
|
18
|
+
TAttribute extends Enumeration<infer TValues> ? EnumerationValue<TValues> : never;
|