mirror of
https://github.com/strapi/strapi.git
synced 2025-08-06 15:53:11 +00:00
Fix circular dependencies breaking types resolution due to DefaultOption using GetAttributeValue
This commit is contained in:
parent
626875fef2
commit
40875d4866
@ -55,8 +55,8 @@ export interface UniqueOption {
|
||||
unique?: boolean;
|
||||
}
|
||||
|
||||
export interface DefaultOption<T extends Attribute> {
|
||||
default?: GetAttributeValue<T>;
|
||||
export interface DefaultOption<T> {
|
||||
default?: T;
|
||||
}
|
||||
|
||||
export interface ConfigurableOption {
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
export type BigIntegerAttribute = Attribute<'biginteger'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxOption<string> &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type BigIntegerAttribute = Attribute<'biginteger'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<BigIntegerValue> &
|
||||
MinMaxOption<string> &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type BigIntegerValue = string;
|
||||
|
||||
|
@ -6,16 +6,12 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
export type BooleanAttribute = Attribute<'boolean'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type BooleanAttribute = Attribute<'boolean'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<BooleanValue> &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type BooleanValue = boolean;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
UniqueOption,
|
||||
} from './base';
|
||||
|
||||
export type DateTimeAttribute = Attribute<'datetime'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption
|
||||
: never
|
||||
: never;
|
||||
export type DateTimeAttribute = Attribute<'datetime'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<DateTimeValue> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption;
|
||||
|
||||
export type DateTimeValue = string;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
UniqueOption,
|
||||
} from './base';
|
||||
|
||||
export type DateAttribute = Attribute<'date'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption
|
||||
: never
|
||||
: never;
|
||||
export type DateAttribute = Attribute<'date'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<DateValue> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption;
|
||||
|
||||
export type DateValue = Date;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
export type DecimalAttribute = Attribute<'decimal'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxOption &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type DecimalAttribute = Attribute<'decimal'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<DecimalValue> &
|
||||
MinMaxOption &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type DecimalValue = number;
|
||||
|
||||
|
@ -8,18 +8,14 @@ import {
|
||||
UniqueOption,
|
||||
} from './base';
|
||||
|
||||
export type EmailAttribute = Attribute<'email'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption
|
||||
: never
|
||||
: never;
|
||||
export type EmailAttribute = Attribute<'email'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<EmailValue> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption;
|
||||
|
||||
export type EmailValue = string;
|
||||
|
||||
|
@ -12,16 +12,12 @@ export interface EnumerationAttributeProperties<T extends string[] = []> {
|
||||
}
|
||||
|
||||
export type EnumerationAttribute<T extends string[] = []> = Attribute<'enumeration'> &
|
||||
EnumerationAttributeProperties<T> extends infer U
|
||||
? U extends Attribute
|
||||
? U &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<U> &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
EnumerationAttributeProperties<T> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type EnumerationValue<T extends string[]> = GetArrayValues<T>;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
export type FloatAttribute = Attribute<'float'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxOption &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type FloatAttribute = Attribute<'float'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<FloatValue> &
|
||||
MinMaxOption &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type FloatValue = number;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
export type IntegerAttribute = Attribute<'integer'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxOption &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type IntegerAttribute = Attribute<'integer'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<IntegerValue> &
|
||||
MinMaxOption &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type IntegerValue = number;
|
||||
|
||||
|
@ -7,19 +7,13 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
// export interface PasswordAttribute extends BaseStringAttribute<'password'> {}
|
||||
|
||||
export type PasswordAttribute = Attribute<'password'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type PasswordAttribute = Attribute<'password'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<PasswordValue> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type PasswordValue = string;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
RequiredOption,
|
||||
} from './base';
|
||||
|
||||
export type RichTextAttribute = Attribute<'richtext'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
export type RichTextAttribute = Attribute<'richtext'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<RichTextValue> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type RichTextValue = string;
|
||||
|
||||
|
@ -14,18 +14,14 @@ export interface StringAttributeProperties {
|
||||
|
||||
export type StringAttribute = Attribute<'string'> &
|
||||
// Properties
|
||||
StringAttributeProperties extends infer U
|
||||
? U extends Attribute
|
||||
? U &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<U> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
UniqueOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
StringAttributeProperties &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<StringValue> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
UniqueOption &
|
||||
RequiredOption;
|
||||
|
||||
export type StringValue = string;
|
||||
|
||||
|
@ -14,18 +14,14 @@ export interface TextAttributeProperties {
|
||||
|
||||
export type TextAttribute = Attribute<'text'> &
|
||||
// Properties
|
||||
TextAttributeProperties extends infer U
|
||||
? U extends Attribute
|
||||
? U &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<U> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
UniqueOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
TextAttributeProperties &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<TextValue> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
UniqueOption &
|
||||
RequiredOption;
|
||||
|
||||
export type TextValue = string;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
UniqueOption,
|
||||
} from './base';
|
||||
|
||||
export type TimeAttribute = Attribute<'time'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption
|
||||
: never
|
||||
: never;
|
||||
export type TimeAttribute = Attribute<'time'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<TimeValue> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption;
|
||||
|
||||
export type TimeValue = string;
|
||||
|
||||
|
@ -7,17 +7,13 @@ import {
|
||||
UniqueOption,
|
||||
} from './base';
|
||||
|
||||
export type TimestampAttribute = Attribute<'timestamp'> extends infer T
|
||||
? T extends Attribute
|
||||
? T &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<T> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption
|
||||
: never
|
||||
: never;
|
||||
export type TimestampAttribute = Attribute<'timestamp'> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<TimestampValue> &
|
||||
PrivateOption &
|
||||
RequiredOption &
|
||||
UniqueOption;
|
||||
|
||||
export type TimestampValue = string;
|
||||
|
||||
|
@ -40,17 +40,15 @@ export type UIDAttribute<
|
||||
U extends T extends SchemaUID
|
||||
? GetAttributesKeysByType<T, 'string' | 'text'>
|
||||
: undefined = undefined
|
||||
> = Attribute<'uid'> & UIDAttributeProperties<S, T, U> extends infer P
|
||||
? P extends Attribute
|
||||
? P &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<P> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption
|
||||
: never
|
||||
: never;
|
||||
> = Attribute<'uid'> &
|
||||
// Properties
|
||||
UIDAttributeProperties<S, T, U> &
|
||||
// Options
|
||||
ConfigurableOption &
|
||||
DefaultOption<UIDValue> &
|
||||
MinMaxLengthOption &
|
||||
PrivateOption &
|
||||
RequiredOption;
|
||||
|
||||
export type UIDValue = string;
|
||||
|
||||
|
@ -3,7 +3,6 @@ import {
|
||||
Attribute,
|
||||
AttributeType,
|
||||
GetBigIntegerAttributeValue,
|
||||
GetComponentAttributeValue,
|
||||
GetBooleanAttributeValue,
|
||||
GetDecimalAttributeValue,
|
||||
GetDynamicZoneAttributeValue,
|
||||
@ -18,7 +17,8 @@ import {
|
||||
GetStringAttributeValue,
|
||||
GetTextAttributeValue,
|
||||
GetUIDAttributeValue,
|
||||
BigIntegerAttribute,
|
||||
GetComponentAttributeValue,
|
||||
GetEmailAttributeValue,
|
||||
} from '.';
|
||||
import { GetDateAttributeValue } from './date';
|
||||
import { GetDateTimeAttributeValue } from './date-time';
|
||||
@ -54,6 +54,7 @@ export type GetAttributeValue<T extends Attribute> =
|
||||
| GetDecimalAttributeValue<T>
|
||||
| GetDynamicZoneAttributeValue<T>
|
||||
| GetEnumerationAttributeValue<T>
|
||||
| GetEmailAttributeValue<T>
|
||||
| GetFloatAttributeValue<T>
|
||||
| GetIntegerAttributeValue<T>
|
||||
| GetJsonAttributeValue<T>
|
||||
|
Loading…
x
Reference in New Issue
Block a user