contentful-management
Version:
Client for Contentful's Content Management API
230 lines (229 loc) • 8.01 kB
TypeScript
import type { Except } from 'type-fest';
import type { CursorPaginationParams, DataTypeDefinition, ExoCursorPaginatedCollectionProp, ExoMetadataProps, ExoQueryFilters, Link, ResourceLink } from '../common-types';
/**
* @deprecated Use `ComponentQueryOptions` (see `./component`) instead.
* The ComponentType entity is superseded by the Component entity.
*/
export type ComponentTypeQueryOptions = CursorPaginationParams & ExoQueryFilters & {
order?: string;
};
export type ComponentTypeViewport = {
id: string;
query: string;
displayName: string;
previewSize: string;
};
export type ComponentTypeContentProperty = DataTypeDefinition & {
id: string;
name: string;
required: boolean;
defaultValue?: unknown;
};
export type StringDesignPropertyRegexpValidation = {
regexp: {
pattern: string;
};
};
export type DesignTokenAllowedResource = {
type: 'DesignToken';
value: string;
name?: string;
};
export type DTCGDesignPropertyType = 'DTCG.Color' | 'DTCG.Dimension' | 'DTCG.FontFamily' | 'DTCG.FontWeight' | 'DTCG.Duration' | 'DTCG.CubicBezier' | 'DTCG.Number' | 'DTCG.StrokeStyle' | 'DTCG.Border' | 'DTCG.Transition' | 'DTCG.Shadow' | 'DTCG.Gradient' | 'DTCG.Typography';
type DesignPropertyCommonFields = {
id: string;
name: string;
description?: string;
};
export type StringDesignProperty = DesignPropertyCommonFields & {
type: 'String';
fallbackValue?: {
type: 'ManualDesignValue';
value: string;
};
validations?: StringDesignPropertyRegexpValidation[];
};
export type BooleanDesignProperty = DesignPropertyCommonFields & {
type: 'Boolean';
fallbackValue?: {
type: 'ManualDesignValue';
value: boolean;
};
};
export type TokenBackedDesignProperty = DesignPropertyCommonFields & {
type: DTCGDesignPropertyType;
fallbackValue?: DesignTokenValue;
allowedResources?: DesignTokenAllowedResource[];
};
export type ComponentTypeDesignProperty = StringDesignProperty | BooleanDesignProperty | TokenBackedDesignProperty;
export type ContentPropertyPointerValue = `$contentProperties/${string}`;
export type DesignPropertyPointerValue = `$designProperties/${string}`;
export type ManualDesignValue = {
type: 'ManualDesignValue';
value: string | number | boolean;
};
export type DesignTokenValue = {
type: 'DesignToken';
/** Must be non-empty (min length 1) */
value: string;
};
export type DesignPropertyValue = ManualDesignValue | DesignTokenValue;
export type DimensionedDesignPropertyValue = Record<string, DesignPropertyValue>;
export type ComponentTreeDesignPropertyValue = DesignPropertyValue | DesignPropertyPointerValue | DimensionedDesignPropertyValue;
/**
* @deprecated Use `ComponentNodeV2` instead. `ComponentNodeV2` uses the renamed
* `component` link (`Contentful:Component`) in place of `componentType`.
*/
export type ComponentNode = {
id: string;
name?: string;
nodeType: 'Component';
componentType: ResourceLink<'Contentful:ComponentType'>;
contentProperties: Record<string, ContentPropertyPointerValue | unknown> | string;
designProperties: Record<string, ComponentTreeDesignPropertyValue>;
slots: Record<string, TreeNode[]>;
};
/**
* @deprecated Use `ExperienceFragmentNode` instead. `ExperienceFragmentNode` uses the
* renamed `experienceFragment` link (`Contentful:ExperienceFragment`).
*/
export type FragmentNode = {
id: string;
name?: string;
nodeType: 'Fragment';
fragment: ResourceLink<'Contentful:Fragment'>;
};
export type ExperienceFragmentNode = {
id: string;
name?: string;
nodeType: 'ExperienceFragment';
experienceFragment: ResourceLink<'Contentful:ExperienceFragment'>;
};
export type SlotNode = {
id: string;
nodeType: 'Slot';
slotId: string;
};
export type ComponentNodeV2 = {
id: string;
name?: string;
nodeType: 'Component';
component: ResourceLink<'Contentful:Component'>;
contentProperties: Record<string, ContentPropertyPointerValue | unknown> | string;
designProperties: Record<string, ComponentTreeDesignPropertyValue>;
slots: Record<string, TreeNodeV2[]>;
};
/**
* @deprecated Use TreeNodeV2 instead.
*/
export type TreeNode = ComponentNode | FragmentNode | SlotNode;
/**
* Renamed form of TreeNode used in ExperienceTemplate component trees (post-migration).
*
* This will be renamed to TreeNode in the future, but during the migration, we need to support both.
*/
export type TreeNodeV2 = ComponentNodeV2 | ExperienceFragmentNode | SlotNode;
export type DataAssemblyLink = ResourceLink<'Contentful:DataAssembly'>;
export declare const COMPONENT_TYPE_ALLOWED_RESOURCE_SOURCE: "crn:contentful:::experience:spaces/$self/environments/$self";
/**
* @deprecated Use `ComponentSlotDefinition` instead. `ComponentSlotDefinition` uses the
* renamed `allowedResources[].type` value (`Contentful:Component`).
*/
export type ComponentTypeSlotDefinition = {
id: string;
name: string;
required: boolean;
validations: Array<{
size?: {
min?: number;
max?: number;
};
}>;
allowedResources?: Array<{
type: 'Contentful:ComponentType';
source: typeof COMPONENT_TYPE_ALLOWED_RESOURCE_SOURCE;
allowedTypes: string[];
}>;
};
export type ComponentSlotDefinition = {
id: string;
name: string;
required: boolean;
validations: Array<{
size?: {
min?: number;
max?: number;
};
}>;
allowedResources?: Array<{
type: 'Contentful:Component';
source: typeof COMPONENT_TYPE_ALLOWED_RESOURCE_SOURCE;
allowedTypes: string[];
}>;
};
/**
* @deprecated Use the Component entity (see `./component`) instead.
* The ComponentType endpoint is superseded by the Component endpoint.
*/
export type ComponentTypeSys = {
id: string;
type: 'ComponentType';
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'>;
};
/**
* @deprecated Use `ComponentProps` (see `./component`) instead.
* The ComponentType entity is superseded by the Component entity.
*/
export type ComponentTypeProps = {
sys: ComponentTypeSys;
name: string;
description: string;
viewports: ComponentTypeViewport[];
contentProperties: ComponentTypeContentProperty[];
designProperties: ComponentTypeDesignProperty[];
componentTree?: TreeNode[];
slots?: ComponentTypeSlotDefinition[];
metadata?: ExoMetadataProps;
dataAssemblies?: DataAssemblyLink[];
source?: ResourceLink<'Contentful:DesignSystemSource'>;
};
/**
* @deprecated Use `CreateComponentProps` (see `./component`) instead.
* The ComponentType entity is superseded by the Component entity.
*/
export type CreateComponentTypeProps = Except<ComponentTypeProps, 'sys' | 'source'> & {
source?: ResourceLink<'Contentful:DesignSystemSource'> | null;
};
/**
* @deprecated Use `UpsertComponentProps` (see `./component`) instead.
* The ComponentType entity is superseded by the Component entity.
*/
export type UpsertComponentTypeProps = Except<ComponentTypeProps, 'sys' | 'source'> & {
sys: {
id: string;
type: 'ComponentType';
version?: number;
};
source?: ResourceLink<'Contentful:DesignSystemSource'> | null;
};
/**
* @deprecated Use `ComponentCollection` (see `./component`) instead.
* The ComponentType entity is superseded by the Component entity.
*/
export type ComponentTypeCollection = ExoCursorPaginatedCollectionProp<ComponentTypeProps>;
export {};