Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#### Date: Feb-16-2026
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`.
Enhancement: SDK defines only the `PersistenceStore` interface (getItem/setItem); full implementation lives in the plugin for a lighter core package.
Fix: Sync API returns non-Axios response causing undefined data and recursive sync failure

### Version: 4.11.2
#### Date: feb-11-2026
Fix: JS core & axios version bump

### Version: 4.11.1
#### Date: Feb-09-2026
Expand Down
230 changes: 115 additions & 115 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"prerelease": "npm run test:all && npm run validate:all"
},
"dependencies": {
"@contentstack/core": "^1.3.9",
"@contentstack/core": "^1.3.10",
"@contentstack/utils": "^1.7.0",
"axios": "^1.13.1",
"axios": "^1.13.5",
"humps": "^2.0.1"
},
"files": [
Expand Down
16 changes: 16 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ export interface SyncType {
locale?: string;
startDate?: string;
}

export interface SyncItem {
type: string;
event_at: string;
content_type_uid: string;
data: any;
}

export interface SyncResponse {
items: SyncItem[];
skip?: number;
limit?: number;
total_count?: number;
sync_token?: string;
pagination_token?: string;
}
export type TransformData = { [key: string]: string | string[] };

export enum Format {
Expand Down
1 change: 1 addition & 0 deletions src/sync/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { synchronization } from './synchronization';
export type { SyncResponse, SyncItem } from '../common/types';
23 changes: 12 additions & 11 deletions src/sync/synchronization.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AxiosInstance, getData } from '@contentstack/core';
import { SyncStack, SyncType, PublishType } from '../common/types';
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { SyncStack, SyncType, PublishType, SyncResponse } from '../common/types';
import { AxiosRequestConfig } from 'axios';
import humps from 'humps';

export async function synchronization(client: AxiosInstance, params: SyncStack | SyncType = {}, recursive = false) {
export async function synchronization(client: AxiosInstance, params: SyncStack | SyncType = {}, recursive = false): Promise<SyncResponse> {
const config: AxiosRequestConfig = { params };
const SYNC_URL = '/stacks/sync';

Expand All @@ -17,18 +17,19 @@ export async function synchronization(client: AxiosInstance, params: SyncStack |
config.params = { ...config.params, type: type.join(',') };
}

let response: AxiosResponse = await getData(client, SYNC_URL, { params: humps.decamelizeKeys(config.params) });
const data = response.data;
// getData returns response.data directly, not the full AxiosResponse
let response: SyncResponse = await getData(client, SYNC_URL, { params: humps.decamelizeKeys(config.params) });

while (recursive && 'pagination_token' in response.data) {
const recResponse: AxiosResponse = await getData(
while (recursive && 'pagination_token' in response) {
const recResponse: SyncResponse = await getData(
client,
SYNC_URL,
humps.decamelizeKeys({ paginationToken: data.pagination_token })
{ params: humps.decamelizeKeys({ paginationToken: response.pagination_token }) }
);
recResponse.data.items = { ...response.data.items, ...recResponse.data.items };
response = { ...recResponse };
// Merge items from all paginated responses
recResponse.items = [...response.items, ...recResponse.items];
response = recResponse;
}

return response.data;
return response;
}
Loading