File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,24 @@ export * as Utils from '@contentstack/utils';
31
31
*/
32
32
// eslint-disable-next-line @typescript-eslint/naming-convention
33
33
export function Stack ( config : StackConfig ) : StackClass {
34
- const defaultConfig = {
34
+ let defaultConfig = {
35
35
defaultHostname : 'cdn.contentstack.io' ,
36
36
headers : { } as AxiosRequestHeaders ,
37
37
params : { } as any ,
38
+ live_preview : { } as any
38
39
} ;
39
40
41
+ if ( config . live_preview ?. enable === true ) {
42
+ if ( config . live_preview ?. management_token != null && config . live_preview ?. preview_token == null ) {
43
+ config . host = 'api.contentstack.com'
44
+ config . live_preview . host = config . host
45
+ } else if ( config . live_preview ?. preview_token != null && config . live_preview ?. management_token == null ) {
46
+ config . host = 'rest-preview.contentstack.com'
47
+ config . live_preview . host = config . host
48
+ }
49
+ } else config . host = defaultConfig . defaultHostname
50
+ defaultConfig . live_preview = config . live_preview
51
+
40
52
defaultConfig . defaultHostname = getHost ( config . region , config . host ) ;
41
53
42
54
if ( config . apiKey ) {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export interface StackConfig extends HttpClientParams {
20
20
plugins ?: any [ ] ;
21
21
logHandler ?: ( level : string , data : any ) => void ;
22
22
cacheOptions ?: CacheOptions ;
23
+ live_preview ?: LivePreview ;
23
24
}
24
25
export interface CacheOptions extends PersistanceStoreOptions {
25
26
policy : Policy ;
@@ -254,3 +255,19 @@ export interface FindResponse<T> {
254
255
global_fields ?: T [ ] ;
255
256
count ?: number
256
257
}
258
+
259
+ export interface LivePreviewQuery {
260
+ live_preview : string
261
+ contentTypeUid : string
262
+ entryUid ?: any ;
263
+ }
264
+
265
+ export type LivePreview = {
266
+ live_preview ?: string ;
267
+ contentTypeUid ?: string ;
268
+ entryUid ?: any ;
269
+ host ?: string ;
270
+ enable : boolean ;
271
+ management_token ?: string ;
272
+ preview_token ?: string ;
273
+ }
You can’t perform that action at this time.
0 commit comments