contentful 11.9.0 → 11.10.1
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/README.md +30 -5
- package/dist/contentful.browser.js +321 -213
- package/dist/contentful.browser.min.js +1 -1
- package/dist/contentful.cjs +85 -4
- package/dist/esm/contentful.js +1 -1
- package/dist/esm/create-contentful-api.js +13 -1
- package/dist/esm/utils/normalize-cursor-pagination-parameters.js +9 -0
- package/dist/esm/utils/normalize-cursor-pagination-response.js +23 -0
- package/dist/stats-browser-min.html +1 -1
- package/dist/types/types/asset.d.ts +9 -1
- package/dist/types/types/client.d.ts +48 -3
- package/dist/types/types/collection.d.ts +36 -9
- package/dist/types/types/concept-scheme.d.ts +2 -11
- package/dist/types/types/concept.d.ts +2 -11
- package/dist/types/types/entry.d.ts +16 -1
- package/dist/types/types/query/query.d.ts +28 -4
- package/dist/types/utils/normalize-cursor-pagination-parameters.d.ts +5 -0
- package/dist/types/utils/normalize-cursor-pagination-response.d.ts +2 -0
- package/package.json +5 -7
package/README.md
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
<a href="LICENSE">
|
|
32
32
|
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License" />
|
|
33
33
|
</a>
|
|
34
|
-
<a href="https://
|
|
35
|
-
<img src="https://
|
|
34
|
+
<a href="https://github.com/contentful/contentful.js/actions?query=branch%3Amaster">
|
|
35
|
+
<img src="https://github.com/contentful/contentful.js/actions/workflows/main.yaml/badge.svg">
|
|
36
36
|
</a>
|
|
37
37
|
<a href="https://www.npmjs.com/package/contentful">
|
|
38
38
|
<img src="https://img.shields.io/npm/v/contentful.svg" alt="NPM">
|
|
@@ -68,12 +68,13 @@ JavaScript library for the Contentful [Content Delivery API](https://www.content
|
|
|
68
68
|
- [Your first request](#your-first-request)
|
|
69
69
|
- [Using this library with the Preview API](#using-this-library-with-the-preview-api)
|
|
70
70
|
- [Authentication](#authentication)
|
|
71
|
+
- [Cursor-based Pagination](#cursor-based-pagination)
|
|
71
72
|
- [Documentation \& References](#documentation--references)
|
|
72
73
|
- [Configuration](#configuration)
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
- [Request configuration options](#request-configuration-options)
|
|
75
|
+
- [Response configuration options](#response-configuration-options)
|
|
75
76
|
- [Timeline Preview](#timeline-preview)
|
|
76
|
-
|
|
77
|
+
- [Example](#example)
|
|
77
78
|
- [Client chain modifiers](#client-chain-modifiers)
|
|
78
79
|
- [Entries](#entries)
|
|
79
80
|
- [Example](#example-1)
|
|
@@ -135,6 +136,7 @@ In order to get started with the Contentful JS library you'll need not only to i
|
|
|
135
136
|
- [Your first request](#your-first-request)
|
|
136
137
|
- [Using this library with the Preview API](#using-this-library-with-the-preview-api)
|
|
137
138
|
- [Authentication](#authentication)
|
|
139
|
+
- [Cursor-based pagination](#cursor-based-pagination)
|
|
138
140
|
- [Documentation & References](#documentation--references)
|
|
139
141
|
|
|
140
142
|
### Installation
|
|
@@ -229,6 +231,29 @@ Don't forget to also get your Space ID.
|
|
|
229
231
|
|
|
230
232
|
For more information, check the [Contentful REST API reference on Authentication](https://www.contentful.com/developers/docs/references/authentication/).
|
|
231
233
|
|
|
234
|
+
### Cursor-based Pagination
|
|
235
|
+
|
|
236
|
+
Cursor-based pagination is supported on collection endpoints for entries and assets:
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
const response = await client.getEntriesWithCursor({ limit: 10 })
|
|
240
|
+
console.log(response.items) // Array of items
|
|
241
|
+
console.log(response.pages?.next) // Cursor for next page
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Use the value from `response.pages.next` to fetch the next page or `response.pages.prev` to fetch the previous page.
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
const nextPageResponse = await client.getEntriesWithCursor({
|
|
248
|
+
limit: 10,
|
|
249
|
+
pageNext: response.pages?.next,
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
console.log(nextPageResponse.items) // Array of items
|
|
253
|
+
console.log(nextPageResponse.pages?.next) // Cursor for next page
|
|
254
|
+
console.log(nextPageResponse.pages?.prev) // Cursor for prev page
|
|
255
|
+
```
|
|
256
|
+
|
|
232
257
|
## Documentation & References
|
|
233
258
|
|
|
234
259
|
- [Configuration](#configuration)
|