Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fe0fda6
refactor: update package dependencies and improve stack configuration
nadeem-cs Sep 4, 2025
3094bc1
chore: update to version 4.10.1 and upgrade dependencies
harshithad0703 Oct 27, 2025
3ad6219
Merge pull request #244 from contentstack/fix/upgrade-utils-dependency
harshithad0703 Oct 27, 2025
f30269d
Merge pull request #245 from contentstack/staging
harshithad0703 Oct 27, 2025
a48ed73
feat: Update package dependencies and add postinstall/postupdate scripts
nadeem-cs Oct 28, 2025
4a9ef4d
feat: update regions.json paths and add copying logic in build process
nadeem-cs Oct 28, 2025
d331cf7
Merge branch 'development' into enhancement/endpoints-region
nadeem-cs Oct 28, 2025
f2594bd
chore: update axios version to 1.13.1 in package.json and package-loc…
nadeem-cs Oct 28, 2025
4eea354
Merge pull request #250 from contentstack/enhancement/endpoints-region
nadeem-cs Oct 29, 2025
7bdae12
Merge branch 'staging' into fix/conflicts
harshithad0703 Oct 29, 2025
501c78e
Merge pull request #252 from contentstack/fix/conflicts
harshithad0703 Oct 29, 2025
a4770be
Merge pull request #251 from contentstack/development
harshithad0703 Oct 29, 2025
2189a38
Merge pull request #254 from contentstack/main
harshithad0703 Oct 29, 2025
80d26ec
feat: implement download script for regions.json and update postinsta…
nadeem-cs Oct 29, 2025
daae12d
Merge pull request #255 from contentstack/enhancement/endpoints-region
nadeem-cs Oct 29, 2025
071b808
Merge pull request #256 from contentstack/development
nadeem-cs Oct 29, 2025
4901c15
improve coverage reports
harshithad0703 Oct 31, 2025
139f5fe
add unit tests for AssetQuery, Asset, BaseQuery, Cache, ContentType, …
harshithad0703 Oct 31, 2025
f7bce9c
add unit tests for Contentstack caching behavior
harshithad0703 Oct 31, 2025
5d6703b
add unit tests for test coverage
harshithad0703 Nov 1, 2025
be78783
Merge pull request #258 from contentstack/fix/dx-3674-improve-testcas…
harshithad0703 Nov 5, 2025
1d6fe87
Revert "feat: implement download script for regions.json and update p…
nadeem-cs Nov 5, 2025
3e11d29
Merge pull request #259 from contentstack/revert-255-enhancement/endp…
nadeem-cs Nov 5, 2025
1508842
Enh: add type casting helper for BaseQuery methods to return Query type
sunil-lakshman Nov 5, 2025
5a465b2
Added console.error mock to suppress the error output
sunil-lakshman Nov 6, 2025
ffbbd17
Updated package-lock file
sunil-lakshman Nov 6, 2025
f521bd7
refactor: region handling logic to utilize getContentstackEndpoint. …
nadeem-cs Nov 12, 2025
ea7f79a
fix: update default region handling in stack function and improve err…
nadeem-cs Nov 12, 2025
329b2a2
Merge pull request #262 from contentstack/enh/set-region-using-getCon…
nadeem-cs Nov 12, 2025
ab59edb
chore: :wastebasket: remove redundant code
nadeem-cs Nov 12, 2025
c1cef7a
Merge pull request #264 from contentstack/enh/set-region-using-getCon…
nadeem-cs Nov 12, 2025
53df972
Merge pull request #260 from contentstack/enh/dx-3226
harshithad0703 Nov 12, 2025
b578029
upgrade dependencies
harshithad0703 Nov 12, 2025
74b1714
Merge pull request #265 from contentstack/fix/update-dependency
harshithad0703 Nov 12, 2025
1d6aaea
fix version bump
harshithad0703 Nov 12, 2025
7d8dce1
Merge pull request #266 from contentstack/fix/version-bump
nadeem-cs Nov 12, 2025
da13ea9
Merge pull request #263 from contentstack/development
harshithad0703 Nov 12, 2025
f3bcca3
Merge pull request #253 from contentstack/staging
harshithad0703 Nov 12, 2025
6031f9d
fix: reverts the endpoints helper method integration
nadeem-cs Nov 13, 2025
da1994e
Merge branch 'main' into fix/revert-endpoints-integration
nadeem-cs Nov 13, 2025
78e499d
fix: revert core package version
nadeem-cs Nov 13, 2025
85d5962
Merge pull request #267 from contentstack/fix/revert-endpoints-integr…
nadeem-cs Nov 13, 2025
7750739
fix: bump @contentstack/core version to ^1.3.4
nadeem-cs Dec 15, 2025
661ffb8
fix: bump version to 4.10.4 and update changelog
nadeem-cs Dec 15, 2025
8c36173
Merge pull request #279 from contentstack/build/core-pkg-version-bump
harshithad0703 Dec 15, 2025
e0931a4
chore: update package-lock
nadeem-cs Dec 15, 2025
3ec2892
Merge branch 'main' into build/core-pkg-version-bump
harshithad0703 Dec 15, 2025
6e35513
fix: add dependencies to various packages in package-lock.json
harshithad0703 Dec 15, 2025
2373e27
Merge pull request #282 from contentstack/build/core-pkg-version-bump
harshithad0703 Dec 15, 2025
19aa8d5
Merge branch 'main' into feat/dx-3797-update-taxonomy-api
harshithad0703 Dec 15, 2025
13fa7d9
refactor: update API endpoints from /taxonomy-manager to /taxonomies
harshithad0703 Dec 15, 2025
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
26 changes: 26 additions & 0 deletions .github/workflows/coverage-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'TS SDK - Unit Testing'

