@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,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;
|
|
@@ -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;
|