Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
240d7f5
feat: Implement Taxonomy class and update TaxonomyQuery for enhanced …
harshitha-cstk Oct 13, 2025
77caa3b
Merge pull request #240 from contentstack/feat/dx-3628-get-all-taxonomy
harshithad0703 Oct 14, 2025
df96f25
get a single taxonomy
harshitha-cstk Oct 17, 2025
056fc6d
Merge pull request #242 from contentstack/feat/dx-3629-single-taxonomy
harshithad0703 Oct 17, 2025
c213dd8
feat: Add Term and TermQuery classes for enhanced taxonomy term manag…
harshitha-cstk Oct 23, 2025
b7e629a
refactor: Rename TermQueryFindResponseDataMock to termQueryFindRespon…
harshitha-cstk Oct 23, 2025
6ed4fdb
Merge pull request #243 from contentstack/feat/dx-3630-get-terms
harshithad0703 Oct 23, 2025
908f206
feat: Add locales method to Term class and corresponding tests
harshitha-cstk Oct 28, 2025
92d633d
refactor: Update locales method in Term class to return data directly…
harshitha-cstk Oct 28, 2025
33bca3b
Merge pull request #247 from contentstack/feat/dx-3632-terms-loacales
harshithad0703 Oct 28, 2025
c4695d8
feat: Add ancestors method to Term class and update related tests
harshitha-cstk Oct 28, 2025
7a8b8a4
Merge pull request #248 from contentstack/feat/dx-3634-ancestors
harshithad0703 Oct 28, 2025
4e97212
feat: Add descendants method to Term class and update related tests
harshitha-cstk Oct 28, 2025
519c7a3
feat: Enhance Taxonomy and TermQuery classes with detailed documentat…
harshitha-cstk Oct 28, 2025
62e3994
docs: Update descriptions in Taxonomy and Term classes to clarify pub…
harshitha-cstk Oct 28, 2025
6a8122f
feat: type definitions for taxonomy management
harshitha-cstk Oct 28, 2025
75c7d9a
Merge pull request #249 from contentstack/feat/dx-3633-descendants
harshithad0703 Oct 29, 2025
19aa8d5
Merge branch 'main' into feat/dx-3797-update-taxonomy-api
harshitha-cstk Dec 15, 2025
13fa7d9
refactor: update API endpoints from /taxonomy-manager to /taxonomies
harshitha-cstk Dec 15, 2025
251a61c
Merge branch 'main' into feat/taxonomy-publishing
harshitha-cstk Dec 15, 2025
d88c4fc
Merge branch 'feat/taxonomy-publishing' into feat/dx-3797-update-taxo…
harshitha-cstk Dec 15, 2025
a85d2a2
Merge pull request #284 from contentstack/feat/dx-3797-update-taxonom…
harshithad0703 Dec 15, 2025
63b49fd
Merge branch 'main' into feat/taxonomy-publishing
harshitha-cstk Jan 13, 2026
38e9def
Merge branch 'main' into feat/taxonomy-publishing
harshitha-cstk Jan 13, 2026
43bc2aa
test: update locales test case to include assertions
harshitha-cstk Jan 19, 2026
165c68d
Update sca-scan.yml
dhavaljain999 Mar 2, 2026
edb8b43
Merge pull request #341 from contentstack/development
harshithad0703 Mar 9, 2026
7d2b228
Merge pull request #343 from contentstack/main
harshithad0703 Mar 9, 2026
a763410
Merge pull request #342 from contentstack/staging
harshithad0703 Mar 9, 2026
071aef5
Merge branch 'development' into feat/taxonomy-publishing
harshitha-cstk Mar 12, 2026
ed590e2
refactor: reorganize taxonomy imports and add Taxonomy and Term classes
harshitha-cstk Mar 12, 2026
5587efd
chore: remove unused Taxonomy import from stack.ts
harshitha-cstk Mar 12, 2026
7ed8c16
refactor: update import paths for Taxonomy and Term classes to reflec…
harshitha-cstk Mar 12, 2026
09268cc
update package-lock
harshitha-cstk Mar 12, 2026
f14f4e9
Merge branch 'main' into feat/taxonomy-publishing
harshitha-cstk Mar 12, 2026
2e0be5a
Merge branch 'main' into feat/taxonomy-publishing
harshitha-cstk Mar 12, 2026
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
3 changes: 3 additions & 0 deletions .github/workflows/sca-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ jobs:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --all-projects --fail-on=all
json: true
continue-on-error: true
- uses: contentstack/sca-policy@main
62 changes: 31 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 34 additions & 4 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ export type queryParams = {

/**
* Interface for creating Contentstack plugins
*
*
* @example
* ```typescript
* import { ContentstackPlugin } from '@contentstack/delivery-sdk';
*
*
* class MyPlugin implements ContentstackPlugin {
* onRequest(config: any): any {
* // Modify request configuration
* console.log('Processing request:', config.url);
* return { ...config, headers: { ...config.headers, 'X-Custom-Header': 'value' } };
* }
*
*
* onResponse(request: any, response: any, data: any): any {
* // Process response data
* console.log('Processing response:', response.status);
* return { ...response, data: { ...data, processed: true } };
* }
* }
*
*
* const stack = contentstack.stack({
* apiKey: 'your-api-key',
* deliveryToken: 'your-delivery-token',
Expand Down Expand Up @@ -344,6 +344,8 @@ export interface FindResponse<T, TContentType = unknown> {
assets?: T[];
global_fields?: T[];
count?: number;
taxonomies?: T[];
terms?: T[];
}

export interface LivePreviewQuery {
Expand All @@ -367,3 +369,31 @@ export type LivePreview = {
management_token?: string;
preview_token?: string;
};

export interface BaseTaxonomy {
uid: string;
name: string;
description?: string;
terms_count?: number;
created_at: string;
updated_at: string;
created_by: string;
updated_by: string;
type: string;
ACL: ACL;
publish_details?: PublishDetails;
}

export interface BaseTerm {
taxonomy_uid: string;
uid: string;
name: string;
created_by: string;
created_at: string;
updated_by: string;
updated_at: string;
children_count?: number;
depth?: number;
ACL: ACL;
publish_details?: PublishDetails;
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type { ImageTransform } from './assets';
export type { AssetQuery } from './query';
export type { TaxonomyQuery } from './query';
export type { ContentTypeQuery } from './query';
export type { Taxonomy } from './taxonomy';
export { ErrorMessages, ErrorCode } from './common/error-messages';

export default contentstack;
33 changes: 27 additions & 6 deletions src/query/taxonomy-query.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import { Query } from "./query";
import { AxiosInstance } from "@contentstack/core";
import { AxiosInstance, getData } from "@contentstack/core";
import { FindResponse } from "../common/types";

export class TaxonomyQuery extends Query {
constructor(client: AxiosInstance) {
super(client, {}, {}); // will need make changes to Query class so that CT uid is not mandatory
this._client = client;
this._urlPath = `/taxonomies/entries`;
}
constructor(client: AxiosInstance) {
super(client, {}, {}); // will need make changes to Query class so that CT uid is not mandatory
this._client = client;
this._urlPath = `/taxonomies/entries`;
}
/**
* @method find
* @memberof TaxonomyQuery
* @description Fetches a list of all published taxonomies available in the stack.
* @returns {Promise<FindResponse<T>>}
* @example
* import contentstack from '@contentstack/delivery-sdk'
*
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const taxonomyQuery = stack.taxonomy();
* const result = await taxonomyQuery.find();
*/
override async find<T>(): Promise<FindResponse<T>> {
this._urlPath = "/taxonomies";
const response = await getData(this._client, this._urlPath, {
params: this._queryParams,
});

return response as FindResponse<T>;
}
};
40 changes: 40 additions & 0 deletions src/query/term-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { AxiosInstance, getData } from '@contentstack/core';
import { FindResponse } from '../common/types';