on:
pull_request:
branches:
- development
- staging
- main

jobs:
coverage:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
checks: write

steps:
- uses: actions/checkout@v4

- name: Run unit tests with coverage
uses: ArtiomTr/jest-coverage-report-action@v2
id: coverage
with:
test-script: npm run test:unit
threshold: 95
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ coverage
.dccache
dist/*
*.log
.nx/
.nx/
6 changes: 5 additions & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
fileignoreconfig:
- filename: package-lock.json
checksum: 32308dbe614c142c4804ff7c81baedddba058c5458e1d233fefb1d8070bf1905
checksum: cb21e1b4fc8240b8ee33c6f974a9d1cf25d96afb9161c85633cbb061f069bbc4
- filename: test/unit/contentstack.spec.ts
checksum: d5b99c01459ab8bc597baaa9e6cc4aa91ac6d9bf78af08e1d0220d0c5db3d0b3
- filename: test/unit/utils.spec.ts
checksum: 79ce5bd78376db37a34df82c0fea19031e995b66a5a246e73f8262fa05d65a9c
- filename: test/unit/query-optimization-comprehensive.spec.ts
checksum: f5aaf6c784d7c101a05ca513c584bbd6e95f963d1e42779f2596050d9bcbac96
- filename: src/lib/entries.ts
Expand Down
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
### Version: 4.10.1
#### Date: Oct-01-2025
### Version: 4.10.2
#### Date: Dec-15-2025
Build: bump @contentstack/core version to ^1.3.4

### Version: 4.10.3
#### Date: Nov-13-2025
Fix: reverts the endpoints helper method integration

### Version: 4.10.2
#### Date: Nov-12-2025
Enhancement: Added logHandler interceptors for request and response logging
Enhancement: Upgraded @contentstack/utils dependency to version 1.6.2
Refactor: Replaced region handling logic to use getContentstackEndpoint from @contentstack/utils

### Version: 4.10.1
#### Date: Oct-27-2025
Fix: Upgrade dependecies

### Version: 4.10.0
#### Date: Sep-22-2025
Expand Down
1,527 changes: 600 additions & 927 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/delivery-sdk",
"version": "4.10.1",
"version": "4.10.4",
"type": "module",
"license": "MIT",
"main": "./dist/legacy/index.cjs",
Expand Down Expand Up @@ -35,9 +35,9 @@
"husky-check": "npm run build && husky && chmod +x .husky/pre-commit"
},
"dependencies": {
"@contentstack/core": "^1.3.0",
"@contentstack/utils": "^1.4.1",
"axios": "^1.12.2",
"@contentstack/core": "^1.3.4",
"@contentstack/utils": "1.5.0",
"axios": "^1.13.1",
"humps": "^2.0.1"
},
"files": [
Expand Down
57 changes: 33 additions & 24 deletions src/lib/base-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AxiosInstance, getData } from '@contentstack/core';
import { Pagination } from './pagination';
import { FindResponse, params } from './types';
import { encodeQueryParams } from './utils';
import type { Query } from './query';

export class BaseQuery extends Pagination {
_parameters: params = {}; // Params of query class ?query={}
Expand All @@ -10,6 +11,14 @@ export class BaseQuery extends Pagination {
protected _urlPath!: string;
protected _variants!: string;

/**
* Helper method to cast this instance to Query type
* @private
*/
protected asQuery(): Query {
return this as unknown as Query;
}

