UNPKG

1.35 kBTypeScriptView Raw
1import type { BasicMetaSysProps, CollectionProp, DefaultElements, MakeRequest, SysLink } from '../common-types';
2import type { ResourceType, UpsertResourceTypeProps } from './resource-type';
3export type ResourceProviderProps = {
4 /**
5 * System metadata
6 */
7 sys: Omit<BasicMetaSysProps, 'version'> & {
8 organization: SysLink;
9 appDefinition: SysLink;
10 };
11 /**
12 * Resource Provider type, value is 'function'
13 */
14 type: 'function';
15 /**
16 * Link to a Contentful function
17 */
18 function: SysLink;
19};
20export type UpsertResourceProviderProps = Omit<ResourceProviderProps, 'sys'> & {
21 sys: {
22 id: string;
23 };
24};
25export interface ResourceProvider extends ResourceProviderProps, DefaultElements<ResourceProviderProps> {
26 upsert(): Promise<ResourceProvider>;
27 delete(): Promise<void>;
28 upsertResourceType(id: string, data: UpsertResourceTypeProps): Promise<ResourceType>;
29 getResourceType(id: string): Promise<ResourceType>;
30 getResourceTypes(): Promise<CollectionProp<ResourceType>>;
31}
32/**
33 * @private
34 * @param makeRequest - function to make requests via an adapter
35 * @param data - Raw Resource Provider data
36 * @return Wrapped Resource Provider data
37 */
38export declare function wrapResourceProvider(makeRequest: MakeRequest, data: ResourceProviderProps): ResourceProvider;