@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
|
@@ -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 = '.';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type * as UID from './uid';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract valid keys from a given registry.
|
|
5
|
+
*
|
|
6
|
+
* It looks for {@link UID.Any} by default but the search can be narrowed to any UID subset using the `TUidFormat` generic.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* interface Registry {
|
|
10
|
+
* 'foo': unknown;
|
|
11
|
+
* 'default.foo': 'unknown';
|
|
12
|
+
* 'global::foo': unknown;
|
|
13
|
+
* 'api::foo.bar': unknown;
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* type T = Keys<Registry>;
|
|
17
|
+
* // ^ 'default.foo' | 'global::foo' | 'api::foo.bar'
|
|
18
|
+
* type T = Keys<Registry, UID.Policy>;
|
|
19
|
+
* // ^ 'global::foo' | 'api::foo.bar'
|
|
20
|
+
* type T = Keys<Registry, UID.Service>
|
|
21
|
+
* // ^ 'api::foo.bar'
|
|
22
|
+
*/
|
|
23
|
+
export type Keys<TRegistry, TUidFormat extends UID.Any = UID.Any> = Extract<
|
|
24
|
+
keyof TRegistry,
|
|
25
|
+
TUidFormat
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Performs a `TQuery` filtering operation on the given `TRegistry` registry.
|
|
30
|
+
*
|
|
31
|
+
* `TQuery` needs to be a partial representation of a {@link UID.Parsed}
|
|
32
|
+
*
|
|
33
|
+
* Note: For additional filtering, the registry keys' type can be passed as the third parameter.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* interface Registry {
|
|
37
|
+
* 'admin::foo': unknown;
|
|
38
|
+
* 'admin::bar': unknown;
|
|
39
|
+
* 'api::foo.bar': unknown;
|
|
40
|
+
* 'api::foo.baz': unknown;
|
|
41
|
+
* 'api::bar.foo': unknown;
|
|
42
|
+
* 'plugin::foo.bar': unknown;
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* type T = keyof WhereKeys<Registry, { namespace: Namespace.API }>;
|
|
46
|
+
* // ^ "api::foo.bar" | "api::foo.baz" | "api::bar.foo"
|
|
47
|
+
*
|
|
48
|
+
* type T = keyof WhereKeys<Registry, { name: 'bar' }>;
|
|
49
|
+
* // ^ "admin::bar" | "api::foo.bar" | "plugin::foo.bar"
|
|
50
|
+
*
|
|
51
|
+
* type T = keyof WhereKeys<Registry, { separator: '.' }>;
|
|
52
|
+
* // ^ "api::foo.bar" | "api::foo.baz" | "api::bar.foo" | 'plugin::foo.bar"
|
|
53
|
+
*
|
|
54
|
+
* type T = keyof WhereKeys<Registry, { namespace: Namespace.Plugin | Namespace.Admin }>;
|
|
55
|
+
* // ^ "plugin::foo.bar" | "admin::foo" | "admin::bar"
|
|
56
|
+
*
|
|
57
|
+
* type T = keyof WhereKeys<Registry, { namespace: Namespace.API; name: Utils.Includes<'b'> }>;
|
|
58
|
+
* // ^ "api::foo.bar" | "api::foo.baz"
|
|
59
|
+
*/
|
|
60
|
+
export type WhereKeys<
|
|
61
|
+
TRegistry,
|
|
62
|
+
TQuery extends Partial<UID.Parsed>,
|
|
63
|
+
TUidFormat extends UID.Any = UID.Any
|
|
64
|
+
> = {
|
|
65
|
+
[uid in Keys<TRegistry, TUidFormat> as UID.Parse<uid> extends TQuery
|
|
66
|
+
? uid
|
|
67
|
+
: never]: TRegistry[uid];
|
|
68
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Attribute,
|
|
2
|
-
import { KeysBy, SchemaUID, StringRecord } from '../../utils';
|
|
1
|
+
import type { Attribute, Utils, Common } from '@strapi/strapi';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Literal union type representing the possible natures of a content type
|
|
@@ -9,7 +8,7 @@ export type ContentTypeKind = 'singleType' | 'collectionType';
|
|
|
9
8
|
/**
|
|
10
9
|
* Literal union type representing the possible types of a model
|
|
11
10
|
*/
|
|
12
|
-
export type
|
|
11
|
+
export type ModelType = 'contentType' | 'component';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Data structure that can either represent a content type or a component
|
|
@@ -18,17 +17,17 @@ export interface Schema {
|
|
|
18
17
|
/**
|
|
19
18
|
* The type of the model. Useful to discriminate content-types from component
|
|
20
19
|
*/
|
|
21
|
-
modelType:
|
|
20
|
+
modelType: ModelType;
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* Informations about schema naming and display
|
|
25
24
|
*/
|
|
26
|
-
info:
|
|
25
|
+
info: Info;
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
28
|
* Map of all the attributes with their name and definition
|
|
30
29
|
*/
|
|
31
|
-
attributes:
|
|
30
|
+
attributes: Attributes;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* Options declared and read by the plugins
|
|
@@ -38,7 +37,7 @@ export interface Schema {
|
|
|
38
37
|
/**
|
|
39
38
|
* Options object dedicated to Strapi core features
|
|
40
39
|
*/
|
|
41
|
-
options?:
|
|
40
|
+
options?: Options;
|
|
42
41
|
|
|
43
42
|
/**
|
|
44
43
|
* Custom table name for the schema
|
|
@@ -49,7 +48,7 @@ export interface Schema {
|
|
|
49
48
|
/**
|
|
50
49
|
* Data structure containing naming and display information for a Schema
|
|
51
50
|
*/
|
|
52
|
-
export interface
|
|
51
|
+
export interface Info {
|
|
53
52
|
/**
|
|
54
53
|
* Default name to use in the admin panel
|
|
55
54
|
*/
|
|
@@ -79,12 +78,14 @@ export interface SchemaInfo {
|
|
|
79
78
|
/**
|
|
80
79
|
* Low level data structure referencing every schema attribute and its name
|
|
81
80
|
*/
|
|
82
|
-
export interface
|
|
81
|
+
export interface Attributes {
|
|
82
|
+
[key: string]: Attribute.Any;
|
|
83
|
+
}
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Structure containing every core schema options and their associated value
|
|
86
87
|
*/
|
|
87
|
-
export interface
|
|
88
|
+
export interface Options {
|
|
88
89
|
draftAndPublish?: boolean;
|
|
89
90
|
populateCreatorFields?: boolean;
|
|
90
91
|
comment?: string;
|
|
@@ -95,13 +96,13 @@ export interface PluginOptions {}
|
|
|
95
96
|
/**
|
|
96
97
|
* Schema for a content type
|
|
97
98
|
*/
|
|
98
|
-
export interface
|
|
99
|
+
export interface ContentType extends Schema {
|
|
99
100
|
modelType: 'contentType';
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
103
|
* Unique identifier of the schema
|
|
103
104
|
*/
|
|
104
|
-
uid:
|
|
105
|
+
uid: Common.UID.ContentType;
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
108
|
* Determine the type of the content type (single-type or collection-type)
|
|
@@ -112,20 +113,20 @@ export interface ContentTypeSchema extends Schema {
|
|
|
112
113
|
/**
|
|
113
114
|
* Schema for a collection type
|
|
114
115
|
*/
|
|
115
|
-
export interface
|
|
116
|
+
export interface CollectionType extends ContentType {
|
|
116
117
|
kind: 'collectionType';
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
/**
|
|
120
121
|
* Schema for a single type
|
|
121
122
|
*/
|
|
122
|
-
export interface
|
|
123
|
+
export interface SingleType extends ContentType {
|
|
123
124
|
kind: 'singleType';
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
/**
|
|
127
128
|
* Schema for a component
|
|
128
129
|
*/
|
|
129
|
-
export interface
|
|
130
|
+
export interface Component extends Schema {
|
|
130
131
|
modelType: 'component';
|
|
131
132
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import type { StringMap } from './utils';
|
|
5
|
-
import type { GenericController } from '../../../core-api/controller';
|
|
6
|
-
import type { GenericService } from '../../../core-api/service';
|
|
1
|
+
import type { Database } from '@strapi/database';
|
|
2
|
+
import type { Shared, Common } from '@strapi/strapi';
|
|
7
3
|
|
|
8
4
|
// TODO move custom fields types to a separate file
|
|
9
5
|
interface CustomFieldServerOptions {
|
|
@@ -69,24 +65,24 @@ export interface Strapi {
|
|
|
69
65
|
*
|
|
70
66
|
* It returns all the registered services
|
|
71
67
|
*/
|
|
72
|
-
readonly services:
|
|
68
|
+
readonly services: Shared.Services;
|
|
73
69
|
|
|
74
70
|
/**
|
|
75
71
|
* Find a service using its unique identifier
|
|
76
72
|
*/
|
|
77
|
-
service<
|
|
73
|
+
service<TService extends Common.Service = Common.Service>(uid: string): TService | undefined;
|
|
78
74
|
|
|
79
75
|
/**
|
|
80
76
|
* Getter for the Strapi controllers container
|
|
81
77
|
*
|
|
82
78
|
* It returns all the registered controllers
|
|
83
79
|
*/
|
|
84
|
-
readonly controllers:
|
|
80
|
+
readonly controllers: Shared.Controllers;
|
|
85
81
|
|
|
86
82
|
/**
|
|
87
83
|
* Find a controller using its unique identifier
|
|
88
84
|
*/
|
|
89
|
-
controller(uid:
|
|
85
|
+
controller<TContentTypeUID extends Common.UID.Controller>(uid: TContentTypeUID): Shared.Controllers[TContentTypeUID];
|
|
90
86
|
|
|
91
87
|
/**
|
|
92
88
|
* Getter for the Strapi content types container
|