@strapi/strapi 4.11.0 → 4.11.1-beta.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/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 +48 -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
|
@@ -1,22 +1,13 @@
|
|
|
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 Float = Attribute.OfType<'float'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<FloatValue> &
|
|
14
|
-
MinMaxOption &
|
|
15
|
-
PrivateOption &
|
|
16
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<FloatValue> &
|
|
7
|
+
Attribute.MinMaxOption &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption;
|
|
17
10
|
|
|
18
11
|
export type FloatValue = number;
|
|
19
12
|
|
|
20
|
-
export type
|
|
21
|
-
? FloatValue
|
|
22
|
-
: never;
|
|
13
|
+
export type GetFloatValue<T extends Attribute.Attribute> = T extends Float ? FloatValue : 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 Integer = Attribute.OfType<'integer'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<IntegerValue> &
|
|
14
|
-
MinMaxOption &
|
|
15
|
-
PrivateOption &
|
|
16
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<IntegerValue> &
|
|
7
|
+
Attribute.MinMaxOption &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption;
|
|
17
10
|
|
|
18
11
|
export type IntegerValue = number;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetIntegerValue<T extends Attribute.Attribute> = T extends Integer
|
|
21
14
|
? IntegerValue
|
|
22
15
|
: never;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { Attribute
|
|
2
|
-
import { JSON } from './common';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
3
2
|
|
|
4
|
-
export type
|
|
5
|
-
//Options
|
|
6
|
-
ConfigurableOption &
|
|
7
|
-
RequiredOption &
|
|
8
|
-
PrivateOption;
|
|
3
|
+
export type JSON = Attribute.OfType<'json'> &
|
|
4
|
+
// Options
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.RequiredOption &
|
|
7
|
+
Attribute.PrivateOption;
|
|
9
8
|
|
|
10
|
-
export type JsonValue =
|
|
9
|
+
export type JsonValue<T extends object = object> = T;
|
|
11
10
|
|
|
12
|
-
export type
|
|
13
|
-
? JsonValue
|
|
14
|
-
: never;
|
|
11
|
+
export type GetJsonValue<T extends Attribute.Attribute> = T extends JSON ? JsonValue : never;
|
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
import { Attribute,
|
|
2
|
-
import { Media } from './common';
|
|
1
|
+
import type { Attribute, Utils } from '@strapi/strapi';
|
|
3
2
|
|
|
4
|
-
export type
|
|
3
|
+
export type MediaKind = 'images' | 'videos' | 'files' | 'audios';
|
|
5
4
|
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// Multiple
|
|
10
|
-
U extends boolean = false
|
|
5
|
+
export interface MediaProperties<
|
|
6
|
+
TKind extends MediaKind | undefined = undefined,
|
|
7
|
+
TMultiple extends Utils.Expression.BooleanValue = Utils.Expression.False
|
|
11
8
|
> {
|
|
12
|
-
allowedTypes?:
|
|
13
|
-
multiple?:
|
|
9
|
+
allowedTypes?: TKind;
|
|
10
|
+
multiple?: TMultiple;
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
U extends boolean = false
|
|
21
|
-
> = Attribute<'media'> &
|
|
13
|
+
export type Media<
|
|
14
|
+
TKind extends MediaKind | undefined = undefined,
|
|
15
|
+
TMultiple extends Utils.Expression.BooleanValue = Utils.Expression.False
|
|
16
|
+
> = Attribute.OfType<'media'> &
|
|
22
17
|
// Properties
|
|
23
|
-
|
|
18
|
+
MediaProperties<TKind, TMultiple> &
|
|
24
19
|
// Options
|
|
25
|
-
ConfigurableOption &
|
|
26
|
-
RequiredOption &
|
|
27
|
-
PrivateOption;
|
|
20
|
+
Attribute.ConfigurableOption &
|
|
21
|
+
Attribute.RequiredOption &
|
|
22
|
+
Attribute.PrivateOption;
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
// TODO: Introduce a real type for the media values
|
|
25
|
+
export type MediaValue<TMultiple extends Utils.Expression.BooleanValue = Utils.Expression.False> =
|
|
26
|
+
Utils.Expression.If<TMultiple, any[], any>;
|
|
30
27
|
|
|
31
|
-
export type
|
|
32
|
-
|
|
33
|
-
infer
|
|
28
|
+
export type GetMediaValue<TAttribute extends Attribute.Attribute> = TAttribute extends Media<
|
|
29
|
+
// Unused as long as the media value is any
|
|
30
|
+
infer _TKind,
|
|
31
|
+
infer TMultiple
|
|
34
32
|
>
|
|
35
|
-
? MediaValue<
|
|
33
|
+
? MediaValue<TMultiple>
|
|
36
34
|
: never;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
MinMaxLengthOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export type
|
|
3
|
+
export type Password = Attribute.OfType<'password'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<PasswordValue> &
|
|
14
|
-
MinMaxLengthOption &
|
|
15
|
-
PrivateOption &
|
|
16
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<PasswordValue> &
|
|
7
|
+
Attribute.MinMaxLengthOption &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption;
|
|
17
10
|
|
|
18
11
|
export type PasswordValue = string;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetPasswordValue<T extends Attribute.Attribute> = T extends Password
|
|
21
14
|
? PasswordValue
|
|
22
15
|
: never;
|
|
@@ -1,63 +1,111 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Attribute, ConfigurableOption, PrivateOption } from './base';
|
|
3
|
-
import { GetAttributesByType, GetAttributesValues } from './utils';
|
|
4
|
-
|
|
5
|
-
export type BasicRelationsType = 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany';
|
|
6
|
-
export type PolymorphicRelationsType = 'morphToOne' | 'morphToMany' | 'morphOne' | 'morphMany';
|
|
7
|
-
export type RelationsType = BasicRelationsType | PolymorphicRelationsType;
|
|
8
|
-
|
|
9
|
-
export interface BasicRelationAttributeProperties<
|
|
10
|
-
S extends SchemaUID,
|
|
11
|
-
R extends RelationsType,
|
|
12
|
-
T extends SchemaUID
|
|
13
|
-
> {
|
|
14
|
-
relation: R;
|
|
15
|
-
target: T;
|
|
16
|
-
inversedBy?: RelationsKeysFromTo<T, S>;
|
|
17
|
-
mappedBy?: RelationsKeysFromTo<T, S>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface PolymorphicRelationAttributeProperties<R extends RelationsType> {
|
|
21
|
-
relation: R;
|
|
22
|
-
}
|
|
1
|
+
import type { Attribute, Common, Utils } from '@strapi/strapi';
|
|
23
2
|
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
export type Relation<
|
|
4
|
+
// TODO: TOrigin was originally needed to infer precise attribute literal types by doing a reverse lookup
|
|
5
|
+
// on TTarget -> TOrigin relations. Due to errors because of Attribute.Any [relation] very generic
|
|
6
|
+
// representation, type mismatches were encountered and mappedBy/inversedBy are now regular strings.
|
|
7
|
+
// It is kept to allow for future iterations without breaking the current type API
|
|
8
|
+
TOrigin extends Common.UID.Schema = Common.UID.Schema,
|
|
9
|
+
TRelationKind extends RelationKind.Any = RelationKind.Any,
|
|
10
|
+
TTarget extends Common.UID.Schema = never
|
|
11
|
+
> = Attribute.OfType<'relation'> &
|
|
29
12
|
// Properties
|
|
30
|
-
|
|
31
|
-
? BasicRelationAttributeProperties<S, R, T>
|
|
32
|
-
: PolymorphicRelationAttributeProperties<R>) &
|
|
13
|
+
RelationProperties<TOrigin, TRelationKind, TTarget> &
|
|
33
14
|
// Options
|
|
34
|
-
ConfigurableOption &
|
|
35
|
-
PrivateOption;
|
|
15
|
+
Attribute.ConfigurableOption &
|
|
16
|
+
Attribute.PrivateOption;
|
|
17
|
+
|
|
18
|
+
export type RelationProperties<
|
|
19
|
+
_TOrigin extends Common.UID.Schema,
|
|
20
|
+
TRelationKind extends RelationKind.Any,
|
|
21
|
+
TTarget extends Common.UID.Schema
|
|
22
|
+
> = Utils.Expression.MatchFirst<
|
|
23
|
+
[
|
|
24
|
+
Utils.Expression.Test<
|
|
25
|
+
Utils.Expression.Extends<TRelationKind, RelationKind.BiDirectional>,
|
|
26
|
+
{
|
|
27
|
+
relation: TRelationKind;
|
|
28
|
+
target: TTarget;
|
|
29
|
+
inversedBy?: string;
|
|
30
|
+
mappedBy?: string;
|
|
31
|
+
}
|
|
32
|
+
>,
|
|
33
|
+
Utils.Expression.Test<
|
|
34
|
+
Utils.Expression.Extends<TRelationKind, RelationKind.UniDirectional>,
|
|
35
|
+
{ relation: TRelationKind }
|
|
36
|
+
>,
|
|
37
|
+
Utils.Expression.Test<
|
|
38
|
+
Utils.Expression.Extends<TRelationKind, RelationKind.MorphReference>,
|
|
39
|
+
{
|
|
40
|
+
relation: TRelationKind;
|
|
41
|
+
target: TTarget;
|
|
42
|
+
morphBy?: Utils.Guard.Never<
|
|
43
|
+
Attribute.GetKeysByType<TTarget, 'relation', { relation: RelationKind.MorphOwner }>,
|
|
44
|
+
string
|
|
45
|
+
>;
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
]
|
|
49
|
+
>;
|
|
36
50
|
|
|
37
51
|
export type RelationsKeysFromTo<
|
|
38
|
-
TTarget extends
|
|
39
|
-
|
|
40
|
-
> = keyof PickRelationsFromTo<TTarget,
|
|
52
|
+
TTarget extends Common.UID.Schema,
|
|
53
|
+
TOrigin extends Common.UID.Schema
|
|
54
|
+
> = keyof PickRelationsFromTo<TTarget, TOrigin>;
|
|
41
55
|
|
|
42
56
|
export type PickRelationsFromTo<
|
|
43
|
-
TTarget extends
|
|
44
|
-
|
|
45
|
-
> =
|
|
57
|
+
TTarget extends Common.UID.Schema,
|
|
58
|
+
TOrigin extends Common.UID.Schema
|
|
59
|
+
> = Attribute.GetByType<TTarget, 'relation', { target: TOrigin }>;
|
|
46
60
|
|
|
47
61
|
export type RelationPluralityModifier<
|
|
48
|
-
|
|
49
|
-
TValue
|
|
50
|
-
> =
|
|
62
|
+
TRelationKind extends RelationKind.Any,
|
|
63
|
+
TValue
|
|
64
|
+
> = TRelationKind extends Utils.String.Suffix<string, 'Many'> ? TValue[] : TValue;
|
|
51
65
|
|
|
52
66
|
export type RelationValue<
|
|
53
|
-
|
|
54
|
-
TTarget extends
|
|
55
|
-
> = RelationPluralityModifier<
|
|
67
|
+
TRelationKind extends RelationKind.Any,
|
|
68
|
+
TTarget extends Common.UID.Schema
|
|
69
|
+
> = RelationPluralityModifier<TRelationKind, Attribute.GetValues<TTarget>>;
|
|
56
70
|
|
|
57
|
-
export type
|
|
58
|
-
infer
|
|
59
|
-
infer
|
|
71
|
+
export type GetRelationValue<TAttribute extends Attribute.Attribute> = TAttribute extends Relation<
|
|
72
|
+
infer _TOrigin,
|
|
73
|
+
infer TRelationKind,
|
|
60
74
|
infer TTarget
|
|
61
75
|
>
|
|
62
|
-
? RelationValue<
|
|
76
|
+
? RelationValue<TRelationKind, TTarget>
|
|
63
77
|
: never;
|
|
78
|
+
|
|
79
|
+
export module RelationKind {
|
|
80
|
+
type GetOppositePlurality<TPlurality extends RelationKind.Left | RelationKind.Right> = {
|
|
81
|
+
one: 'many';
|
|
82
|
+
One: 'Many';
|
|
83
|
+
many: 'one';
|
|
84
|
+
Many: 'One';
|
|
85
|
+
}[TPlurality];
|
|
86
|
+
|
|
87
|
+
export type Plurality = 'one' | 'many';
|
|
88
|
+
|
|
89
|
+
export type Left = Lowercase<RelationKind.Plurality>;
|
|
90
|
+
export type Right = Capitalize<RelationKind.Plurality>;
|
|
91
|
+
|
|
92
|
+
export type MorphOwner = `morphTo${RelationKind.Right}`;
|
|
93
|
+
export type MorphReference = `morph${RelationKind.Right}`;
|
|
94
|
+
export type Morph = RelationKind.MorphOwner | RelationKind.MorphReference;
|
|
95
|
+
|
|
96
|
+
export type XWay = `${RelationKind.Left}Way`;
|
|
97
|
+
|
|
98
|
+
export type BiDirectional = `${RelationKind.Left}To${RelationKind.Right}`;
|
|
99
|
+
export type UniDirectional = RelationKind.Morph | RelationKind.XWay;
|
|
100
|
+
|
|
101
|
+
export type Any = RelationKind.BiDirectional | RelationKind.UniDirectional;
|
|
102
|
+
|
|
103
|
+
export type Reverse<TRelationKind extends RelationKind.Any> =
|
|
104
|
+
TRelationKind extends `${infer TLeft extends RelationKind.Left}To${infer TRight extends RelationKind.Right}`
|
|
105
|
+
? Utils.Expression.If<
|
|
106
|
+
Utils.Expression.Extends<Uppercase<TLeft>, Uppercase<TRight>>,
|
|
107
|
+
TRelationKind,
|
|
108
|
+
`${GetOppositePlurality<TLeft>}To${GetOppositePlurality<TRight>}`
|
|
109
|
+
>
|
|
110
|
+
: TRelationKind;
|
|
111
|
+
}
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
MinMaxLengthOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
} from './base';
|
|
1
|
+
import type { Attribute } from '@strapi/strapi';
|
|
9
2
|
|
|
10
|
-
export type
|
|
3
|
+
export type RichText = Attribute.OfType<'richtext'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<RichTextValue> &
|
|
14
|
-
MinMaxLengthOption &
|
|
15
|
-
PrivateOption &
|
|
16
|
-
RequiredOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<RichTextValue> &
|
|
7
|
+
Attribute.MinMaxLengthOption &
|
|
8
|
+
Attribute.PrivateOption &
|
|
9
|
+
Attribute.RequiredOption;
|
|
17
10
|
|
|
18
11
|
export type RichTextValue = string;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetRichTextValue<T extends Attribute.Attribute> = T extends RichText
|
|
21
14
|
? RichTextValue
|
|
22
15
|
: never;
|
|
@@ -1,30 +1,20 @@
|
|
|
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 interface
|
|
3
|
+
export interface StringProperties {
|
|
12
4
|
regex?: RegExp;
|
|
13
5
|
}
|
|
14
6
|
|
|
15
|
-
export type
|
|
7
|
+
export type String = Attribute.OfType<'string'> &
|
|
16
8
|
// Properties
|
|
17
|
-
|
|
9
|
+
StringProperties &
|
|
18
10
|
// Options
|
|
19
|
-
ConfigurableOption &
|
|
20
|
-
DefaultOption<StringValue> &
|
|
21
|
-
MinMaxLengthOption &
|
|
22
|
-
PrivateOption &
|
|
23
|
-
UniqueOption &
|
|
24
|
-
RequiredOption;
|
|
11
|
+
Attribute.ConfigurableOption &
|
|
12
|
+
Attribute.DefaultOption<StringValue> &
|
|
13
|
+
Attribute.MinMaxLengthOption &
|
|
14
|
+
Attribute.PrivateOption &
|
|
15
|
+
Attribute.UniqueOption &
|
|
16
|
+
Attribute.RequiredOption;
|
|
25
17
|
|
|
26
18
|
export type StringValue = string;
|
|
27
19
|
|
|
28
|
-
export type
|
|
29
|
-
? StringValue
|
|
30
|
-
: never;
|
|
20
|
+
export type GetStringValue<T extends Attribute.Attribute> = T extends String ? StringValue : never;
|
|
@@ -1,30 +1,20 @@
|
|
|
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 interface
|
|
3
|
+
export interface TextProperties {
|
|
12
4
|
regex?: RegExp;
|
|
13
5
|
}
|
|
14
6
|
|
|
15
|
-
export type
|
|
7
|
+
export type Text = Attribute.OfType<'text'> &
|
|
16
8
|
// Properties
|
|
17
|
-
|
|
9
|
+
TextProperties &
|
|
18
10
|
// Options
|
|
19
|
-
ConfigurableOption &
|
|
20
|
-
DefaultOption<TextValue> &
|
|
21
|
-
MinMaxLengthOption &
|
|
22
|
-
PrivateOption &
|
|
23
|
-
UniqueOption &
|
|
24
|
-
RequiredOption;
|
|
11
|
+
Attribute.ConfigurableOption &
|
|
12
|
+
Attribute.DefaultOption<TextValue> &
|
|
13
|
+
Attribute.MinMaxLengthOption &
|
|
14
|
+
Attribute.PrivateOption &
|
|
15
|
+
Attribute.UniqueOption &
|
|
16
|
+
Attribute.RequiredOption;
|
|
25
17
|
|
|
26
18
|
export type TextValue = string;
|
|
27
19
|
|
|
28
|
-
export type
|
|
29
|
-
? TextValue
|
|
30
|
-
: never;
|
|
20
|
+
export type GetTextValue<T extends Attribute.Attribute> = T extends Text ? TextValue : 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 Time = Attribute.OfType<'time'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<TimeValue> &
|
|
14
|
-
PrivateOption &
|
|
15
|
-
RequiredOption &
|
|
16
|
-
UniqueOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<TimeValue> &
|
|
7
|
+
Attribute.PrivateOption &
|
|
8
|
+
Attribute.RequiredOption &
|
|
9
|
+
Attribute.UniqueOption;
|
|
17
10
|
|
|
18
11
|
export type TimeValue = string;
|
|
19
12
|
|
|
20
|
-
export type
|
|
21
|
-
? TimeValue
|
|
22
|
-
: never;
|
|
13
|
+
export type GetTimeValue<T extends Attribute.Attribute> = T extends Time ? TimeValue : 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 Timestamp = Attribute.OfType<'timestamp'> &
|
|
11
4
|
// Options
|
|
12
|
-
ConfigurableOption &
|
|
13
|
-
DefaultOption<TimestampValue> &
|
|
14
|
-
PrivateOption &
|
|
15
|
-
RequiredOption &
|
|
16
|
-
UniqueOption;
|
|
5
|
+
Attribute.ConfigurableOption &
|
|
6
|
+
Attribute.DefaultOption<TimestampValue> &
|
|
7
|
+
Attribute.PrivateOption &
|
|
8
|
+
Attribute.RequiredOption &
|
|
9
|
+
Attribute.UniqueOption;
|
|
17
10
|
|
|
18
11
|
export type TimestampValue = string;
|
|
19
12
|
|
|
20
|
-
export type
|
|
13
|
+
export type GetTimestampValue<T extends Attribute.Attribute> = T extends Timestamp
|
|
21
14
|
? TimestampValue
|
|
22
15
|
: never;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attribute,
|
|
3
|
-
ConfigurableOption,
|
|
4
|
-
DefaultOption,
|
|
5
|
-
MinMaxLengthOption,
|
|
6
|
-
PrivateOption,
|
|
7
|
-
RequiredOption,
|
|
8
|
-
} from './base';
|
|
9
|
-
import { SchemaUID } from '../../utils';
|
|
10
|
-
import { GetAttributesKeysByType } from './utils';
|
|
1
|
+
import type { Attribute, Common, Utils } from '@strapi/strapi';
|
|
11
2
|
|
|
12
|
-
export interface
|
|
3
|
+
export interface UIDOptions {
|
|
13
4
|
separator?: string;
|
|
14
5
|
lowercase?: boolean;
|
|
15
6
|
decamelize?: boolean;
|
|
@@ -17,41 +8,46 @@ export interface UIDAttributeOptions {
|
|
|
17
8
|
preserveLeadingUnderscore?: boolean;
|
|
18
9
|
}
|
|
19
10
|
|
|
20
|
-
export interface
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
U extends T extends SchemaUID
|
|
25
|
-
? GetAttributesKeysByType<T, 'string' | 'text'>
|
|
26
|
-
: undefined = undefined,
|
|
27
|
-
// UID options
|
|
28
|
-
S extends UIDAttributeOptions = UIDAttributeOptions
|
|
11
|
+
export interface UIDProperties<
|
|
12
|
+
TOrigin extends Common.UID.Schema,
|
|
13
|
+
TTargetAttribute extends AllowedTargetAttributes<TOrigin>,
|
|
14
|
+
TOptions extends UIDOptions = UIDOptions
|
|
29
15
|
> {
|
|
30
|
-
targetField
|
|
31
|
-
options
|
|
16
|
+
targetField: TTargetAttribute;
|
|
17
|
+
options: UIDOptions & TOptions;
|
|
32
18
|
}
|
|
33
19
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
> = Attribute<'uid'> &
|
|
20
|
+
export interface GenericUIDProperties<TOptions extends UIDOptions = UIDOptions> {
|
|
21
|
+
targetField?: string;
|
|
22
|
+
options: TOptions & UIDOptions;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type UID<
|
|
26
|
+
TOrigin extends Common.UID.Schema | undefined = undefined,
|
|
27
|
+
TTargetAttribute extends AllowedTargetAttributes<TOrigin> = AllowedTargetAttributes<TOrigin>,
|
|
28
|
+
TOptions extends UIDOptions = UIDOptions
|
|
29
|
+
> = Attribute.OfType<'uid'> &
|
|
44
30
|
// Properties
|
|
45
|
-
|
|
31
|
+
(TOrigin extends Common.UID.Schema
|
|
32
|
+
? UIDProperties<TOrigin, TTargetAttribute, TOptions>
|
|
33
|
+
: GenericUIDProperties<TOptions>) &
|
|
46
34
|
// Options
|
|
47
|
-
ConfigurableOption &
|
|
48
|
-
DefaultOption<UIDValue> &
|
|
49
|
-
MinMaxLengthOption &
|
|
50
|
-
PrivateOption &
|
|
51
|
-
RequiredOption;
|
|
35
|
+
Attribute.ConfigurableOption &
|
|
36
|
+
Attribute.DefaultOption<UIDValue> &
|
|
37
|
+
Attribute.MinMaxLengthOption &
|
|
38
|
+
Attribute.PrivateOption &
|
|
39
|
+
Attribute.RequiredOption;
|
|
40
|
+
|
|
41
|
+
type AllowedTargetAttributes<TOrigin extends Common.UID.Schema | undefined> =
|
|
42
|
+
TOrigin extends Common.UID.Schema
|
|
43
|
+
? Utils.Guard.Never<Attribute.GetKeysByType<TOrigin, 'string' | 'text'>, string>
|
|
44
|
+
: never;
|
|
52
45
|
|
|
53
46
|
export type UIDValue = string;
|
|
54
47
|
|
|
55
|
-
export type
|
|
48
|
+
export type GetUIDValue<TAttribute extends Attribute.Attribute> = TAttribute extends UID<
|
|
49
|
+
infer _TOrigin,
|
|
50
|
+
infer _TTargetAttribute
|
|
51
|
+
>
|
|
56
52
|
? UIDValue
|
|
57
53
|
: never;
|