Skip to content

Commit a4f5485

Browse files
committed
refactor: reorganize file structure and enhance caching functionality
- Updated file paths in .talismanrc to reflect new directory structure. - Introduced new classes for asset management and image transformation in the src/assets directory. - Added caching utilities and error messages to improve cache handling. - Enhanced README with updated instructions for cache policies and persistence store usage. - Updated CHANGELOG to reflect changes in caching and file structure adjustments.
1 parent a1746df commit a4f5485

89 files changed

Lines changed: 286 additions & 266 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.talismanrc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
fileignoreconfig:
22
- filename: README.md
33
checksum: b40240271f930e1c0db9bbcf78a55bf0d52d6caf0eb265eae94d1a2aecf442c5
4-
- filename: src/lib/types.ts
5-
checksum: 0466775043773ec966f10bac2eeed812274748fc275a1017ad51295dff5c58ca
64
- filename: test/unit/error-messages.spec.ts
7-
checksum: abe5acafad0aa0464e36b2cc3576a3200e96d7292984a93cce5f24e14a2a6366
5+
checksum: 186390727b2488317c49f22955ade58b454d4c00c6b850bbb0617c30c59f8255
6+
- filename: src/common/types.ts
7+
checksum: 0466775043773ec966f10bac2eeed812274748fc275a1017ad51295dff5c58ca
88
- filename: test/unit/contentstack.spec.ts
99
checksum: 8f560efd9fba6e04682899eff3cc448d22c38019eac0a5ffcab35ba59f81da2c
1010
- filename: test/unit/cache.spec.ts
@@ -27,11 +27,11 @@ fileignoreconfig:
2727
checksum: a491df0a19c336ff5b18450fb23e26676a1798222100c946150e7a1b6504d953
2828
- filename: test/unit/query-optimization-comprehensive.spec.ts
2929
checksum: f5aaf6c784d7c101a05ca513c584bbd6e95f963d1e42779f2596050d9bcbac96
30-
- filename: src/lib/entries.ts
30+
- filename: src/entries/entries.ts
3131
checksum: f6a19da15baed75062ad0cc599573ed08926e28fffe3f6e4890a0efb4d58c910
32-
- filename: src/lib/cache.ts
32+
- filename: src/cache/cache.ts
3333
checksum: d8d32089b8a4b247e4ba71c22b56cbb0a54440ebf35b102af222eb8032919f02
34-
- filename: src/lib/query.ts
34+
- filename: src/query/query.ts
3535
checksum: 073c47e46755eb79d1d7e9fcaf2864296a218bf650888dd37c42480cce7df379
3636
- filename: test/api/retry-integration.spec.ts
3737
checksum: dc07b0a8111fd8e155b99f56c31ccdddd4f46c86f1b162b17d73e15dfed8e3c8
@@ -40,19 +40,19 @@ fileignoreconfig:
4040
- filename: package-lock.json
4141
checksum: 993afd503e9f5d399fac30ae230cb47538cec2c61c5364e88be72726fb723dda
4242
ignore_detectors: [ base64, filecontent ]
43-
- filename: src/lib/global-field.ts
43+
- filename: src/global-field/global-field.ts
4444
checksum: 70b9652bcba16ddc4d853ac212ad909a8ecfc76f491c55a05e4e3cdf9ce476b5
45-
- filename: src/lib/content-type.ts
45+
- filename: src/content-type/content-type.ts
4646
checksum: 1dc0fa53ae209efb67d68a01493822e9dec560799f8309329213dae69459655f
47-
- filename: src/lib/stack.ts
47+
- filename: src/stack/stack.ts
4848
checksum: 145dd6add876a771a9a6ba024f57ef2c4b46a911fe1bf3885a69cf1f6c9dd72d
49-
- filename: src/lib/entry.ts
49+
- filename: src/entries/entry.ts
5050
checksum: 1c64ccf19226873d068d6896028bfb74546c1cfd993779515bccfcc747180ca0
51-
- filename: src/lib/error-messages.ts
51+
- filename: src/common/error-messages.ts
5252
checksum: 3b960af19f3ba302522e912616b147b11d63dfe3f7ad2e0cf2de807815ee236a
53-
- filename: src/lib/global-field-query.ts
53+
- filename: src/query/global-field-query.ts
5454
checksum: 824c54061b80236380e776640e7f52f45164230bcc0ee88de302b30e9f83297f
55-
- filename: src/lib/base-query.ts
55+
- filename: src/query/base-query.ts
5656
checksum: 8d67435121581d43ba9c5f544daf30a0579b7faa7c8661000d8d37ddfc172112
5757
- filename: test/unit/base-query.spec.ts
5858
checksum: ceaceb1d65965b151edc9fc11d5a226460328b1913319994df51ca1b453cd6af

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### 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.
2+
#### Date: Feb-16-2026
3+
Breaking: Cache persistence is now a separate plugin. When using a cache policy other than `IGNORE_CACHE`, you must pass `cacheOptions.persistenceStore`. Install `@contentstack/persistence-plugin` and use `new PersistenceStore({ ... })` as the store. The SDK no longer bundles persistence code or accepts `storeType` in `cacheOptions`.
4+
Enhancement: SDK defines only the `PersistenceStore` interface (getItem/setItem); full implementation lives in the plugin for a lighter core package.
55

