contentful-management
Version:
Client for Contentful's Content Management API
51 lines (50 loc) • 1.92 kB
TypeScript
import type { Except } from 'type-fest';
import type { CursorPaginationParams, ExoCursorPaginatedCollectionProp, ExoMetadataProps, ExoQueryFilters, Link } from '../common-types';
import type { ComponentSlotDefinition, ComponentTypeContentProperty, ComponentTypeDesignProperty, DataAssemblyLink, TreeNodeV2 } from './component-type';
export type ComponentSys = {
id: string;
type: 'Component';
version: number;
space: Link<'Space'>;
environment: Link<'Environment'>;
fieldStatus?: Record<string, Record<string, 'draft' | 'published' | 'changed'>>;
publishedAt?: string;
publishedVersion?: number;
publishedCounter?: number;
firstPublishedAt?: string;
publishedBy?: Link<'User'> | Link<'AppDefinition'>;
variant?: string;
variantType?: string;
variantDimension?: string;
createdAt: string;
createdBy: Link<'User'>;
updatedAt: string;
updatedBy: Link<'User'>;
};
export type ComponentProps = {
sys: ComponentSys;
name: string;
description: string;
contentProperties: ComponentTypeContentProperty[];
designProperties: ComponentTypeDesignProperty[];
/**
* `null` marks a coded component (no tree); `[]` is a composed component with an empty tree.
* The Content Management API requires this field on create and update, so always send it.
*/
componentTree?: TreeNodeV2[] | null;
slots?: ComponentSlotDefinition[];
metadata?: ExoMetadataProps;
dataAssemblies?: DataAssemblyLink[];
};
export type CreateComponentProps = Except<ComponentProps, 'sys'>;
export type UpsertComponentProps = Except<ComponentProps, 'sys'> & {
sys: {
id: string;
type: 'Component';
version?: number;
};
};
export type ComponentQueryOptions = CursorPaginationParams & ExoQueryFilters & {
order?: string;
};
export type ComponentCollection = ExoCursorPaginatedCollectionProp<ComponentProps>;