@uniformdev/canvas-contentful 19.35.2 → 19.35.3-alpha.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +140 -0
- package/package.json +3 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ContentfulClientApi, Sys } from 'contentful';
|
|
2
|
+
import { ComponentParameterEnhancerFunction, EnhancerContext, ComponentParameter, ComponentInstance, LimitPolicy, ComponentParameterEnhancer } from '@uniformdev/canvas';
|
|
3
|
+
|
|
4
|
+
interface AddClientArgs {
|
|
5
|
+
/**
|
|
6
|
+
* The Contentful source public ID that this client maps to in the composition data.
|
|
7
|
+
* This is used to enable multiple Contentful spaces/environments as data sources.
|
|
8
|
+
* If unspecified, the client will be the default source that is used when no source public ID
|
|
9
|
+
* is in the data, or the source ID is 'default'.
|
|
10
|
+
*/
|
|
11
|
+
source?: string;
|
|
12
|
+
/** The Contentful client instance to use when fetching published data */
|
|
13
|
+
client: ContentfulClientApi;
|
|
14
|
+
/**
|
|
15
|
+
* The Contentful client instance to use when fetching preview data.
|
|
16
|
+
* If the preview client is not passed, it defaults to the client.
|
|
17
|
+
*/
|
|
18
|
+
previewClient?: ContentfulClientApi;
|
|
19
|
+
}
|
|
20
|
+
declare class ContentfulClientList {
|
|
21
|
+
private _clients;
|
|
22
|
+
constructor(clients?: AddClientArgs[] | AddClientArgs);
|
|
23
|
+
addClient({ source, client, previewClient }: AddClientArgs): void;
|
|
24
|
+
getClient({ source, isPreviewClient, }: {
|
|
25
|
+
source?: string;
|
|
26
|
+
isPreviewClient?: boolean;
|
|
27
|
+
}): ContentfulClientApi | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The default shape of the Contentful entry. Note that this can change if the query is altered. */
|
|
31
|
+
type ContentfulEntryResult<TFields> = {
|
|
32
|
+
/**
|
|
33
|
+
* The shape of the `fields` that the Contentful REST API is expected to return for this entry
|
|
34
|
+
* https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entry
|
|
35
|
+
*
|
|
36
|
+
* These should line up with the fields in your content model(s) that are allowed for this component.
|
|
37
|
+
*/
|
|
38
|
+
fields: TFields;
|
|
39
|
+
/** System fields returned by the Contentful API. If you modify the query parameters to fetch more than fields, you may get more sys data than this. */
|
|
40
|
+
sys: Partial<Pick<Sys, 'id' | 'type'>>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type EnhancerValue = ContentfulEntryResult<unknown> | ContentfulEntryResult<unknown>[] | null;
|
|
44
|
+
declare const contentfulRichTextToHtmlEnhancer: ComponentParameterEnhancerFunction<EnhancerValue>;
|
|
45
|
+
|
|
46
|
+
type EntrySelectorParameterValue = {
|
|
47
|
+
entryId: string;
|
|
48
|
+
source?: string;
|
|
49
|
+
} | string | null | undefined;
|
|
50
|
+
type CreateContentfulQueryOptions<TContext extends EnhancerContext = EnhancerContext> = {
|
|
51
|
+
/** Canvas parameter name being queried for. Not defined if using batching. */
|
|
52
|
+
parameterName?: string;
|
|
53
|
+
/** Canvas parameter value being fetched. Not defined if using batching. */
|
|
54
|
+
parameter?: ComponentParameter<EntrySelectorParameterValue>;
|
|
55
|
+
/** Component containing the parameter being fetched. Not defined if using batching. */
|
|
56
|
+
component?: ComponentInstance;
|
|
57
|
+
/** The default Contentful query expression (select fields + include 1 layer of references) */
|
|
58
|
+
defaultQuery: any;
|
|
59
|
+
/** The enhancer context provided to the enhance() function */
|
|
60
|
+
context: TContext;
|
|
61
|
+
};
|
|
62
|
+
/** The default shape of the result value of the Contentful enhancer. Note that this can change if the query is altered. */
|
|
63
|
+
type ContentfulEnhancerResult<TFields> = ContentfulEntryResult<TFields> | null;
|
|
64
|
+
type CreateContentfulEnhancerOptions = {
|
|
65
|
+
/** Either a list of Contentful clients for use with multi-space/environment-enabled Canvas projects.
|
|
66
|
+
* Or a single Contentful client for use with legacy Canvas data.*/
|
|
67
|
+
client: ContentfulClientApi | ContentfulClientList;
|
|
68
|
+
/** @deprecated Contentful client instance to use for fetching preview content.
|
|
69
|
+
* This client is _only_ relevant when the `client` property is a single Contentful client intended for use with
|
|
70
|
+
* legacy Canvas data. Conversely, if you use a `ContentfulClientList` for the `client` property, any value for `previewClient`
|
|
71
|
+
* will be ignored. To avoid deprecated use, you should switch to using a `ContentfulClientList` for the `client` property. */
|
|
72
|
+
previewClient?: ContentfulClientApi;
|
|
73
|
+
/** Creates the Contentful client's query params for specific parameters. See https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters */
|
|
74
|
+
createQuery?: (options: CreateContentfulQueryOptions) => any | undefined;
|
|
75
|
+
useBatching?: boolean;
|
|
76
|
+
limitPolicy?: LimitPolicy;
|
|
77
|
+
};
|
|
78
|
+
declare const CANVAS_CONTENTFUL_PARAMETER_TYPES: readonly string[];
|
|
79
|
+
declare function createContentfulEnhancer({ client, previewClient, createQuery, useBatching, limitPolicy, }: CreateContentfulEnhancerOptions): ComponentParameterEnhancer<EntrySelectorParameterValue, ContentfulEnhancerResult<unknown>>;
|
|
80
|
+
|
|
81
|
+
type ContentfulMultiEntryParameterValue = {
|
|
82
|
+
entries: string[];
|
|
83
|
+
source: string;
|
|
84
|
+
} | null | undefined;
|
|
85
|
+
type CreateContentfulMultiEntryQueryOptions<TContext extends EnhancerContext = EnhancerContext> = {
|
|
86
|
+
/** Canvas parameter name being queried for */
|
|
87
|
+
parameterName: string;
|
|
88
|
+
/** Canvas parameter value being fetched */
|
|
89
|
+
parameter: ComponentParameter<ContentfulMultiEntryParameterValue>;
|
|
90
|
+
/** Component containing the parameter being fetched */
|
|
91
|
+
component: ComponentInstance;
|
|
92
|
+
/** The default Contentful query expression (select fields + include 1 layer of references) */
|
|
93
|
+
defaultQuery: any;
|
|
94
|
+
/** The enhancer context provided to the enhance() function */
|
|
95
|
+
context: TContext;
|
|
96
|
+
};
|
|
97
|
+
/** The default shape of the result value of the Contentful Multi Entry enhancer. Note that this can change if the query is altered. */
|
|
98
|
+
type ContentfulMultiEntryEnhancerResult<TFields> = ContentfulEntryResult<TFields>[] | null;
|
|
99
|
+
type CreateContentfulMultiEntryEnhancerOptions = {
|
|
100
|
+
/** Either a list of Contentful clients for use with multi-space/environment-enabled Canvas projects. */
|
|
101
|
+
clients: ContentfulClientList;
|
|
102
|
+
/** Creates the Contentful client's query params for specific parameters. See https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters */
|
|
103
|
+
createQuery?: (options: CreateContentfulMultiEntryQueryOptions) => any | undefined;
|
|
104
|
+
limitPolicy?: LimitPolicy;
|
|
105
|
+
};
|
|
106
|
+
declare const CANVAS_CONTENTFUL_MULTI_PARAMETER_TYPES: readonly string[];
|
|
107
|
+
declare function createContentfulMultiEnhancer({ clients, createQuery, limitPolicy, }: CreateContentfulMultiEntryEnhancerOptions): ComponentParameterEnhancer<ContentfulMultiEntryParameterValue, ContentfulMultiEntryEnhancerResult<unknown>>;
|
|
108
|
+
|
|
109
|
+
declare const CANVAS_CONTENTFUL_QUERY_PARAMETER_TYPES: readonly string[];
|
|
110
|
+
type ContentfulQueryParameterValue = {
|
|
111
|
+
source: string;
|
|
112
|
+
contentType: string;
|
|
113
|
+
count: number;
|
|
114
|
+
sortBy?: string;
|
|
115
|
+
sortOrder?: 'asc' | 'desc';
|
|
116
|
+
} | null | undefined;
|
|
117
|
+
/** The default shape of the result value of the Contentful Query enhancer. Note that this can change if the query is altered. */
|
|
118
|
+
type ContentfulQueryEnhancerResult<TFields> = ContentfulEntryResult<TFields>[] | null;
|
|
119
|
+
type CreateContentfulQueryApiQueryOptions<TContext extends EnhancerContext = EnhancerContext> = {
|
|
120
|
+
/** Canvas parameter name being queried for */
|
|
121
|
+
parameterName: string;
|
|
122
|
+
/** Canvas parameter value being fetched */
|
|
123
|
+
parameter: ComponentParameter<ContentfulQueryParameterValue>;
|
|
124
|
+
/** Component containing the parameter being fetched */
|
|
125
|
+
component: ComponentInstance;
|
|
126
|
+
/** The default Contentful query expression (select fields + include 1 layer of references) */
|
|
127
|
+
defaultQuery: any;
|
|
128
|
+
/** The enhancer context provided to the enhance() function */
|
|
129
|
+
context: TContext;
|
|
130
|
+
};
|
|
131
|
+
type CreateContentfulQueryEnhancerOptions = {
|
|
132
|
+
/** Either a list of Contentful clients for use with multi-space/environment-enabled Canvas projects. */
|
|
133
|
+
clients: ContentfulClientList;
|
|
134
|
+
/** Creates the Contentful client's query params for specific parameters. See https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters */
|
|
135
|
+
createQuery?: (options: CreateContentfulQueryApiQueryOptions) => any | undefined;
|
|
136
|
+
limitPolicy?: LimitPolicy;
|
|
137
|
+
};
|
|
138
|
+
declare function createContentfulQueryEnhancer({ clients, createQuery, limitPolicy, }: CreateContentfulQueryEnhancerOptions): ComponentParameterEnhancer<ContentfulQueryParameterValue, ContentfulQueryEnhancerResult<unknown>>;
|
|
139
|
+
|
|
140
|
+
export { AddClientArgs, CANVAS_CONTENTFUL_MULTI_PARAMETER_TYPES, CANVAS_CONTENTFUL_PARAMETER_TYPES, CANVAS_CONTENTFUL_QUERY_PARAMETER_TYPES, ContentfulClientList, ContentfulEnhancerResult, ContentfulMultiEntryEnhancerResult, ContentfulMultiEntryParameterValue, ContentfulQueryEnhancerResult, ContentfulQueryParameterValue, CreateContentfulEnhancerOptions, CreateContentfulMultiEntryEnhancerOptions, CreateContentfulMultiEntryQueryOptions, CreateContentfulQueryApiQueryOptions, CreateContentfulQueryEnhancerOptions, CreateContentfulQueryOptions, EntrySelectorParameterValue, contentfulRichTextToHtmlEnhancer, createContentfulEnhancer, createContentfulMultiEnhancer, createContentfulQueryEnhancer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-contentful",
|
|
3
|
-
"version": "19.35.
|
|
3
|
+
"version": "19.35.3-alpha.82+4bc341093",
|
|
4
4
|
"description": "Contentful data enhancers for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"document": "api-extractor run --local"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@uniformdev/canvas": "19.35.
|
|
27
|
+
"@uniformdev/canvas": "19.35.3-alpha.82+4bc341093"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@contentful/rich-text-html-renderer": ">= 14",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "4bc341093bc946900df2646fe53eca4bcddc693c"
|
|
44
44
|
}
|