66
### Version: 4.11.0
77
#### Date: Jan-19-2026

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,28 +191,28 @@ const pagedResult = await query
191191

192192
### Caching
193193

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:
194+
To use cache policies (`CACHE_THEN_NETWORK`, `CACHE_ELSE_NETWORK`, `NETWORK_ELSE_CACHE`), you must provide a persistence store via `cacheOptions.persistenceStore`. Install the optional persistence plugin and pass a `PersistenceStore` instance:
195195

196196
```bash
197-
npm install @contentstack/delivery-sdk-persistence
197+
npm install @contentstack/persistence-plugin
198198
```
199199

200200
```typescript
201201
import contentstack, { Policy } from '@contentstack/delivery-sdk';
202-
import { PersistanceStore } from '@contentstack/delivery-sdk-persistence';
202+
import { PersistenceStore } from '@contentstack/persistence-plugin';
203203

204204
const stack = contentstack.stack({
205205
apiKey: 'your-api-key',
206206
deliveryToken: 'your-delivery-token',
207207
environment: 'your-environment',
208208
cacheOptions: {
209209
policy: Policy.CACHE_THEN_NETWORK,
210-
persistanceStore: new PersistanceStore({ storeType: 'localStorage', maxAge: 86400000 }),
210+
persistenceStore: new PersistenceStore({ storeType: 'localStorage', maxAge: 86400000 }),
211211
},
212212
});
213213
```
214214

215-
See [@contentstack/delivery-sdk-persistence](https://www.npmjs.com/package/@contentstack/delivery-sdk-persistence) for options (`storeType`, `maxAge`, custom storage).
215+
See [@contentstack/persistence-plugin](https://www.npmjs.com/package/@contentstack/persistence-plugin) for options (`storeType`, `maxAge`, custom storage).
216216

217217
### Development
218218

@@ -226,7 +226,7 @@ When contributing or running tests from the repository, run `npm run build` befo
226226

227227
### The MIT License (MIT)
228228

229-
Copyright © 2012-2025 [Contentstack](https://www.contentstack.com). All Rights Reserved
229+
Copyright © 2012-2026 [Contentstack](https://www.contentstack.com). All Rights Reserved
230230

231231
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
232232

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/validate-browser-safe.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* Usage: node scripts/validate-browser-safe.js
1010
*/
1111

12-
const fs = require('fs');
13-
const path = require('path');
12+
import fs from 'fs';
13+
import path from 'path';
14+
import { fileURLToPath } from 'url';
15+
16+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1417

1518
// ANSI color codes for pretty output
1619
const colors = {
File renamed without changes.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable @cspell/spellchecker */
2-
import './string-extensions';
32
import {
43
CanvasBy,
54
CropBy,
@@ -10,7 +9,7 @@ import {
109
OverlayRepeat,
1110
ResizeFilter,
1211
TransformData,
13-
} from './types';
12+
} from '../common/types';
1413

1514
export class ImageTransform {
1615
obj: TransformData = {};

src/assets/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Asset } from './asset';
2+
export { ImageTransform } from './image-transform';

src/lib/cache.ts renamed to src/cache/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CacheOptions, Policy } from './types';
2-
import { ErrorMessages } from './error-messages';
1+
import { CacheOptions, Policy } from '../common/types';
2+
import { ErrorMessages } from '../common/error-messages';
33

44
/**
55
* Extracts entry UID from request URL if available
@@ -55,10 +55,10 @@ export async function handleRequest(
5555
reject: any,
5656
config: any
5757
) {
58-
if (!cacheOptions.persistanceStore) {
59-
throw new Error(ErrorMessages.MISSING_PERSISTANCE_STORE);
58+
if (!cacheOptions.persistenceStore) {
59+
throw new Error(ErrorMessages.MISSING_PERSISTENCE_STORE);
6060
}
61-
const cacheStore = cacheOptions.persistanceStore;
61+
const cacheStore = cacheOptions.persistenceStore;
6262

6363
// Extract entry UID from URL or config
6464
const entryUid = config.entryUid || extractEntryUidFromUrl(config);
@@ -133,4 +133,4 @@ export async function handleRequest(
133133
}
134134
}
135135
}
136-
}
136+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export const ErrorMessages = {
1515
INVALID_ARGUMENT_STRING_OR_ARRAY: 'Invalid argument. Provide a string or an array and try again.',
1616

1717
// Cache persistence errors
18-
MISSING_PERSISTANCE_STORE:
19-
'Cache policy requires cacheOptions.persistanceStore (storage). Install @contentstack/delivery-sdk-persistence and pass a PersistanceStore instance and try again.',
18+
MISSING_PERSISTENCE_STORE:
19+
'Cache policy requires cacheOptions.persistenceStore (storage). Install @contentstack/persistence-plugin and pass a PersistenceStore instance and try again.',
2020

2121
// Regex validation errors
2222
INVALID_REGEX_PATTERN: 'Invalid regexPattern: Must be a valid regular expression',
@@ -41,4 +41,3 @@ export enum ErrorCode {
4141
INVALID_REGEX = 'INVALID_REGEX',
4242
SLACK_ERROR = 'SLACK_ERROR',
4343
}
44-

0 commit comments

Comments
 (0)