diff --git a/packages/core-data/src/dynamic-entities.ts b/packages/core-data/src/dynamic-entities.ts index 51b579cb0cfcf0..7db8865fded641 100644 --- a/packages/core-data/src/dynamic-entities.ts +++ b/packages/core-data/src/dynamic-entities.ts @@ -18,6 +18,7 @@ export type WPEntityTypes< C extends ET.Context = 'edit' > = { Site: ET.Settings< C >; Status: ET.PostStatusObject< C >; Taxonomy: ET.Taxonomy< C >; + Term: ET.Term< C >; Theme: ET.Theme< C >; UnstableBase: ET.UnstableBase< C >; User: ET.User< C >; diff --git a/packages/core-data/src/entity-types/index.ts b/packages/core-data/src/entity-types/index.ts index 68087a74005b2c..893de59cde548b 100644 --- a/packages/core-data/src/entity-types/index.ts +++ b/packages/core-data/src/entity-types/index.ts @@ -17,6 +17,7 @@ import type { PostRevision } from './post-revision'; import type { Settings } from './settings'; import type { Sidebar } from './sidebar'; import type { Taxonomy } from './taxonomy'; +import type { Term } from './term'; import type { Theme } from './theme'; import type { User } from './user'; import type { Type } from './type'; @@ -46,6 +47,7 @@ export type { Taxonomy, TemplatePartArea, TemplateType, + Term, Theme, Type, Updatable, @@ -105,6 +107,7 @@ export interface PerPackageEntityRecords< C extends Context > { | Settings< C > | Sidebar< C > | Taxonomy< C > + | Term< C > | Theme< C > | User< C > | Type< C > diff --git a/packages/core-data/src/entity-types/term.ts b/packages/core-data/src/entity-types/term.ts new file mode 100644 index 00000000000000..f007832d7e7553 --- /dev/null +++ b/packages/core-data/src/entity-types/term.ts @@ -0,0 +1,57 @@ +/** + * Internal dependencies + */ +import type { Context, ContextualField, OmitNevers } from './helpers'; + +import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records'; + +declare module './base-entity-records' { + export namespace BaseEntityRecords { + export interface Term< C extends Context > { + /** + * Unique identifier for the term. + */ + id: number; + /** + * Number of published posts for the term. + */ + count: ContextualField< number, 'view' | 'edit', C >; + /** + * HTML description of the term. + */ + description: ContextualField< string, 'view' | 'edit', C >; + /** + * URL of the term. + */ + link: string; + /** + * HTML title for the term. + */ + name: string; + /** + * An alphanumeric identifier for the term unique to its type. + */ + slug: string; + /** + * Type attribution for the term. + */ + taxonomy: string; + /** + * The parent term ID. Only present for hierarchical taxonomies. + */ + parent?: number; + /** + * Meta fields. + */ + meta: ContextualField< + Record< string, string >, + 'view' | 'edit', + C + >; + } + } +} + +export type Term< C extends Context = 'edit' > = OmitNevers< + _BaseEntityRecords.Term< C > +>;