diff --git a/.cursor/rules/README.md b/.cursor/rules/README.md new file mode 100644 index 0000000..f5c1f87 --- /dev/null +++ b/.cursor/rules/README.md @@ -0,0 +1,5 @@ +# Cursor (optional) + +**Cursor** users: start at **[AGENTS.md](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**. + +This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs. diff --git a/.cursor/rules/code-review.mdc b/.cursor/rules/code-review.mdc new file mode 100644 index 0000000..08165f0 --- /dev/null +++ b/.cursor/rules/code-review.mdc @@ -0,0 +1,25 @@ +--- +description: "PR checklist for @contentstack/core — exports, semver, errors, tests, consumers" +alwaysApply: true +--- + +# Code review — `@contentstack/core` + +## Public API + +- **`src/index.ts`** exports match intended **npm `exports`**; new surface is documented and versioned. +- Changes that affect **`@contentstack/delivery-sdk`** require a coordinated plan (bump **core** + **SDK** as needed). + +## Implementation + +- Axios / retry / serializer changes remain **backward compatible** unless this is a **major** release. +- Errors use existing **classes** and **messages**; do not leak secrets in **logs** or **errors**. + +## Tests & quality + +- New logic includes **`test/*.spec.ts`** (or extends existing specs); **coverage thresholds** must still pass. +- **Lint** clean. + +## Dependencies + +- New dependencies need justification (bundle size, maintenance, license). diff --git a/.cursor/rules/contentstack-js-core.mdc b/.cursor/rules/contentstack-js-core.mdc new file mode 100644 index 0000000..f72fa64 --- /dev/null +++ b/.cursor/rules/contentstack-js-core.mdc @@ -0,0 +1,24 @@ +--- +description: "@contentstack/core — Axios httpClient, errors, serialization, retry policies" +globs: ["src/**/*.ts"] +alwaysApply: false +--- + +# `@contentstack/core` implementation + +## HTTP + +- **`httpClient(options)`** in **`src/lib/contentstack-core.ts`** builds the **Axios** instance: **baseURL**, headers (**api_key**, **access_token**), **timeout**, **retryCondition** (e.g. **429**), **logHandler**, **versioningStrategy**, etc. +- **`src/lib/request.ts`** and **`param-serializer.ts`** implement delivery-oriented query/body serialization — keep behavior aligned with CDA query expectations. + +## Errors + +- Use **`ContentstackError`** / **`ApiError`** and **`error-messages.ts`** for consistent messaging; preserve **status** / response metadata where applicable. + +## Retries + +- **`src/lib/retryPolicy/delivery-sdk-handlers.ts`** provides Axios interceptors (**retryRequestHandler**, **retryResponseHandler**, **retryResponseErrorHandler**) — changes here affect all consumers (including **@contentstack/delivery-sdk**). + +## Testing + +- Prefer **axios-mock-adapter** or mocks in **`test/utils`**; keep **`*.spec.ts`** focused and deterministic. diff --git a/.cursor/rules/dev-workflow.md b/.cursor/rules/dev-workflow.md new file mode 100644 index 0000000..8c8b709 --- /dev/null +++ b/.cursor/rules/dev-workflow.md @@ -0,0 +1,26 @@ +--- +description: "Branches, build, lint, and PR expectations for contentstack-js-core" +globs: ["**/*.ts", "**/*.js", "**/*.json"] +alwaysApply: false +--- + +# Development workflow — `@contentstack/core` + +## Before a PR + +1. **`npm run lint`** — must pass. +2. **`npm test`** — Jest + coverage thresholds in `jest.config.ts` must be satisfied. +3. **`npm run build`** — CJS, ESM, UMD, and types must compile. + +## API stability + +- This package is a **dependency of `@contentstack/delivery-sdk`**. Avoid breaking changes to exported functions, option shapes, or error types without a **semver-major** bump and coordinated **delivery-sdk** upgrade. +- Keep **`package.json` `exports`** in sync with `src/index.ts`. + +## Versioning + +- Bump **`package.json` `version`** for releases that change published behavior (patch/minor/major per semver). + +## Links + +- [`AGENTS.md`](../../AGENTS.md) · [`skills/contentstack-js-core/SKILL.md`](../../skills/contentstack-js-core/SKILL.md) diff --git a/.cursor/rules/testing.mdc b/.cursor/rules/testing.mdc new file mode 100644 index 0000000..2894d10 --- /dev/null +++ b/.cursor/rules/testing.mdc @@ -0,0 +1,22 @@ +--- +description: "Jest tests and coverage for @contentstack/core" +globs: ["test/**/*.ts"] +alwaysApply: false +--- + +# Testing — contentstack-js-core + +## Runner + +- **Jest** + **ts-jest** — see **`jest.config.ts`** / **`jest.preset.js`** / **`tsconfig.spec.json`**. +- **Coverage** is collected from **`src/**`** (with exclusions in config); **global thresholds** (branches/functions/lines/statements) apply — see `jest.config.ts`. + +## Layout + +- Specs: **`test/*.spec.ts`** (e.g. `request.spec.ts`, `contentstack-core.spec.ts`). +- Shared mocks: **`test/utils/mocks.ts`**. + +## Hygiene + +- No **committed** `it.only` / `describe.only` meant for CI. +- Avoid live network calls in unit tests unless explicitly an integration suite (this repo is primarily mocked unit tests). diff --git a/.cursor/rules/typescript.mdc b/.cursor/rules/typescript.mdc new file mode 100644 index 0000000..419e112 --- /dev/null +++ b/.cursor/rules/typescript.mdc @@ -0,0 +1,28 @@ +--- +description: "TypeScript and repo conventions for @contentstack/core" +globs: + - "src/**/*.ts" + - "config/**/*.ts" + - "config/**/*.js" + - "tools/**/*.js" + - "jest.config.ts" + - "jest.preset.js" +alwaysApply: false +--- + +# TypeScript — contentstack-js-core + +## Layout + +- **`src/lib/*.ts`** — implementation modules; **`src/index.ts`** re-exports the public surface. +- **Configs** live under **`config/`** (multiple `tsconfig.*.json`, webpack). + +## Style + +- Follow **ESLint** (Airbnb TypeScript + Prettier) and existing patterns in `src/lib/`. +- Prefer **explicit types** on public exports and Axios-related options. +- Use **lodash** / **axios** patterns already present in `contentstack-core.ts` and `request.ts`. + +## Security + +- Do not log **api keys**, **access tokens**, or full auth headers in new code; align with existing **`logHandler`** usage. diff --git a/.talismanrc b/.talismanrc index ccb9bb1..4f799de 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,4 +1,4 @@ fileignoreconfig: - filename: package-lock.json - checksum: 8b8088b2ef8210337d3a7f74d626b1ae4c2a4dcb0b5abab0c82e53e2d184eb04 + checksum: c573bb4a5846055335df856bff87f28d9fccb90714ac4dbd699f5dcff2257615 version: "" \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..3d608c6 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,43 @@ +# @contentstack/core – Agent guide + +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. + +## What this repo is + +| Field | Detail | +|--------|--------| +| **Name:** | [contentstack-js-core](https://github.com/contentstack/contentstack-js-core) (`@contentstack/core`) | +| **Purpose:** | TypeScript core library: HTTP client wiring, errors, serialization, retries—shared by Contentstack TS SDKs. | +| **Out of scope:** | Not an end-user SDK; apps should use the Delivery SDK, which depends on this package. | + +## Tech stack (at a glance) + +| Area | Details | +|------|---------| +| Language | TypeScript (see `typescript` in `package.json`; `config/tsconfig.*.json`) | +| Build | `tsc` (CJS/ESM/types) + Webpack UMD (`config/webpack.config.js`, `tools/`) | +| Tests | Jest → `test/` (`npm test` → `jest ./test`) | +| Lint / coverage | ESLint `.eslintrc.js` (`npm run lint`) | +| CI | `.github/workflows/unit-test.yml`, `check-branch.yml`, `sca-scan.yml`, `policy-scan.yml`, `codeql-analysis.yml` | + +## Commands (quick reference) + +| Command type | Command | +|--------------|---------| +| Build | `npm run build` | +| Test | `npm test` | +| Lint | `npm run lint` | + +## Where the documentation lives: skills + +| Skill | Path | What it covers | +|-------|------|----------------| +| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Branches, CI, npm scripts, Husky, release notes | +| **Contentstack core (package)** | [`skills/contentstack-core/SKILL.md`](skills/contentstack-core/SKILL.md) | `@contentstack/core` boundaries, public surface, dependency role | +| **TypeScript & layout** | [`skills/typescript/SKILL.md`](skills/typescript/SKILL.md) | `src/`, `config/` tsconfigs, ESM/CJS/UMD outputs | +| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | Jest layout, mocks, fixtures | +| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR expectations and checklist | + +## Using Cursor (optional) + +If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else. diff --git a/CHANGELOG.md b/CHANGELOG.md index f49fb10..069ca78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Change log +### Version: 1.3.14 +#### Date: May-04-2026 + - Fix: Bump axios to ^1.15.2 (security patches for axios 1.15.0) + ### Version: 1.3.13 #### Date: April-15-2026 - Fix: Axios version bump @@ -88,7 +92,6 @@ #### Date: Oct-22-2024 - Fix: getData to receive params and headers both in data -## Change log ### Version: 1.1.2 #### Date: Oct-22-2024 - Node version bump diff --git a/package-lock.json b/package-lock.json index 0039bd4..d25f3f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@contentstack/core", - "version": "1.3.13", + "version": "1.3.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/core", - "version": "1.3.13", + "version": "1.3.14", "license": "MIT", "dependencies": { - "axios": "^1.15.0", + "axios": "^1.15.2", "axios-mock-adapter": "^2.1.0", "lodash": "^4.18.1", "qs": "6.15.1", @@ -92,9 +92,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.0.tgz", - "integrity": "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg==", + "version": "7.29.3", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.3.tgz", + "integrity": "sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg==", "dev": true, "license": "MIT", "engines": { @@ -263,9 +263,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.29.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", - "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", + "version": "7.29.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.3.tgz", + "integrity": "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA==", "dev": true, "license": "MIT", "dependencies": { @@ -1520,9 +1520,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/ajv": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz", - "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "dev": true, "license": "MIT", "dependencies": { @@ -3168,9 +3168,9 @@ } }, "node_modules/ajv": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", - "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "dev": true, "license": "MIT", "dependencies": { @@ -3555,9 +3555,9 @@ } }, "node_modules/axe-core": { - "version": "4.11.3", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.11.3.tgz", - "integrity": "sha512-zBQouZixDTbo3jMGqHKyePxYxr1e5W8UdTmBQ7sNtaA9M2bE32daxxPLS/jojhKOHxQ7LWwPjfiwf/fhaJWzlg==", + "version": "4.11.4", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.11.4.tgz", + "integrity": "sha512-KunSNx+TVpkAw/6ULfhnx+HWRecjqZGTOyquAoWHYLRSdK1tB5Ihce1ZW+UY3fj33bYAFWPu7W/GRSmmrCGuxA==", "dev": true, "license": "MPL-2.0", "engines": { @@ -3565,12 +3565,12 @@ } }, "node_modules/axios": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.15.0.tgz", - "integrity": "sha512-wWyJDlAatxk30ZJer+GeCWS209sA42X+N5jU2jy6oHTp7ufw8uzUTVFBX9+wTfAlhiJXGS0Bq7X6efruWjuK9Q==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.16.0.tgz", + "integrity": "sha512-6hp5CwvTPlN2A31g5dxnwAX0orzM7pmCRDLnZSX772mv8WDqICwFjowHuPs04Mc8deIld1+ejhtaMn5vp6b+1w==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.11", + "follow-redirects": "^1.16.0", "form-data": "^4.0.5", "proxy-from-env": "^2.1.0" } @@ -3726,9 +3726,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.10.19", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.19.tgz", - "integrity": "sha512-qCkNLi2sfBOn8XhZQ0FXsT1Ki/Yo5P90hrkRamVFRS7/KV9hpfA4HkoWNU152+8w0zPjnxo5psx5NL3PSGgv5g==", + "version": "2.10.27", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.27.tgz", + "integrity": "sha512-zEs/ufmZoUd7WftKpKyXaT6RFxpQ5Qm9xytKRHvJfxFV9DFJkZph9RvJ1LcOUi0Z1ZVijMte65JbILeV+8QQEA==", "dev": true, "license": "Apache-2.0", "bin": { @@ -3960,9 +3960,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001788", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001788.tgz", - "integrity": "sha512-6q8HFp+lOQtcf7wBK+uEenxymVWkGKkjFpCvw5W25cmMwEDU45p1xQFBQv8JDlMMry7eNxyBaR+qxgmTUZkIRQ==", + "version": "1.0.30001791", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001791.tgz", + "integrity": "sha512-yk0l/YSrOnFZk3UROpDLQD9+kC1l4meK/wed583AXrzoarMGJcbRi2Q4RaUYbKxYAsZ8sWmaSa/DsLmdBeI1vQ==", "dev": true, "funding": [ { @@ -5103,9 +5103,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.336", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.336.tgz", - "integrity": "sha512-AbH9q9J455r/nLmdNZes0G0ZKcRX73FicwowalLs6ijwOmCJSRRrLX63lcAlzy9ux3dWK1w1+1nsBJEWN11hcQ==", + "version": "1.5.349", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.349.tgz", + "integrity": "sha512-QsWVGyRuY07Aqb234QytTfwd5d9AJlfNIQ5wIOl1L+PZDzI9d9+Fn0FRale/QYlFxt/bUnB0/nLd1jFPGxGK1A==", "dev": true, "license": "ISC" }, @@ -5295,9 +5295,9 @@ } }, "node_modules/es-module-lexer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.0.0.tgz", - "integrity": "sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.1.0.tgz", + "integrity": "sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==", "dev": true, "license": "MIT" }, @@ -5906,9 +5906,9 @@ } }, "node_modules/eslint/node_modules/ajv": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz", - "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "dev": true, "license": "MIT", "dependencies": { @@ -6926,9 +6926,9 @@ } }, "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -9010,9 +9010,9 @@ } }, "node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", "dev": true, "license": "MIT", "dependencies": { @@ -9147,9 +9147,9 @@ "license": "MIT" }, "node_modules/loader-runner": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.1.tgz", - "integrity": "sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.2.tgz", + "integrity": "sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==", "dev": true, "license": "MIT", "engines": { @@ -9655,9 +9655,9 @@ "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.37", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.37.tgz", - "integrity": "sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==", + "version": "2.0.38", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.38.tgz", + "integrity": "sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==", "dev": true, "license": "MIT" }, @@ -10850,15 +10850,15 @@ } }, "node_modules/safe-array-concat": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz", - "integrity": "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.4.tgz", + "integrity": "sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==", "dev": true, "license": "MIT", "dependencies": { - "call-bind": "^1.0.8", - "call-bound": "^1.0.2", - "get-intrinsic": "^1.2.6", + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", "has-symbols": "^1.1.0", "isarray": "^2.0.5" }, @@ -11577,9 +11577,9 @@ } }, "node_modules/terser": { - "version": "5.46.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.1.tgz", - "integrity": "sha512-vzCjQO/rgUuK9sf8VJZvjqiqiHFaZLnOiimmUuOKODxWL8mm/xua7viT7aqX7dgPY60otQjUotzFMmCB4VdmqQ==", + "version": "5.46.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.2.tgz", + "integrity": "sha512-uxfo9fPcSgLDYob/w1FuL0c99MWiJDnv+5qXSQc5+Ki5NjVNsYi66INnMFBjf6uFz6OnX12piJQPF4IpjJTNTw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -11596,9 +11596,9 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.4.0.tgz", - "integrity": "sha512-Bn5vxm48flOIfkdl5CaD2+1CiUVbonWQ3KQPyP7/EuIl9Gbzq/gQFOzaMFUEgVjB1396tcK0SG8XcNJ/2kDH8g==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.5.0.tgz", + "integrity": "sha512-UYhptBwhWvfIjKd/UuFo6D8uq9xpGLDK+z8EDsj/zWhrTaH34cKEbrkMKfV5YWqGBvAYA3tlzZbs2R+qYrbQJA==", "dev": true, "license": "MIT", "dependencies": { @@ -11898,14 +11898,14 @@ } }, "node_modules/ts-loader/node_modules/enhanced-resolve": { - "version": "5.20.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.20.1.tgz", - "integrity": "sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.0.tgz", + "integrity": "sha512-otxSQPw4lkOZWkHpB3zaEQs6gWYEsmX4xQF68ElXC/TWvGxGMSGOvoNbaLXm6/cS/fSfHtsEdw90y20PCd+sCA==", "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", - "tapable": "^2.3.0" + "tapable": "^2.3.3" }, "engines": { "node": ">=10.13.0" @@ -11935,9 +11935,9 @@ } }, "node_modules/ts-loader/node_modules/tapable": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.2.tgz", - "integrity": "sha512-1MOpMXuhGzGL5TTCZFItxCc0AARf1EZFQkGqMm7ERKj8+Hgr5oLvJOVFcC+lRmR8hCe2S3jC4T5D7Vg/d7/fhA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", "dev": true, "license": "MIT", "engines": { @@ -12289,6 +12289,7 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", "dev": true, "license": "MIT", "bin": { @@ -12400,9 +12401,9 @@ } }, "node_modules/webpack": { - "version": "5.106.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.106.1.tgz", - "integrity": "sha512-EW8af29ak8Oaf4T8k8YsajjrDBDYgnKZ5er6ljWFJsXABfTNowQfvHLftwcepVgdz+IoLSdEAbBiM9DFXoll9w==", + "version": "5.106.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.106.2.tgz", + "integrity": "sha512-wGN3qcrBQIFmQ/c0AiOAQBvrZ5lmY8vbbMv4Mxfgzqd/B6+9pXtLo73WuS1dSGXM5QYY3hZnIbvx+K1xxe6FyA==", "dev": true, "license": "MIT", "dependencies": { @@ -12422,9 +12423,8 @@ "events": "^3.2.0", "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.2.11", - "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.3.1", - "mime-types": "^2.1.27", + "mime-db": "^1.54.0", "neo-async": "^2.6.2", "schema-utils": "^4.3.3", "tapable": "^2.3.0", @@ -12532,9 +12532,9 @@ } }, "node_modules/webpack-sources": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.3.4.tgz", - "integrity": "sha512-7tP1PdV4vF+lYPnkMR0jMY5/la2ub5Fc/8VQrrU+lXkiM6C4TjVfGw7iKfyhnTQOsD+6Q/iKw0eFciziRgD58Q==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.4.1.tgz", + "integrity": "sha512-eACpxRN02yaawnt+uUNIF7Qje6A9zArxBbcAJjK1PK3S9Ycg5jIuJ8pW4q8EMnwNZCEGltcjkRx1QzOxOkKD8A==", "dev": true, "license": "MIT", "engines": { @@ -12542,23 +12542,33 @@ } }, "node_modules/webpack/node_modules/enhanced-resolve": { - "version": "5.20.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.20.1.tgz", - "integrity": "sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.0.tgz", + "integrity": "sha512-otxSQPw4lkOZWkHpB3zaEQs6gWYEsmX4xQF68ElXC/TWvGxGMSGOvoNbaLXm6/cS/fSfHtsEdw90y20PCd+sCA==", "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", - "tapable": "^2.3.0" + "tapable": "^2.3.3" }, "engines": { "node": ">=10.13.0" } }, + "node_modules/webpack/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/webpack/node_modules/tapable": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.2.tgz", - "integrity": "sha512-1MOpMXuhGzGL5TTCZFItxCc0AARf1EZFQkGqMm7ERKj8+Hgr5oLvJOVFcC+lRmR8hCe2S3jC4T5D7Vg/d7/fhA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index c610520..f0ee5d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/core", - "version": "1.3.13", + "version": "1.3.14", "type": "commonjs", "main": "./dist/cjs/src/index.js", "types": "./dist/cjs/src/index.d.ts", @@ -33,7 +33,7 @@ "husky-check": "npx husky install && chmod +x .husky/pre-commit" }, "dependencies": { - "axios": "^1.15.0", + "axios": "^1.15.2", "axios-mock-adapter": "^2.1.0", "lodash": "^4.18.1", "qs": "6.15.1", diff --git a/skills/README.md b/skills/README.md new file mode 100644 index 0000000..4849502 --- /dev/null +++ b/skills/README.md @@ -0,0 +1,10 @@ +# Project skills — `@contentstack/core` + +| Skill | When to use | +|-------|-------------| +| [`code-review/`](code-review/SKILL.md) | PR readiness, semver, consumer impact | +| [`testing/`](testing/SKILL.md) | Jest, coverage thresholds, mocks | +| [`contentstack-js-core/`](contentstack-js-core/SKILL.md) | httpClient, request, errors, retry handlers | +| [`framework/`](framework/SKILL.md) | Axios pipeline, interceptors, serializers | + +**Overview:** [`AGENTS.md`](../AGENTS.md) · **Rules:** [`.cursor/rules/README.md`](../.cursor/rules/README.md) diff --git a/skills/code-review/SKILL.md b/skills/code-review/SKILL.md new file mode 100644 index 0000000..a4dbaa9 --- /dev/null +++ b/skills/code-review/SKILL.md @@ -0,0 +1,27 @@ +--- +name: code-review +description: Use when reviewing PRs or preparing changes for contentstack-js-core—API stability, tests, and consumer impact. +--- + +# Code review – contentstack-js-core + +## When to use + +- Authoring or reviewing a PR +- Judging whether a change is safe for downstream SDKs + +## Instructions + +### Checklist + +- **API / exports**: Any change to public exports or types that could break `@contentstack/delivery-sdk` or other consumers? +- **Behavior**: Retries, errors, and serialization remain backward compatible unless semver major. +- **Tests**: New logic covered; existing tests updated when semantics change. +- **Build**: `npm run build` and `npm test` and `npm run lint` succeed. +- **Security / deps**: Dependency bumps justified; no secrets in code or tests. + +### Severity hints + +- **Blocker**: Breaking change without major version or failing CI. +- **Major**: Missing tests for risky HTTP/error changes. +- **Minor**: Style, naming, or internal refactors with full green CI. diff --git a/skills/contentstack-core/SKILL.md b/skills/contentstack-core/SKILL.md new file mode 100644 index 0000000..1d07a9d --- /dev/null +++ b/skills/contentstack-core/SKILL.md @@ -0,0 +1,28 @@ +--- +name: contentstack-core +description: Use when working on @contentstack/core API surface, HTTP layer, errors, or how other SDKs consume this package. +--- + +# Contentstack core package – contentstack-js-core + +## When to use + +- Adding or changing modules under `src/` +- Adjusting Axios usage, retries, error types, or serialization +- Explaining how Delivery SDK pulls in this dependency + +## Instructions + +### Role of the package + +- Published as **`@contentstack/core`**; it is an **internal building block** for Contentstack TypeScript SDKs, not a standalone app SDK for stack users. +- Entry points and exports are defined via `package.json` `exports` and build outputs under `dist/`. + +### Boundaries + +- Prefer stable, documented behavior for HTTP, errors, and request helpers—downstream SDKs rely on consistent error shapes and retry semantics. +- Coordinate version bumps with consumers (e.g. `contentstack-typescript`) when changing public types or behavior. + +### Versioning + +- Follow semver for releases; breaking changes require a major bump and coordinated updates in dependent packages. diff --git a/skills/contentstack-js-core/SKILL.md b/skills/contentstack-js-core/SKILL.md new file mode 100644 index 0000000..762cb06 --- /dev/null +++ b/skills/contentstack-js-core/SKILL.md @@ -0,0 +1,32 @@ +--- +name: contentstack-js-core +description: @contentstack/core — httpClient, request helpers, param serialization, errors, delivery retry handlers. +--- + +# `@contentstack/core` skill + +Internal library for **Contentstack TypeScript/JavaScript SDKs**. Prefer **`@contentstack/delivery-sdk`** for app code. + +## Modules + +| Module | Responsibility | +|--------|----------------| +| **`contentstack-core.ts`** | **`httpClient`**: Axios create, defaults, **apiKey** / **accessToken** → headers, **retryCondition**, **logHandler** | +| **`request.ts`** | Request execution helpers used with the client | +| **`param-serializer.ts`** | Query/body serialization for CDA-style calls | +| **`contentstack-error.ts`**, **`api-error.ts`** | Typed errors | +| **`retryPolicy/delivery-sdk-handlers.ts`** | Retry interceptors composed with **`httpClient`** in consumers | +| **`types.ts`** | **HttpClientParams**, etc. | + +## Changing behavior + +- Coordinate with **`contentstack-typescript`** when changing interceptor signatures, default timeouts, or error shapes. +- Run **`npm test`** and **`npm run build`** before PR. + +## Docs + +- [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) (consumer semantics) + +## Rule shortcut + +- `.cursor/rules/contentstack-js-core.mdc` diff --git a/skills/dev-workflow/SKILL.md b/skills/dev-workflow/SKILL.md new file mode 100644 index 0000000..2bc47c9 --- /dev/null +++ b/skills/dev-workflow/SKILL.md @@ -0,0 +1,31 @@ +--- +name: dev-workflow +description: Use when changing branches, CI, npm scripts, Husky hooks, or release workflow in contentstack-js-core. +--- + +# Development workflow – contentstack-js-core + +## When to use + +- Planning a change that touches build, test, or CI +- Onboarding to how PRs and checks run for this repo + +## Instructions + +### Branches and integration + +- Default branch is **`main`**; `development` also exists—match team practice for PR targets. +- GitHub Actions under `.github/workflows/` run tests, branch checks, SCA, policy, and CodeQL—coordinate schema changes with those jobs. + +### Commands + +- Install: `npm ci` (or `npm install` for local dev). +- Build: `npm run build` (CJS + ESM + UMD + types). +- Test: `npm test`. +- Lint: `npm run lint`. +- `prepare` runs build and Husky setup—expect hooks after install. + +### PR expectations + +- Keep changes scoped; this package is consumed by other SDKs—avoid breaking exports without semver alignment. +- Ensure `npm run build` and `npm test` pass locally before opening a PR. diff --git a/skills/framework/SKILL.md b/skills/framework/SKILL.md new file mode 100644 index 0000000..ad90957 --- /dev/null +++ b/skills/framework/SKILL.md @@ -0,0 +1,26 @@ +--- +name: framework +description: Axios HTTP stack in @contentstack/core — clients, retries, serialization pipeline. +--- + +# Framework skill — HTTP layer (`@contentstack/core`) + +## Flow + +1. **`httpClient(params)`** returns a configured **Axios** instance (**baseURL**, **headers**, **timeout**, adapters). +2. **Interceptors** from **`retryPolicy/delivery-sdk-handlers.ts`** may be attached by consumers for retry-on-429-style behavior. +3. **Serialization** via **`param-serializer`** ensures query strings match API expectations. + +## When to edit + +- **Global defaults** (timeout, retry predicate) → **`contentstack-core.ts`**. +- **Query encoding** → **`param-serializer.ts`** (watch for regressions in delivery-sdk tests). +- **Retry timing / idempotency** → **`retryPolicy/delivery-sdk-handlers.ts`**. + +## Tests + +- **`test/request.spec.ts`**, **`test/contentstack-core.spec.ts`**, retry specs under **`test/retryPolicy/`** — extend when altering behavior. + +## Rule shortcut + +- `.cursor/rules/contentstack-js-core.mdc` · `.cursor/rules/typescript.mdc` diff --git a/skills/testing/SKILL.md b/skills/testing/SKILL.md new file mode 100644 index 0000000..1b5d865 --- /dev/null +++ b/skills/testing/SKILL.md @@ -0,0 +1,23 @@ +--- +name: testing +description: Use when writing or fixing Jest tests, mocks, or test layout under test/ in contentstack-js-core. +--- + +# Testing – contentstack-js-core + +## When to use + +- Adding coverage for new `src/` behavior +- Fixing flaky or outdated tests under `test/` + +## Instructions + +### Runner and layout + +- **Jest** is configured for this repo; tests live under **`test/`** (`npm test` runs `jest ./test`). +- Prefer focused unit tests near the behavior under test; use mocks for HTTP where `axios` or adapters are involved. + +### Practice + +- Run the full suite before merging: `npm test`. +- Keep tests deterministic—no live network calls to Contentstack APIs in CI unless a dedicated integration job exists and secrets are available. diff --git a/skills/typescript/SKILL.md b/skills/typescript/SKILL.md new file mode 100644 index 0000000..86eedba --- /dev/null +++ b/skills/typescript/SKILL.md @@ -0,0 +1,24 @@ +--- +name: typescript +description: Use for TypeScript layout, tsconfig variants, and build outputs (CJS/ESM/UMD/types) in contentstack-js-core. +--- + +# TypeScript & repo layout – contentstack-js-core + +## When to use + +- Editing `config/tsconfig.*.json` or build pipelines +- Adding new source files under `src/` +- Debugging dual CJS/ESM/UMD output issues + +## Instructions + +### Layout + +- Source lives under **`src/`**; compiled artifacts go to **`dist/`** via separate targets (`build:cjs`, `build:esm`, `build:umd`, `build:types`). +- **`config/`** holds TypeScript and Webpack configs—keep them in sync when adding path aliases or new entry files. + +### Tooling + +- TypeScript version is pinned in `package.json`—upgrade deliberately with full `npm run build` and `npm test`. +- ESLint uses `.eslintrc.js`; run `npm run lint` after structural refactors.