/**
* @class TermQuery
* @description Represents a query for fetching multiple published terms from a taxonomy. Requires taxonomy_publish feature flag to be enabled.
*/
export class TermQuery {
private _taxonomyUid: string;
private _client: AxiosInstance;
private _urlPath: string;
_queryParams: { [key: string]: string | number } = {};

/**
* @constructor
* @param {AxiosInstance} client - The HTTP client instance
* @param {string} taxonomyUid - The taxonomy UID
*/
constructor(client: AxiosInstance, taxonomyUid: string) {
this._client = client;
this._taxonomyUid = taxonomyUid;
this._urlPath = `/taxonomies/${this._taxonomyUid}/terms`;
}

/**
* @method find
* @memberof TermQuery
* @description Fetches a list of all published terms within a specific taxonomy.
* @returns {Promise<FindResponse<T>>}
* @example
* import contentstack from '@contentstack/delivery-sdk'
*
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.taxonomy('taxonomy_uid').term().find();
*/
async find<T>(): Promise<FindResponse<T>> {
const response = await getData(this._client, this._urlPath, { params: this._queryParams });
return response as FindResponse<T>;
}
}
7 changes: 6 additions & 1 deletion src/stack/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { synchronization } from '../sync';
import { TaxonomyQuery } from '../query';
import { GlobalFieldQuery } from '../query';
import { GlobalField } from '../global-field';
import { Taxonomy } from '../taxonomy';

export class Stack {
readonly config: StackConfig;
Expand Down Expand Up @@ -78,7 +79,11 @@ export class Stack {

* const taxonomy = stack.taxonomy() // For taxonomy query object
*/
taxonomy(): TaxonomyQuery {
taxonomy(): TaxonomyQuery;
taxonomy(uid: string): Taxonomy;
taxonomy(uid?: string): Taxonomy | TaxonomyQuery {
if (uid) return new Taxonomy(this._client, uid);

return new TaxonomyQuery(this._client);
}

Expand Down
68 changes: 68 additions & 0 deletions src/taxonomy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { AxiosInstance, getData } from '@contentstack/core';
import { TermQuery } from '../query/term-query';
import { Term } from './term';

/**
* @class Taxonomy
* @description Represents a published taxonomy with methods to fetch taxonomy data and manage terms. Requires taxonomy_publish feature flag to be enabled.
*/
export class Taxonomy {
private _client: AxiosInstance;
private _taxonomyUid: string;
private _urlPath: string;

_queryParams: { [key: string]: string | number } = {};

Check warning on line 14 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

/**
* @constructor
* @param {AxiosInstance} client - The HTTP client instance
* @param {string} taxonomyUid - The taxonomy UID
*/
constructor(client: AxiosInstance, taxonomyUid: string) {

Check warning on line 21 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
this._client = client;

Check warning on line 22 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
this._taxonomyUid = taxonomyUid;

Check warning on line 23 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
this._urlPath = `/taxonomies/${this._taxonomyUid}`;

Check warning on line 24 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

/**
* @method term
* @memberof Taxonomy
* @description Gets a specific term or creates a term query
* @param {string} [uid] - Optional term UID. If provided, returns a Term instance. If not provided, returns a TermQuery instance.
* @returns {Term | TermQuery}
* @example
* import contentstack from '@contentstack/delivery-sdk'
*
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* // Get a specific term
* const term = stack.taxonomy('taxonomy_uid').term('term_uid');
* // Get all terms
* const termQuery = stack.taxonomy('taxonomy_uid').term();
*/
term(uid: string): Term;
term(): TermQuery;
term(uid?: string): Term | TermQuery {

Check warning on line 44 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
if (uid) return new Term(this._client, this._taxonomyUid, uid);

Check warning on line 45 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 45 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 45 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

return new TermQuery(this._client, this._taxonomyUid);

Check warning on line 47 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

/**
* @method fetch
* @memberof Taxonomy
* @description Fetches the taxonomy data by UID
* @returns {Promise<T>}
* @example
* import contentstack from '@contentstack/delivery-sdk'
*
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
* const result = await stack.taxonomy('taxonomy_uid').fetch();
*/
async fetch<T>(): Promise<T> {

Check warning on line 61 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
const response = await getData(this._client, this._urlPath);

Check warning on line 62 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

if (response.taxonomy) return response.taxonomy as T;

Check warning on line 64 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 64 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 64 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

return response;

Check warning on line 66 in src/taxonomy/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}
Loading
Loading