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';
3131 */
3232// eslint-disable-next-line @typescript-eslint/naming-convention
3333export function Stack ( config : StackConfig ) : StackClass {
34- const defaultConfig = {
34+ let defaultConfig = {
3535 defaultHostname : 'cdn.contentstack.io' ,
3636 headers : { } as AxiosRequestHeaders ,
3737 params : { } as any ,
38+ live_preview : { } as any
3839 } ;
3940
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+
4052 defaultConfig . defaultHostname = getHost ( config . region , config . host ) ;
4153
4254 if ( config . apiKey ) {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export interface StackConfig extends HttpClientParams {
2020 plugins ?: any [ ] ;
2121 logHandler ?: ( level : string , data : any ) => void ;
2222 cacheOptions ?: CacheOptions ;
23+ live_preview ?: LivePreview ;
2324}
2425export interface CacheOptions extends PersistanceStoreOptions {
2526 policy : Policy ;
@@ -254,3 +255,19 @@ export interface FindResponse<T> {
254255 global_fields ?: T [ ] ;
255256 count ?: number
256257}
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