Skip to content

Commit 2ac1bb2

Browse files
committed
chore: update to version 5.0.0 with cache persistence as a separate plugin
- Added support for cache persistence via the new `@contentstack/delivery-sdk-persistence` package. - Updated README to include usage instructions for cache policies requiring a persistence store. - Refactored cache handling to throw an error if `persistanceStore` is not provided when using cache policies. - Removed the old persistence implementation from the codebase. - Updated CHANGELOG for version 5.0.0 with breaking changes and enhancements.
1 parent 0b0d42c commit 2ac1bb2

29 files changed

Lines changed: 525 additions & 1165 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ test/docs/*.js
4242
test/docs/*.mjs
4343
test/docs/sanity-report*
4444
*.log
45-
.nx/
45+
.nx/
46+
delivery-sdk-persistence/

.talismanrc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
fileignoreconfig:
2+
- filename: README.md
3+
checksum: b40240271f930e1c0db9bbcf78a55bf0d52d6caf0eb265eae94d1a2aecf442c5
4+
- filename: src/lib/types.ts
5+
checksum: 0466775043773ec966f10bac2eeed812274748fc275a1017ad51295dff5c58ca
6+
- filename: test/unit/error-messages.spec.ts
7+
checksum: abe5acafad0aa0464e36b2cc3576a3200e96d7292984a93cce5f24e14a2a6366
8+
- filename: test/unit/contentstack.spec.ts
9+
checksum: 8f560efd9fba6e04682899eff3cc448d22c38019eac0a5ffcab35ba59f81da2c
10+
- filename: test/unit/cache.spec.ts
11+
checksum: a9bf179485c09e3821d78588a6bd2a57a70b68dd05948f7187c73d05b846b651
212
- filename: test/browser/import.spec.ts
313
checksum: 2e9a157e28b0ce71c4b6422c6b457996a2e6785a1ef591c8bb35276b3471a5d0
414
- filename: scripts/test-bundlers.js
@@ -13,20 +23,14 @@ fileignoreconfig:
1323
checksum: 6646595d48bfaec3d9de111b22b36cf0925b33e18df55b068181c0bb81c1862b
1424
- filename: test/browser/real-api-calls.spec.ts
1525
checksum: 514930cdde28cdc8b37ab054031260d5703dc8bdf777906dd5f9baa270ab7c3a
16-
- filename: package-lock.json
17-
checksum: e0a6679bfc6556fb7a8424c3f8eb0cec62f2cc871ad544f691fa064ddec30db7
1826
- filename: test/unit/utils.spec.ts
1927
checksum: a491df0a19c336ff5b18450fb23e26676a1798222100c946150e7a1b6504d953
20-
- filename: test/unit/contentstack.spec.ts
21-
checksum: d5b99c01459ab8bc597baaa9e6cc4aa91ac6d9bf78af08e1d0220d0c5db3d0b3
2228
- filename: test/unit/query-optimization-comprehensive.spec.ts
2329
checksum: f5aaf6c784d7c101a05ca513c584bbd6e95f963d1e42779f2596050d9bcbac96
2430
- filename: src/lib/entries.ts
2531
checksum: f6a19da15baed75062ad0cc599573ed08926e28fffe3f6e4890a0efb4d58c910
2632
- filename: src/lib/cache.ts
2733
checksum: d8d32089b8a4b247e4ba71c22b56cbb0a54440ebf35b102af222eb8032919f02
28-
- filename: test/unit/cache.spec.ts
29-
checksum: e96f913a466a1f4d55a422e7032fc2c06eeed5fea86cdcc86a05fbe3eba29b7a
3034
- filename: src/lib/query.ts
3135
checksum: 073c47e46755eb79d1d7e9fcaf2864296a218bf650888dd37c42480cce7df379
3236
- filename: test/api/retry-integration.spec.ts
@@ -52,16 +56,10 @@ fileignoreconfig:
5256
checksum: 8d67435121581d43ba9c5f544daf30a0579b7faa7c8661000d8d37ddfc172112
5357
- filename: test/unit/base-query.spec.ts
5458
checksum: ceaceb1d65965b151edc9fc11d5a226460328b1913319994df51ca1b453cd6af
55-
- filename: src/lib/entries.ts
56-
checksum: 3ffe426234ef710d0fcfd8e41ca57f61ce6bc44298ee7dde6f4530fa3c16d2ee
57-
- filename: test/unit/error-messages.spec.ts
58-
checksum: b64be136b19890aa9e9000bac7df6eb1188828ee4b740d5c756396699716c428
5959
- filename: test/api/modular-blocks.spec.ts
6060
checksum: 1e536b0409f05f2d5c1d6e87b0ec4bda2c3fde9bc4ff331406f33464a26cff55
6161
- filename: test/unit/centralized-error-handling.spec.ts
6262
checksum: 66a5eb520414bd71da331338bfb4faa2fc9f233eadf0eb18ddd7915db6849238
63-
- filename: src/lib/query.ts
64-
checksum: f7200cb6e3b9ff681439482faaf882781dfb5f6ab6fefd4c98203ba8bf30d5e6
6563
- filename: test/api/base-query-casting.specs.ts
6664
checksum: 9185df498914e2966d78d9d216acaaa910d43cd7ac9a5e9a26e7241ac9edc9b5
6765
- filename: test/reporting/generate-unified-report.js

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### Version: 5.0.0
2+
#### Date: Jan-30-2026
3+
Breaking: Cache persistence is now a separate plugin. When using a cache policy other than `IGNORE_CACHE`, you must pass `cacheOptions.persistanceStore`. Install `@contentstack/delivery-sdk-persistence` and use `new PersistanceStore({ ... })` as the store. The SDK no longer bundles persistence code or accepts `storeType` in `cacheOptions`.
4+
Enhancement: SDK defines only the `PersistanceStore` interface (getItem/setItem); full implementation lives in the plugin for a lighter core package.
5+
16
### Version: 4.11.0
27
#### Date: Jan-19-2026
38
Enhancement: Integrated getContentstackEndpoint method of Utils SDK for endpoint selection

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,31 @@ const pagedResult = await query
189189

190190
```
191191

192+
### Caching
193+
194+
To use cache policies (`CACHE_THEN_NETWORK`, `CACHE_ELSE_NETWORK`, `NETWORK_ELSE_CACHE`), you must provide a persistence store via `cacheOptions.persistanceStore`. Install the optional persistence plugin and pass a `PersistanceStore` instance:
195+
196+
```bash
197+
npm install @contentstack/delivery-sdk-persistence
198+
```
199+
200+
```typescript
201+
import contentstack, { Policy } from '@contentstack/delivery-sdk';
202+
import { PersistanceStore } from '@contentstack/delivery-sdk-persistence';
203+
204+
const stack = contentstack.stack({
205+
apiKey: 'your-api-key',
206+
deliveryToken: 'your-delivery-token',
207+
environment: 'your-environment',
208+
cacheOptions: {
209+
policy: Policy.CACHE_THEN_NETWORK,
210+
persistanceStore: new PersistanceStore({ storeType: 'localStorage', maxAge: 86400000 }),
211+
},
212+
});
213+
```
214+
215+
See [@contentstack/delivery-sdk-persistence](https://www.npmjs.com/package/@contentstack/delivery-sdk-persistence) for options (`storeType`, `maxAge`, custom storage).
216+
192217
### Helpful Links
193218

194219
- [Contentstack Website](https://www.contentstack.com)

0 commit comments

Comments
 (0)