Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ JavaScript library for the Contentful [Content Delivery API](https://www.content
- [Authentication](#authentication)
- [Documentation \& References](#documentation--references)
- [Configuration](#configuration)
- [Request configuration options](#request-configuration-options)
- [Response configuration options](#response-configuration-options)
- [Request configuration options](#request-configuration-options)
- [Response configuration options](#response-configuration-options)
- [Timeline Preview](#timeline-preview)
- [Example](#example)
- [Client chain modifiers](#client-chain-modifiers)
- [Entries](#entries)
- [Example](#example)
- [Assets](#assets)
- [Example](#example-1)
- [Sync](#sync)
- [Assets](#assets)
- [Example](#example-2)
- [Sync](#sync)
- [Example](#example-3)
- [Reference documentation](#reference-documentation)
- [Tutorials \& other resources](#tutorials--other-resources)
- [Troubleshooting](#troubleshooting)
Expand Down Expand Up @@ -292,11 +294,9 @@ const client = contentful.createClient({
accessToken: 'preview_0b7f6x59a0',
host: 'preview.contentful.com',
// either release or timestamp or both can be passed as a valid config
alphaFeatures: {
timelinePreview: {
release: { lte: 'black-friday' },
timestamp: { lte: '2025-11-29T08:46:15Z' },
},
timelinePreview: {
release: { lte: 'black-friday' },
timestamp: { lte: '2025-11-29T08:46:15Z' },
},
})
```
Expand Down
13 changes: 12 additions & 1 deletion lib/contentful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
* @param level - Log level, e.g. error, warning, or info
* @param data - Log data
*/
logHandler?: (level: ClientLogLevel, data?: Record<string, any> | string) => void

Check warning on line 99 in lib/contentful.ts

View workflow job for this annotation

GitHub Actions / check / lint

Unexpected any. Specify a different type

Check warning on line 99 in lib/contentful.ts

View workflow job for this annotation

GitHub Actions / check / test

Unexpected any. Specify a different type
/**
* connection timeout in milliseconds (default:30000)
*/
Expand All @@ -113,7 +113,7 @@
/**
* Interceptor called on every response. Takes Axios response object as an arg.
*/
responseLogger?: (response: AxiosResponse<any> | Error) => unknown

Check warning on line 116 in lib/contentful.ts

View workflow job for this annotation

GitHub Actions / check / lint

Unexpected any. Specify a different type

Check warning on line 116 in lib/contentful.ts

View workflow job for this annotation

GitHub Actions / check / test

Unexpected any. Specify a different type
/**
* Enable Content Source Maps.
* @remarks
Expand All @@ -121,6 +121,14 @@
*/
includeContentSourceMaps?: boolean

/**
* Enable Timeline Preview.
*
* @remarks
* This feature is only available when using the Content Preview API.
*/
timelinePreview?: TimelinePreview

/**
* Enable alpha features.
*/
Expand All @@ -132,8 +140,11 @@

/**
* Enable Timeline Preview.
*
* @remarks
* This feature is only available in private beta when using the Content Preview API.
* This feature is only available when using the Content Preview API.
*
* @deprecated Use the `timelinePreview` option directly instead.
*/
timelinePreview?: TimelinePreview
}
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/timeline-preview-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const isValidTimelinePreviewConfig = (timelinePreview: TimelinePreview) =

export const getTimelinePreviewParams = (params: CreateClientParams) => {
const host = params?.host as string
const timelinePreview = params?.alphaFeatures?.timelinePreview as TimelinePreview
const timelinePreview =
params?.timelinePreview ?? (params?.alphaFeatures?.timelinePreview as TimelinePreview)
const enabled = checkEnableTimelinePreviewIsAllowed(host, timelinePreview)
return { enabled, timelinePreview }
}
5 changes: 2 additions & 3 deletions test/integration/getEntry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,8 @@ test('Gets entry with attached metadata and field called "metadata" on preview',
test('can make calls to TimelinePreview API on preview', async () => {
const timelinePreviewClient = contentful.createClient({
...previewParamsWithCSM,
alphaFeatures: {
timelinePreview: { release: { lte: 'black-friday' } },
},

timelinePreview: { release: { lte: 'black-friday' } },
})

const entryWithMetadataFieldAndMetadata = '1NnAC4eF9IRMpHtFB1NleW'
Expand Down
9 changes: 4 additions & 5 deletions test/unit/timeline-preview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ describe('Timeline Preview path and query', () => {
get: mockGet,
httpClientParams: {
host: 'preview.contentful.com',
alphaFeatures: {
timelinePreview: {
release: { lte: 'black-friday' },
timestamp: { lte: '2023-11-30T23:59:59Z' },
},

timelinePreview: {
release: { lte: 'black-friday' },
timestamp: { lte: '2023-11-30T23:59:59Z' },
},
},
} as unknown as AxiosInstance
Expand Down
Loading