import type { String } from '../utils'; /** * Namespace for admin resources */ export type Admin = 'admin'; /** * Namespace for strapi internal resources */ export type Strapi = 'strapi'; /** * Namespace for scoped APIs resources */ export type API = `api${ColonsSeparator}${T}`; /** * Namespace for scoped plugins resources */ export type Plugin = `plugin${ColonsSeparator}${T}`; /** * Namespace for global resources */ export type Global = 'global'; /** * Represents any namespace */ export type AnyNamespace = API | Plugin | Admin | Strapi | Global; /** * Return a {@link Separator} based on the given {@link AnyNamespace} ({@link DotSeparator} for {@link Scoped} and {@link ColonsSeparator} for regular ones) * * @example * type S = GetSeparator * // ^ '::' * * type S = GetSeparator * // ^ '.' * * type S = GetSeparator * // ^ '.' | '::' */ export type GetSeparator = TNamespace extends Scoped ? DotSeparator : ColonsSeparator; /** * Adds the corresponding separator (using {@link GetSeparator}) at the end of a namespace * * Warning: Using WithSeparator with a union type might produce undesired results as it'll distribute every matching suffix to every union member * * @example * type T = WithSeparator * // ^ 'admin::' * * type T = WithSeparator * // ^ 'api::{string}.' * * type T = WithSeparator * // ^ 'admin::' | 'admin.' | 'api::{string}.' | 'api::{string}::' * * type T = WithSeparator | WithSeparator * // ^ 'admin::' | 'api::{string}.' */ export type WithSeparator = String.Suffix>; /** * Represents namespaces composed of an origin and a scope, separated by colons */ export type Scoped = AnyNamespace & `${TOrigin}${ColonsSeparator}${TScope}`; /** * Extract the scope from the given scoped namespace */ export type ExtractScope = TNamespace extends `${string}${ColonsSeparator}${infer TScope}` ? TScope : never; /** * Extract the origin from the given scoped namespace */ export type ExtractOrigin = TNamespace extends `${infer TOrigin}${ColonsSeparator}${string}` ? TOrigin : never; /** * Separators used to join the different parts of a namespace (e.g. building a uid) */ export type Separator = ColonsSeparator | DotSeparator; type ColonsSeparator = '::'; type DotSeparator = '.'; export {}; //# sourceMappingURL=namespace.d.ts.map