Skip to content

feat: Add checkpoint loading for Contentstack sync initialization #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 3, 2025

Conversation

aman19K
Copy link
Contributor

@aman19K aman19K commented Jul 3, 2025

This PR introduces checkpoint file support during the Contentstack sync initialization. Key updates include:

  • Added loadCheckpoint function to read existing sync token from a hidden file.
  • Implemented readHiddenFile utility to safely read and parse JSON from disk.
  • Integrated checkpoint loading into the init lifecycle to resume sync from the last known state.
  • Added fallback logic to look for a default .checkpoint file if none is found at the specified path.

These changes enhance resiliency and efficiency by enabling sync resume capabilities, reducing redundant content fetching on service restarts

@aman19K aman19K requested a review from a team as a code owner July 3, 2025 03:53
@aman19K aman19K requested review from Copilot and removed request for a team July 3, 2025 03:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for reading and applying checkpoint files during the Contentstack sync initialization to resume from the last known state and avoid redundant fetches.

  • Introduces loadCheckpoint and readHiddenFile functions for loading and parsing a JSON checkpoint.
  • Hooks checkpoint loading into the init lifecycle with fallback logic to a default file path.
  • Expands config schema with checkpoint options and bumps the package version.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/core/plugins.ts Added try/catch around plugin loading to surface errors.
src/core/index.ts Implemented loadCheckpoint, readHiddenFile, and integrated checkpoint logic into init.
src/config.ts Added checkpoint settings (enabled, filePath, preserve).
package.json Updated version from 2.0.11 to 2.1.0.
Comments suppressed due to low confidence (3)

src/core/index.ts:84

  • The variable checkPointConfig has inconsistent capitalization; consider renaming it to checkpointConfig for consistency with the interface name.
      const checkPointConfig: ICheckpoint = config.checkpoint

src/core/index.ts:122

  • There are no unit tests covering the new loadCheckpoint and readHiddenFile behaviors; consider adding tests for successful load, fallback, missing file, and parse errors.
const loadCheckpoint = (checkPointConfig: ICheckpoint, paths: any): void => {

src/core/index.ts:54

  • The preserve flag in ICheckpoint is neither documented nor implemented; add comments or implement its behavior, and correct formatting to preserve: boolean.
  preserve:boolean

aman19K and others added 3 commits July 3, 2025 09:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@harshithad0703 harshithad0703 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aman19K aman19K merged commit 5899cd9 into development Jul 3, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants