import type * as Schema from '../../../schema'; import type * as UID from '../../../uid'; import type { Constants, Guard, If, And, DoesNotExtends, IsNotNever, XOR, Intersect, Extends } from '../../../utils'; import type { Params } from '..'; /** * Wildcard notation for populate * * To populate all the root level relations */ export type WildcardNotation = '*'; /** * Union of all possible string representation for populate * * @example * type A = 'image'; // ✅ * type B = 'image,component'; // ✅ * type c = '*'; // ✅ * type D = 'populatableField'; // ✅ * type E = ''; // ❌ */ export type StringNotation = WildcardNotation | Guard.Never, string> | `${string},${string}` | `${string}.${string}`; /** * Array notation for populate * * @example * type A = ['image']; // ✅ * type B = ['image', 'component']; // ✅ * type C = ['populatableField']; // ✅ * type D = ['']; // ❌ * type E = ['*']; // ❌ */ export type ArrayNotation = Exclude, WildcardNotation>[]; type GetPopulatableKeysWithTarget = Extract, Schema.AttributeNamesWithTarget>; type GetPopulatableKeysWithoutTarget = Exclude, GetPopulatableKeysWithTarget>; /** * Fragment populate notation for polymorphic attributes */ export type Fragment = { on?: { [TSchemaUID in TMaybeTargets]?: boolean | NestedParams; }; }; type PopulateClause> = { [TKey in TKeys]?: Schema.Attribute.Target> extends infer TTarget extends UID.Schema ? boolean | Intersect<[ NestedParams, If, CountClause, unknown> ]> : never; }; type CountClause = { count?: boolean; }; type DeprecatedSharedPopulateClauseForPolymorphicLinks = { /** * Enables the population of all first-level links using a wildcard. * * @deprecated The support is going to be dropped in Strapi v6 */ populate?: WildcardNotation; }; /** * Object notation for populate * * @example * type A = { image: true }; // ✅ * type B = { image: { fields: ['url', 'provider'] } }; // ✅ * type C = { populatableField: { populate: { nestedPopulatableField: true } } }; // ✅ * type D = { dynamic_zone: { on: { comp_A: { fields: ['name', 'price_a'] }, comp_B: { fields: ['name', 'price_b'] } } } }; // ✅ */ export type ObjectNotation = [ GetPopulatableKeysWithTarget, GetPopulatableKeysWithoutTarget ] extends [ infer TKeysWithTarget extends Schema.PopulatableAttributeNames, infer TKeysWithoutTarget extends Schema.PopulatableAttributeNames ] ? If>, If, PopulateClause> | If, { [TKey in TKeysWithoutTarget]?: boolean | Intersect<[ Fragment>, UID.Schema>>, DeprecatedSharedPopulateClauseForPolymorphicLinks ]>; }>, { [key: string]: boolean | XOR, CountClause]>, Intersect<[Fragment, DeprecatedSharedPopulateClauseForPolymorphicLinks]>>; }> : never; export type NestedParams = Params.Pick; export type Any = StringNotation | ArrayNotation | ObjectNotation; export {}; //# sourceMappingURL=populate.d.ts.map