/**
* @method includeCount
* @memberof BaseQuery
Expand All @@ -23,12 +32,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().includeCount().find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
includeCount(): BaseQuery {
includeCount(): Query {
this._queryParams.include_count = 'true';

return this;
return this.asQuery();
}

/**
Expand All @@ -44,12 +53,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().orderByAscending().find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
orderByAscending(key: string): BaseQuery {
orderByAscending(key: string): Query {
this._queryParams.asc = key;

return this;
return this.asQuery();
}

/**
Expand All @@ -65,12 +74,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().orderByDescending().find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
orderByDescending(key: string): BaseQuery {
orderByDescending(key: string): Query {
this._queryParams.desc = key;

return this;
return this.asQuery();
}

/**
Expand All @@ -86,12 +95,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().limit(5).find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
limit(key: number): BaseQuery {
limit(key: number): Query {
this._queryParams.limit = key;

return this;
return this.asQuery();
}

/**
Expand All @@ -107,12 +116,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().skip(5).find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
skip(key: number): BaseQuery {
skip(key: number): Query {
this._queryParams.skip = key;

return this;
return this.asQuery();
}


Expand All @@ -130,12 +139,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().param("key", "value").find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
param(key: string, value: string | number): BaseQuery {
param(key: string, value: string | number): Query {
this._queryParams[key] = value;

return this;
return this.asQuery();
}

/**
Expand All @@ -151,12 +160,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().addParams({"key": "value"}).find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
addParams(paramObj: { [key: string]: string | boolean | number }): BaseQuery {
addParams(paramObj: { [key: string]: string | boolean | number }): Query {
this._queryParams = { ...this._queryParams, ...paramObj };

return this;
return this.asQuery();
}

/**
Expand All @@ -172,12 +181,12 @@ export class BaseQuery extends Pagination {
* // OR
* const asset = await stack.asset().removeParam("query_param_key").find()
*
* @returns {BaseQuery}
* @returns {Query}
*/
removeParam(key: string): BaseQuery {
removeParam(key: string): Query {
delete this._queryParams[key];

return this;
return this.asQuery();
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/lib/contentstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { httpClient, retryRequestHandler, retryResponseErrorHandler, retryRespon
import { AxiosRequestHeaders } from 'axios';
import { handleRequest } from './cache';
import { Stack as StackClass } from './stack';
import { Policy, StackConfig, ContentstackPlugin } from './types';
import { Policy, StackConfig, ContentstackPlugin, Region } from './types';
import * as Utility from './utils';
export * as Utils from '@contentstack/utils';
import * as Utils from '@contentstack/utils';
export { Utils };

let version = '{{VERSION}}';

Expand Down Expand Up @@ -33,16 +34,17 @@ let version = '{{VERSION}}';
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export function stack(config: StackConfig): StackClass {
const DEFAULT_HOST = Utility.getHostforRegion(config.region || Region.US, config.host);

let defaultConfig = {
defaultHostname: 'cdn.contentstack.io',
defaultHostname: DEFAULT_HOST,
headers: {} as AxiosRequestHeaders,
params: {} as any,
live_preview: {} as any,
port: config.port as number,
...config
};

defaultConfig.defaultHostname = config.host || Utility.getHost(config.region, config.host);
config.host = defaultConfig.defaultHostname;

if (config.apiKey) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,5 @@ import { Taxonomy } from './taxonomy';
if (typeof debug === "boolean") this.config.debug = debug;
return this;
}

}
2 changes: 1 addition & 1 deletion src/lib/taxonomy-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class TaxonomyQuery extends Query {
* const result = await taxonomyQuery.find();
*/
override async find<T>(): Promise<FindResponse<T>> {
this._urlPath = "/taxonomy-manager"; // TODO: change to /taxonomies
this._urlPath = "/taxonomies";
const response = await getData(this._client, this._urlPath, {
params: this._queryParams,
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/taxonomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Taxonomy {
constructor(client: AxiosInstance, taxonomyUid: string) {
this._client = client;
this._taxonomyUid = taxonomyUid;
this._urlPath = `/taxonomy-manager/${this._taxonomyUid}`; // TODO: change to /taxonomies/${this._taxonomyUid}
this._urlPath = `/taxonomies/${this._taxonomyUid}`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/term-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class TermQuery {
constructor(client: AxiosInstance, taxonomyUid: string) {
this._client = client;
this._taxonomyUid = taxonomyUid;
this._urlPath = `/taxonomy-manager/${this._taxonomyUid}/terms`;
this._urlPath = `/taxonomies/${this._taxonomyUid}/terms`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/term.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Term {
this._client = client;
this._taxonomyUid = taxonomyUid;
this._termUid = termUid;
this._urlPath = `/taxonomy-manager/${this._taxonomyUid}/terms/${this._termUid}`; // TODO: change to /taxonomies
this._urlPath = `/taxonomies/${this._taxonomyUid}/terms/${this._termUid}`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Region, params } from './types';

export function getHost(region: Region = Region.US, host?: string) {
export function getHostforRegion(region: Region = Region.US, host?: string): string {
if (host) return host;

let url = 'cdn.contentstack.io';
Expand Down
Loading