mirror of
https://github.com/strapi/strapi.git
synced 2025-12-02 10:04:09 +00:00
Rename AssertNamespaceIs to EnsureNamespaceMatches for uids
This commit is contained in:
parent
a13398e0d2
commit
fef81ec261
24
packages/core/strapi/lib/types/core/uid.d.ts
vendored
24
packages/core/strapi/lib/types/core/uid.d.ts
vendored
@ -108,16 +108,16 @@ export type Parse<U extends Any> = ExtractNamespace<U> extends infer B extends N
|
||||
* It returns N (the {@link Namespace.Any} literal) if there is a match, never otherwise.
|
||||
*
|
||||
* @example
|
||||
* type T = AssertNamespaceIs<'admin::foo', Namespace.Admin>
|
||||
* type T = EnsureNamespaceMatches<'admin::foo', Namespace.Admin>
|
||||
* // ^ Namespace.Admin
|
||||
* @example
|
||||
* type T = AssertNamespaceIs<'foo.bar', Namespace.API>
|
||||
* type T = EnsureNamespaceMatches<'foo.bar', Namespace.API>
|
||||
* // ^ never
|
||||
* @example
|
||||
* type T = AssertNamespaceIs<'api::foo.bar', Namespace.Plugin>
|
||||
* type T = EnsureNamespaceMatches<'api::foo.bar', Namespace.Plugin>
|
||||
* // ^ never
|
||||
*/
|
||||
export type AssertNamespaceIs<U extends Any, N extends Namespace.Any> = U extends StringSuffix<
|
||||
export type EnsureNamespaceMatches<U extends Any, N extends Namespace.Any> = U extends StringSuffix<
|
||||
Namespace.WithSeparator<N>
|
||||
>
|
||||
? N
|
||||
@ -137,18 +137,18 @@ export type Select<U extends Any, P extends keyof Parse<U>> = Pick<Parse<U>, P>;
|
||||
* Extract the namespace literal from a given UID.
|
||||
*
|
||||
* @example
|
||||
* type T = AssertNamespaceIs<'admin::foo'>
|
||||
* type T = ExtractNamespace<'admin::foo'>
|
||||
* // ^ Namespace.Admin
|
||||
* @example
|
||||
* type T = AssertNamespaceIs<'api::foo.bar'>
|
||||
* type T = ExtractNamespace<'api::foo.bar'>
|
||||
* // ^ Namespace.API
|
||||
* @example
|
||||
* type T = AssertNamespaceIs<'admin::foo' | 'api::foo.bar'>
|
||||
* type T = ExtractNamespace<'admin::foo' | 'api::foo.bar'>
|
||||
* // ^ Namespace.Admin | Namespace.API
|
||||
*/
|
||||
export type ExtractNamespace<U extends Any> =
|
||||
| AssertNamespaceIs<U, Namespace.Global>
|
||||
| AssertNamespaceIs<U, Namespace.Admin>
|
||||
| AssertNamespaceIs<U, Namespace.Strapi>
|
||||
| AssertNamespaceIs<U, Namespace.API>
|
||||
| AssertNamespaceIs<U, Namespace.Plugin>;
|
||||
| EnsureNamespaceMatches<U, Namespace.Global>
|
||||
| EnsureNamespaceMatches<U, Namespace.Admin>
|
||||
| EnsureNamespaceMatches<U, Namespace.Strapi>
|
||||
| EnsureNamespaceMatches<U, Namespace.API>
|
||||
| EnsureNamespaceMatches<U, Namespace.Plugin>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user