UNPKG

1.72 kBTypeScriptView Raw
1import type { CollectionProp, DefaultElements, EntryMetaSysProps, KeyValueMap, MakeRequest, MetadataProps } from '../common-types';
2import type { ContentfulEntryApi } from '../create-entry-api';
3import type { AssetProps } from './asset';
4export type EntryProps<T = KeyValueMap> = {
5 sys: EntryMetaSysProps;
6 metadata?: MetadataProps;
7 fields: T;
8};
9export type CreateEntryProps<TFields = KeyValueMap> = Omit<EntryProps<TFields>, 'sys'>;
10export type EntryReferenceError = {
11 sys: {
12 type: 'error';
13 id: 'notResolvable';
14 };
15 details: {
16 type: 'Link';
17 linkType: 'Entry' | 'Asset';
18 id: string;
19 };
20};
21export interface EntryReferenceProps extends CollectionProp<EntryProps> {
22 includes?: {
23 Entry?: EntryProps[];
24 Asset?: AssetProps[];
25 };
26 errors?: EntryReferenceError[];
27}
28export type EntryReferenceOptionsProps = {
29 include?: number;
30};
31export interface Entry extends EntryProps, DefaultElements<EntryProps>, ContentfulEntryApi {
32}
33export type WithResourceName<T extends {
34 sys: unknown;
35}> = T extends {
36 sys: infer Sys;
37} ? Omit<T, 'sys'> & {
38 sys: Sys & {
39 urn: string;
40 };
41} : never;
42/**
43 * @private
44 * @param makeRequest - function to make requests via an adapter
45 * @param data - Raw entry data
46 * @return Wrapped entry data
47 */
48export declare function wrapEntry(makeRequest: MakeRequest, data: EntryProps): Entry;
49/**
50 * Data is also mixed in with link getters if links exist and includes were requested
51 * @private
52 */
53export declare const wrapEntryCollection: (makeRequest: MakeRequest, data: CollectionProp<EntryProps<KeyValueMap>>) => import("../common-types").Collection<Entry, EntryProps<KeyValueMap>>;