@prismicio/types-internal
Version:
Prismic types for Custom Types and Prismic Data
771 lines (770 loc) • 33.3 kB
TypeScript
import * as t from "io-ts";
import type { ContentPath, TraverseWidgetContentFn } from "../../../_internal/utils";
import { type NestableWidget } from "../../../customtypes";
import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx";
export declare const TableContentType = "TableContent";
export declare const isTableContent: (u: unknown) => u is {
__TYPE__: "TableContent";
content: ({
key: string;
} & {
type: "tableRow";
content: ({
key: string;
} & {
type: "tableHeader" | "tableCell";
content: {
__TYPE__: "StructuredTextContent";
value: (({
type: "image";
data: {
origin: {
id: string;
url: string;
width: number;
height: number;
};
width: number;
height: number;
edit: {
zoom: number;
crop: {
x: number;
y: number;
};
background: string;
};
} & {
url?: string;
credits?: string | null;
alt?: string | null;
provider?: string | null | undefined;
} & {
linkTo?: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
}) | null | undefined;
};
} & {
label?: string | null | undefined;
direction?: string | null | undefined;
}) | ({
type: "embed";
data: {
embed_url: string;
type: string;
} & {
version?: string | number | null;
title?: string | null | undefined;
author_name?: string | null | undefined;
author_url?: string | null | undefined;
provider_name?: string | null | undefined;
provider_url?: string | null | undefined;
cache_age?: string | number | null;
thumbnail_url?: string | null | undefined;
thumbnail_width?: number | null | undefined;
thumbnail_height?: number | null | undefined;
html?: string | null | undefined;
} & {
__TYPE__: "EmbedContent";
all: unknown;
};
} & {
label?: string | null | undefined;
direction?: string | null | undefined;
}) | ({
type: "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
content: {
text: string;
} & {
spans?: ({
data: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
});
start: number;
end: number;
type: "hyperlink";
} | {
data: string;
start: number;
end: number;
type: "label";
} | {
start: number;
end: number;
type: "strong" | "em" | "list-item";
})[];
};
} & {
label?: string;
direction?: string;
}))[];
};
} & {
columnWidth?: number;
})[];
})[];
};
export declare const TableContent: t.ExactC<t.TypeC<{
__TYPE__: t.LiteralC<"TableContent">;
content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
key: t.Type<string, string, unknown>;
}>>, t.ExactC<t.TypeC<{
type: t.LiteralC<"tableRow">;
content: t.ArrayC<t.IntersectionC<[t.ExactC<t.TypeC<{
key: t.Type<string, string, unknown>;
}>>, t.IntersectionC<[t.ExactC<t.TypeC<{
type: t.UnionC<[t.LiteralC<"tableHeader">, t.LiteralC<"tableCell">]>;
content: t.ExactC<t.TypeC<{
__TYPE__: t.LiteralC<"StructuredTextContent">;
value: t.ArrayC<t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.LiteralC<"image">;
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
origin: t.ExactC<t.TypeC<{
id: t.StringC;
url: t.StringC;
width: t.NumberC;
height: t.NumberC;
}>>;
width: t.NumberC;
height: t.NumberC;
edit: t.TypeC<{
zoom: t.NumberC;
crop: t.TypeC<{
x: t.NumberC;
y: t.NumberC;
}>;
background: t.StringC;
}>;
}>, t.PartialC<{
url: t.StringC;
credits: t.Type<string | null, string | null, unknown>;
alt: t.Type<string | null, string | null, unknown>;
provider: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
}>]>>, t.PartialC<{
linkTo: t.UnionC<[t.Type<({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
}), ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
}), unknown>, t.NullC, t.UndefinedC]>;
}>]>;
}>, t.PartialC<{
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.LiteralC<"embed">;
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
embed_url: t.StringC;
type: t.StringC;
}>, t.PartialC<{
version: t.UnionC<[t.StringC, t.NumberC, t.NullC]>;
title: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
author_name: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
author_url: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
provider_name: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
provider_url: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
cache_age: t.UnionC<[t.StringC, t.NumberC, t.NullC]>;
thumbnail_url: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
thumbnail_width: t.UnionC<[t.Type<number, number, unknown>, t.NullC, t.UndefinedC]>;
thumbnail_height: t.UnionC<[t.Type<number, number, unknown>, t.NullC, t.UndefinedC]>;
html: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
}>]>>, t.ExactC<t.TypeC<{
__TYPE__: t.LiteralC<"EmbedContent">;
all: t.UnknownC;
}>>]>;
}>, t.PartialC<{
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
content: t.IntersectionC<[t.TypeC<{
text: t.StringC;
}>, t.PartialC<{
spans: t.Type<({
data: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
});
start: number;
end: number;
type: "hyperlink";
} | {
data: string;
start: number;
end: number;
type: "label";
} | {
start: number;
end: number;
type: "strong" | "em" | "list-item";
})[], ({
data: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
});
start: number;
end: number;
type: "hyperlink";
} | {
data: string;
start: number;
end: number;
type: "label";
} | {
start: number;
end: number;
type: "strong" | "em" | "list-item";
})[], unknown>;
}>]>;
}>, t.PartialC<{
label: t.StringC;
direction: t.StringC;
}>]>>]>>;
}>>;
}>>, t.ExactC<t.PartialC<{
columnWidth: t.NumberC;
}>>]>]>>;
}>>]>>;
}>>;
export declare type TableContent = t.TypeOf<typeof TableContent>;
export declare const TableLegacy: (ctx: LegacyContentCtx) => t.Type<{
__TYPE__: "TableContent";
content: ({
key: string;
} & {
type: "tableRow";
content: ({
key: string;
} & {
type: "tableHeader" | "tableCell";
content: {
__TYPE__: "StructuredTextContent";
value: (({
type: "image";
data: {
origin: {
id: string;
url: string;
width: number;
height: number;
};
width: number;
height: number;
edit: {
zoom: number;
crop: {
x: number;
y: number;
};
background: string;
};
} & {
url?: string;
credits?: string | null;
alt?: string | null;
provider?: string | null | undefined;
} & {
linkTo?: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
}) | null | undefined;
};
} & {
label?: string | null | undefined;
direction?: string | null | undefined;
}) | ({
type: "embed";
data: {
embed_url: string;
type: string;
} & {
version?: string | number | null;
title?: string | null | undefined;
author_name?: string | null | undefined;
author_url?: string | null | undefined;
provider_name?: string | null | undefined;
provider_url?: string | null | undefined;
cache_age?: string | number | null;
thumbnail_url?: string | null | undefined;
thumbnail_width?: number | null | undefined;
thumbnail_height?: number | null | undefined;
html?: string | null | undefined;
} & {
__TYPE__: "EmbedContent";
all: unknown;
};
} & {
label?: string | null | undefined;
direction?: string | null | undefined;
}) | ({
type: "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
content: {
text: string;
} & {
spans?: ({
data: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
});
start: number;
end: number;
type: "hyperlink";
} | {
data: string;
start: number;
end: number;
type: "label";
} | {
start: number;
end: number;
type: "strong" | "em" | "list-item";
})[];
};
} & {
label?: string;
direction?: string;
}))[];
};
} & {
columnWidth?: number;
})[];
})[];
}, WithTypes<{
content: ({
key: string;
} & {
type: "tableRow";
content: ({
key: string;
} & {
type: "tableHeader" | "tableCell";
content: (({
type: "image";
data: {
origin: {
id: string;
url: string;
width: number;
height: number;
};
width: number;
height: number;
edit: {
zoom: number;
crop: {
x: number;
y: number;
};
background: string;
};
} & {
url?: string;
credits?: string | null;
alt?: string | null;
provider?: string | null | undefined;
} & {
linkTo?: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
}) | null | undefined;
};
} & {
label?: string | null | undefined;
direction?: string | null | undefined;
}) | ({
type: "embed";
data: {
embed_url: string;
type: string;
} & {
version?: string | number | null;
title?: string | null | undefined;
author_name?: string | null | undefined;
author_url?: string | null | undefined;
provider_name?: string | null | undefined;
provider_url?: string | null | undefined;
cache_age?: string | number | null;
thumbnail_url?: string | null | undefined;
thumbnail_width?: number | null | undefined;
thumbnail_height?: number | null | undefined;
html?: string | null | undefined;
} & {
__TYPE__: "EmbedContent";
all: unknown;
};
} & {
label?: string | null | undefined;
direction?: string | null | undefined;
}) | ({
type: "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
content: {
text: string;
} & {
spans?: ({
data: ({
__TYPE__: "ImageLink";
} & {
kind: "image";
id: string;
url: string;
height: string;
width: string;
size: string;
name: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "FileLink";
} & {
kind: "file";
id: string;
url: string;
name: string;
size: string;
} & {
date?: string | null | undefined;
}) | ({
__TYPE__: "DocumentLink";
} & {
id: string;
}) | ({
__TYPE__: "ExternalLink";
} & {
url: string;
} & {
kind?: "web";
target?: string | null | undefined;
preview?: {
title?: string;
} | null | undefined;
});
start: number;
end: number;
type: "hyperlink";
} | {
data: string;
start: number;
end: number;
type: "label";
} | {
start: number;
end: number;
type: "strong" | "em" | "list-item";
})[];
};
} & {
label?: string;
direction?: string;
}))[];
} & {
columnWidth?: number;
})[];
})[];
}>, unknown>;
export declare function traverseTableContent({ path, key, apiId, model, content, }: {
path: ContentPath;
key: string;
apiId: string;
content: TableContent;
model?: NestableWidget | undefined;
}): (transform: TraverseWidgetContentFn) => TableContent | undefined;