@strapi/strapi 4.11.0-exp.push-transfer-push-stuck → 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/core/domain/content-type/index.js +1 -7
- package/lib/factories.d.ts +21 -0
- package/lib/global.d.ts +0 -44
- package/lib/index.d.ts +2 -1
- package/lib/services/entity-service/index.d.ts +1 -3
- package/lib/services/entity-service/index.js +60 -20
- package/lib/services/webhook-store.js +32 -4
- 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 +7 -11
- 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 +17 -17
- 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,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;
|
|
@@ -1,98 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
Attribute,
|
|
4
|
-
AttributeType,
|
|
5
|
-
GetBigIntegerAttributeValue,
|
|
6
|
-
GetBooleanAttributeValue,
|
|
7
|
-
GetDecimalAttributeValue,
|
|
8
|
-
GetDynamicZoneAttributeValue,
|
|
9
|
-
GetEnumerationAttributeValue,
|
|
10
|
-
GetFloatAttributeValue,
|
|
11
|
-
GetIntegerAttributeValue,
|
|
12
|
-
GetJsonAttributeValue,
|
|
13
|
-
GetMediaAttributeValue,
|
|
14
|
-
GetPasswordAttributeValue,
|
|
15
|
-
GetRelationAttributeValue,
|
|
16
|
-
GetRichTextAttributeValue,
|
|
17
|
-
GetStringAttributeValue,
|
|
18
|
-
GetTextAttributeValue,
|
|
19
|
-
GetUIDAttributeValue,
|
|
20
|
-
GetComponentAttributeValue,
|
|
21
|
-
GetEmailAttributeValue,
|
|
22
|
-
} from '.';
|
|
23
|
-
import { GetDateAttributeValue } from './date';
|
|
24
|
-
import { GetDateTimeAttributeValue } from './date-time';
|
|
25
|
-
import { GetTimeAttributeValue } from './time';
|
|
26
|
-
import { GetTimestampAttributeValue } from './timestamp';
|
|
1
|
+
import type { Attribute, Common, Utils } from '@strapi/strapi';
|
|
27
2
|
|
|
28
|
-
export type
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
3
|
+
export type GetKeysByType<
|
|
4
|
+
TSchemaUID extends Common.UID.Schema,
|
|
5
|
+
TKind extends Attribute.Kind,
|
|
6
|
+
TCondition = never
|
|
7
|
+
> = Utils.Object.KeysBy<
|
|
8
|
+
GetAll<TSchemaUID>,
|
|
9
|
+
Attribute.OfType<TKind> & Utils.Guard.Never<TCondition, unknown>
|
|
10
|
+
>;
|
|
35
11
|
|
|
36
|
-
export type
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
export type GetByType<
|
|
13
|
+
TSchemaUID extends Common.UID.Schema,
|
|
14
|
+
TKind extends Attribute.Kind,
|
|
15
|
+
TCondition = never
|
|
16
|
+
> = Utils.Object.PickBy<
|
|
17
|
+
GetAll<TSchemaUID>,
|
|
18
|
+
Attribute.OfType<TKind> & Utils.Guard.Never<TCondition, unknown>
|
|
39
19
|
>;
|
|
40
20
|
|
|
41
|
-
export type
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
export type Get<TSchemaUID extends Common.UID.Schema, TKey extends GetKeys<TSchemaUID>> = Utils.Get<
|
|
22
|
+
GetAll<TSchemaUID>,
|
|
23
|
+
TKey
|
|
44
24
|
>;
|
|
45
25
|
|
|
46
|
-
export type
|
|
26
|
+
export type GetAll<TSchemaUID extends Common.UID.Schema> = Utils.Get<
|
|
27
|
+
Common.Schemas[TSchemaUID],
|
|
28
|
+
'attributes'
|
|
29
|
+
>;
|
|
47
30
|
|
|
48
|
-
export type
|
|
31
|
+
export type GetKeys<TSchemaUID extends Common.UID.Schema> = keyof GetAll<TSchemaUID>;
|
|
49
32
|
|
|
50
|
-
export type
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
| GetTimestampAttributeValue<T>;
|
|
33
|
+
export type GetValue<TAttribute extends Attribute.Attribute> =
|
|
34
|
+
| Attribute.GetBigIntegerValue<TAttribute>
|
|
35
|
+
| Attribute.GetBooleanValue<TAttribute>
|
|
36
|
+
| Attribute.GetComponentValue<TAttribute>
|
|
37
|
+
| Attribute.GetDecimalValue<TAttribute>
|
|
38
|
+
| Attribute.GetDynamicZoneValue<TAttribute>
|
|
39
|
+
| Attribute.GetEnumerationValue<TAttribute>
|
|
40
|
+
| Attribute.GetEmailValue<TAttribute>
|
|
41
|
+
| Attribute.GetFloatValue<TAttribute>
|
|
42
|
+
| Attribute.GetIntegerValue<TAttribute>
|
|
43
|
+
| Attribute.GetJsonValue<TAttribute>
|
|
44
|
+
| Attribute.GetMediaValue<TAttribute>
|
|
45
|
+
| Attribute.GetPasswordValue<TAttribute>
|
|
46
|
+
| Attribute.GetRelationValue<TAttribute>
|
|
47
|
+
| Attribute.GetRichTextValue<TAttribute>
|
|
48
|
+
| Attribute.GetStringValue<TAttribute>
|
|
49
|
+
| Attribute.GetTextValue<TAttribute>
|
|
50
|
+
| Attribute.GetUIDValue<TAttribute>
|
|
51
|
+
| Attribute.GetDateValue<TAttribute>
|
|
52
|
+
| Attribute.GetDateTimeValue<TAttribute>
|
|
53
|
+
| Attribute.GetTimeValue<TAttribute>
|
|
54
|
+
| Attribute.GetTimestampValue<TAttribute>;
|
|
73
55
|
|
|
74
|
-
export type
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
> =
|
|
78
|
-
?
|
|
79
|
-
? GetAttributeValue<P>
|
|
80
|
-
: never
|
|
56
|
+
export type GetValueByKey<
|
|
57
|
+
TSchemaUID extends Common.UID.Schema,
|
|
58
|
+
TKey extends GetKeys<TSchemaUID>
|
|
59
|
+
> = Get<TSchemaUID, TKey> extends infer TAttribute extends Attribute.Attribute
|
|
60
|
+
? GetValue<TAttribute>
|
|
81
61
|
: never;
|
|
82
62
|
|
|
83
|
-
export type
|
|
63
|
+
export type GetValues<
|
|
64
|
+
TSchemaUID extends Common.UID.Schema,
|
|
65
|
+
TKey extends GetKeys<TSchemaUID> = GetKeys<TSchemaUID>
|
|
66
|
+
> = {
|
|
84
67
|
// Handle required attributes
|
|
85
|
-
[key in
|
|
68
|
+
[key in GetRequiredKeys<TSchemaUID> as key extends TKey ? key : never]-?: GetValueByKey<
|
|
69
|
+
TSchemaUID,
|
|
70
|
+
key
|
|
71
|
+
>;
|
|
86
72
|
} & {
|
|
87
73
|
// Handle optional attributes
|
|
88
|
-
[key in
|
|
74
|
+
[key in GetOptionalKeys<TSchemaUID> as key extends TKey ? key : never]?: GetValueByKey<
|
|
75
|
+
TSchemaUID,
|
|
76
|
+
key
|
|
77
|
+
>;
|
|
89
78
|
};
|
|
90
79
|
|
|
91
|
-
export type
|
|
92
|
-
|
|
80
|
+
export type GetRequiredKeys<TSchemaUID extends Common.UID.Schema> = Utils.Object.KeysBy<
|
|
81
|
+
GetAll<TSchemaUID>,
|
|
93
82
|
{ required: true }
|
|
94
83
|
>;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
|
|
85
|
+
export type GetOptionalKeys<TSchemaUID extends Common.UID.Schema> = keyof Omit<
|
|
86
|
+
GetAll<TSchemaUID>,
|
|
87
|
+
GetRequiredKeys<TSchemaUID>
|
|
98
88
|
>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtendableContext, Next } from 'koa';
|
|
2
|
+
|
|
3
|
+
export type ControllerHandler = <TResponse = unknown>(
|
|
4
|
+
context: ExtendableContext,
|
|
5
|
+
next: Next
|
|
6
|
+
) => Promise<TResponse | void> | TResponse | void;
|
|
7
|
+
|
|
8
|
+
export type Controller = Record<string, ControllerHandler>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Shared,
|
|
3
|
+
Schema as SchemaNamespace,
|
|
4
|
+
Common,
|
|
5
|
+
Registry,
|
|
6
|
+
UID,
|
|
7
|
+
Utils,
|
|
8
|
+
} from '@strapi/strapi';
|
|
9
|
+
|
|
10
|
+
export type Service = Registry.Keys<Shared.Services, UID.Service>;
|
|
11
|
+
|
|
12
|
+
export type Controller = Registry.Keys<Shared.Controllers, UID.Controller>;
|
|
13
|
+
|
|
14
|
+
export type Policy = Registry.Keys<Shared.Policies, UID.Policy>;
|
|
15
|
+
|
|
16
|
+
export type Middleware = Registry.Keys<Shared.Middlewares, UID.Middleware>;
|
|
17
|
+
|
|
18
|
+
export type ContentType = Registry.Keys<Shared.ContentTypes, UID.ContentType>;
|
|
19
|
+
|
|
20
|
+
export type CollectionType = Utils.Guard.Never<
|
|
21
|
+
// extract uids only for collection types
|
|
22
|
+
Extract<Utils.Object.KeysBy<Shared.ContentTypes, SchemaNamespace.CollectionType>, ContentType>,
|
|
23
|
+
// if no collection type is found (never), fallback to a generic content type uid
|
|
24
|
+
ContentType
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export type SingleType = Utils.Guard.Never<
|
|
28
|
+
// extract uids only for single types
|
|
29
|
+
Extract<Utils.Object.KeysBy<Shared.ContentTypes, SchemaNamespace.SingleType>, ContentType>,
|
|
30
|
+
// if no single type is found (never), fallback to a generic content type uid
|
|
31
|
+
ContentType
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export type Component = Registry.Keys<Shared.Components, UID.Component>;
|
|
35
|
+
export type ComponentCategory = Component extends UID.Component<infer TCategory>
|
|
36
|
+
? TCategory
|
|
37
|
+
: never;
|
|
38
|
+
|
|
39
|
+
export type Schema = Registry.Keys<
|
|
40
|
+
Common.Schemas,
|
|
41
|
+
UID.ContentType | UID.Component<ComponentCategory>
|
|
42
|
+
>;
|
|
43
|
+
|
|
44
|
+
export type IsCollectionType<TContentTypeUID extends ContentType> = Utils.Expression.Extends<
|
|
45
|
+
Shared.ContentTypes[TContentTypeUID],
|
|
46
|
+
SchemaNamespace.CollectionType
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
export type IsSingleType<TContentTypeUID extends ContentType> = Utils.Expression.Extends<
|
|
50
|
+
Shared.ContentTypes[TContentTypeUID],
|
|
51
|
+
SchemaNamespace.SingleType
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
export type IsComponent<TComponentUID extends Component> = Utils.Expression.Extends<
|
|
55
|
+
Shared.Components[TComponentUID],
|
|
56
|
+
SchemaNamespace.Component
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
export type IsContentType<TContentTypeUID extends ContentType> = Utils.Expression.Or<
|
|
60
|
+
IsCollectionType<TContentTypeUID>,
|
|
61
|
+
IsSingleType<TContentTypeUID>
|
|
62
|
+
>;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export * from './attributes';
|
|
2
|
-
export * from './schemas';
|
|
1
|
+
export * as Attribute from './attributes';
|
|
2
|
+
export * as Schema from './schemas';
|
|
3
3
|
export * from './strapi';
|
|
4
|
+
|
|
5
|
+
export * as Common from './common';
|
|
6
|
+
export * as Namespace from './namespace';
|
|
7
|
+
export * as UID from './uid';
|
|
8
|
+
export * as Registry from './registry';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type * as Utils from '../utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Namespace for admin resources
|
|
5
|
+
*/
|
|
6
|
+
export type Admin = 'admin';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Namespace for strapi internal resources
|
|
10
|
+
*/
|
|
11
|
+
export type Strapi = 'strapi';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Namespace for scoped APIs resources
|
|
15
|
+
*/
|
|
16
|
+
export type API<T extends string = string> = `api${ColonsSeparator}${T}`;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Namespace for scoped plugins resources
|
|
20
|
+
*/
|
|
21
|
+
export type Plugin<T extends string = string> = `plugin${ColonsSeparator}${T}`;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Namespace for global resources
|
|
25
|
+
*/
|
|
26
|
+
export type Global = 'global';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Represents any namespace
|
|
30
|
+
*/
|
|
31
|
+
export type Any = API | Plugin | Admin | Strapi | Global;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Return a {@link Separator} based on the given {@link Any} ({@link DotSeparator} for {@link Scoped} and {@link ColonsSeparator} for regular ones)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* type S = GetSeparator<Admin>
|
|
38
|
+
* // ^ '::'
|
|
39
|
+
*
|
|
40
|
+
* type S = GetSeparator<API>
|
|
41
|
+
* // ^ '.'
|
|
42
|
+
*
|
|
43
|
+
* type S = GetSeparator<Admin | API>
|
|
44
|
+
* // ^ '.' | '::'
|
|
45
|
+
*/
|
|
46
|
+
export type GetSeparator<TNamespace extends Any = Any> = TNamespace extends Scoped
|
|
47
|
+
? // 'api::foo' | 'plugin::bar' => '.'
|
|
48
|
+
DotSeparator
|
|
49
|
+
: // 'admin' | 'strapi' | 'global' => '::'
|
|
50
|
+
ColonsSeparator;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Adds the corresponding separator (using {@link GetSeparator}) at the end of a namespace
|
|
54
|
+
*
|
|
55
|
+
* Warning: Using WithSeparator with a union type might produce undesired results as it'll distribute every matching suffix to every union member
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* type T = WithSeparator<Admin>
|
|
59
|
+
* // ^ 'admin::'
|
|
60
|
+
*
|
|
61
|
+
* type T = WithSeparator<API>
|
|
62
|
+
* // ^ 'api::{string}.'
|
|
63
|
+
*
|
|
64
|
+
* type T = WithSeparator<Admin | API>
|
|
65
|
+
* // ^ 'admin::' | 'admin.' | 'api::{string}.' | 'api::{string}::'
|
|
66
|
+
*
|
|
67
|
+
* type T = WithSeparator<Admin> | WithSeparator<API>
|
|
68
|
+
* // ^ 'admin::' | 'api::{string}.'
|
|
69
|
+
*/
|
|
70
|
+
export type WithSeparator<TNamespace extends Any> = Utils.String.Suffix<
|
|
71
|
+
TNamespace,
|
|
72
|
+
GetSeparator<TNamespace>
|
|
73
|
+
>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Represents namespaces composed of an origin and a scope, separated by colons
|
|
77
|
+
*/
|
|
78
|
+
export type Scoped<TOrigin extends string = string, TScope extends string = string> = Any &
|
|
79
|
+
`${TOrigin}${ColonsSeparator}${TScope}`;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Extract the scope from the given scoped namespace
|
|
83
|
+
*/
|
|
84
|
+
export type ExtractScope<TNamespace> =
|
|
85
|
+
TNamespace extends `${string}${ColonsSeparator}${infer TScope}` ? TScope : never;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Extract the origin from the given scoped namespace
|
|
89
|
+
*/
|
|
90
|
+
export type ExtractOrigin<TNamespace> =
|
|
91
|
+
TNamespace extends `${infer TOrigin}${ColonsSeparator}${string}` ? TOrigin : never;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Separators used to join the different parts of a namespace (e.g. building a uid)
|
|
95
|
+
*/
|
|
96
|
+
export type Separator = ColonsSeparator | DotSeparator;
|
|
97
|
+
|
|
98
|
+
type ColonsSeparator = '::';
|
|
99
|
+
type DotSeparator = '.';
|