diff --git a/.commitlintrc.json b/.commitlintrc.json
new file mode 100644
index 0000000..b40de1a
--- /dev/null
+++ b/.commitlintrc.json
@@ -0,0 +1,27 @@
+{
+ "extends": ["@commitlint/config-conventional"],
+ "rules": {
+ "subject-case": [0],
+ "subject-empty": [2, "never"],
+ "subject-full-stop": [2, "never", "."],
+ "type-enum": [
+ 2,
+ "always",
+ [
+ "build",
+ "chore",
+ "ci",
+ "docs",
+ "feat",
+ "fix",
+ "perf",
+ "refactor",
+ "revert",
+ "style",
+ "test",
+ "sample"
+ ]
+ ],
+ "type-empty": [2, "never"]
+ }
+}
diff --git a/.cursor/rules/README.md b/.cursor/rules/README.md
new file mode 100644
index 0000000..b4b2107
--- /dev/null
+++ b/.cursor/rules/README.md
@@ -0,0 +1,26 @@
+# Cursor rules — `@contentstack/utils`
+
+This folder holds project-specific rules for AI assistants working in **contentstack-utils-javascript**. For the full project overview, see **[`AGENTS.md`](../../AGENTS.md)** at the repository root.
+
+## How rules are picked up
+
+Each rule is a `.md`/`.mdc` file. Files with YAML frontmatter can set `description`, `globs`, and `alwaysApply`. Cursor uses these to decide when a rule is included in context.
+
+### Referencing rules in chat
+
+In Cursor, you can **`@`-mention** a rule file (e.g. type `@` and choose the rule from the list) to force its guidance into the conversation. The file name (without extension) is the usual handle, e.g. **`typescript`**, **`testing`**, **`code-review`**.
+
+## Rule index
+
+| File | `alwaysApply` | Globs | When it applies |
+|------|----------------|-------|------------------|
+| [`dev-workflow.md`](dev-workflow.md) | no | *(none)* | Branching, CI alignment, commits, releases, and day-to-day commands for this repo. |
+| [`typescript.mdc`](typescript.mdc) | no | `src/**/*.ts`, `__test__/**/*.ts` | TypeScript version, layout, ESLint/Prettier, strictness, imports. |
+| [`typescript-contentstack-utils.mdc`](typescript-contentstack-utils.mdc) | no | `src/**/*.ts` | Delivery-oriented utils only: RTE rendering, GQL helpers, endpoints JSON, Live Preview tags—**not** full CDA/CMA SDK surface. |
+| [`testing.mdc`](testing.mdc) | no | `__test__/**/*.ts` | Jest, jsdom, mocks, coverage output paths, no live-test env. |
+| [`code-review.mdc`](code-review.mdc) | **yes** | *(global)* | PR checklist: public API docs, compatibility, errors, dependencies, terminology (utils + delivery context). |
+
+## Related
+
+- **[`AGENTS.md`](../../AGENTS.md)** — Single entry point (package purpose, stack, commands).
+- **[`skills/README.md`](../../skills/README.md)** — Longer-form skill docs for the same themes.
diff --git a/.cursor/rules/code-review.mdc b/.cursor/rules/code-review.mdc
new file mode 100644
index 0000000..0e5fc27
--- /dev/null
+++ b/.cursor/rules/code-review.mdc
@@ -0,0 +1,41 @@
+---
+description: PR review checklist for @contentstack/utils — API docs, compatibility, security, testing
+alwaysApply: true
+---
+
+# Code review checklist — `@contentstack/utils`
+
+Use severity labels (**Blocker / Major / Minor**) when triaging findings.
+
+## Public API and documentation
+
+- **Blocker/Major:** New or changed **exports** from `src/index.ts` need accurate **JSDoc** (or clear type names) matching runtime behavior.
+- **Major:** README / CHANGELOG updates when behavior is user-visible or migration is needed.
+
+## Backward compatibility
+
+- **Blocker:** Unplanned breaking changes to **function signatures** or **default behavior** consumed by Delivery SDK integrations or documented `renderOption` contracts.
+- **Major:** Stricter throwing on inputs that previously passed (especially `getContentstackEndpoint`, RTE traversals).
+
+## Errors
+
+- This package uses **plain `Error`** (e.g. `endpoints.ts`); new code should keep messages actionable. **Major:** Silent failures where callers need to detect bad input.
+
+## Null safety and RTE edge cases
+
+- **Major:** Missing guards on **null/undefined** node or entry fragments (historically sensitive in `entry-editable` / RTE paths).
+- **Minor:** Align with **`strictNullChecks: false`** legacy but avoid widening undefined leaks into public types.
+
+## Dependencies and SCA
+
+- **Major:** New runtime deps are rare—justify any addition; **`prepublishOnly`** and hooks assume **`npm test`** and Snyk-friendly trees.
+- Use **`npm audit` / Snyk** expectations per org policy.
+
+## Tests
+
+- **Blocker:** Behavioral fixes or new branches without **`__test__`** coverage when risk is high (RTE nesting, GQL URL rewriting, endpoint resolution).
+- **Minor:** Snapshot-only tests where a small assertion would be clearer.
+
+## Terminology
+
+- **Major:** Docs/comments must describe this as **utils** alongside **CDA / Delivery / JSON RTE / GraphQL**, not as **CMA** unless the change is explicitly management-related.
diff --git a/.cursor/rules/dev-workflow.md b/.cursor/rules/dev-workflow.md
new file mode 100644
index 0000000..0453f3c
--- /dev/null
+++ b/.cursor/rules/dev-workflow.md
@@ -0,0 +1,38 @@
+---
+description: Branching, CI, local commands, commit hooks, and release flow for contentstack-utils-javascript
+alwaysApply: false
+---
+
+# Dev workflow — `@contentstack/utils`
+
+## Branches and PRs
+
+- **CI** (`Unit-Test-CI`) runs on **push/PR** to `development`, `staging`, and `master` (see `.github/workflows/ci.yml`).
+- **Branch protection:** A workflow fails PRs that target **`staging`** when the head branch is **not** `development` (see `.github/workflows/check-branch.yml`). Prefer **`development`** as the integration branch when contributing upstream.
+- Target the branch your team uses for integration; align with maintainers if unsure.
+
+## Local development
+
+| Task | Command / note |
+|------|----------------|
+| Build | `npm run build` (runs `prebuild`: clean `dist`, `download-regions`, then `tsc` + Rollup) |
+| Test | `npm test` (includes `pretest` → build; Jest + coverage; `reports/`) |
+| Format | `npm run format` (Prettier: `src/**/*.ts`) |
+| ESLint | No `lint` script in `package.json`; run e.g. `npx eslint src __test__` using `eslint.config.js` |
+
+## Git hooks (Husky)
+
+- **`commit-msg`:** [Conventional Commits](https://www.conventionalcommits.org/) via **`commitlint`** (`.commitlintrc.json`).
+- **`pre-commit`:** Requires **Snyk** (`snyk test --all-projects`) and **Talisman** installed locally. Set `SKIP_HOOK=1` to bypass (documented in the hook).
+
+## PR expectations
+
+- **`npm test`** passes (build + unit tests).
+- **CHANGELOG.md** updated for user-visible changes when maintainers expect it.
+- **Dependencies:** Be mindful of Snyk/SCA workflows; security-relevant bumps should be justified.
+
+## Releases and versioning
+
+- **Package version** lives in **`package.json`** (also reflected in **`CHANGELOG.md`**).
+- **`prepublishOnly`** runs **`npm test`** before publish.
+- **NPM / GitHub Packages:** Publishing is driven by **GitHub release `created`** (`.github/workflows/npm-publish.yml`); requires maintainer secrets (`NPM_TOKEN`, `GIT_TOKEN`). Bump version and changelog in the same change set as the release your team uses.
diff --git a/.cursor/rules/testing.mdc b/.cursor/rules/testing.mdc
new file mode 100644
index 0000000..1b7f67e
--- /dev/null
+++ b/.cursor/rules/testing.mdc
@@ -0,0 +1,38 @@
+---
+description: Jest tests, mocks, reports, and environments for @contentstack/utils
+globs:
+ - __test__/**/*.ts
+alwaysApply: false
+---
+
+# Testing — `@contentstack/utils`
+
+## Framework
+
+- **Jest 29** with **`ts-jest`** preset (`jest.config.ts`).
+- **Environment:** **`jsdom`** (suitable for HTML string assertions and DOM-related behavior).
+
+## Discovery and naming
+
+- **Pattern:** `**/__test__/**/?(*.)+(spec|test).[jt]s?(x)` — this repo uses `*.test.ts` under **`__test__/`**.
+- **Mocks / fixtures:** `__test__/mock/*.ts` — follow existing mock naming (`*-mock.ts`).
+
+## Coverage and reports
+
+- **Coverage** is collected from `src/**` excluding `src/index.ts` (`collectCoverageFrom`).
+- Outputs: **`reports/coverage/`**, **`reports/html/`** (jest-html-reporters), **`reports/junit/`** (jest-junit), **`reports/report.json`** (from `npm test` script).
+
+## Running tests
+
+| Command | Behavior |
+|---------|----------|
+| `npm test` | Runs **`pretest` → build** then Jest (CI-aligned). |
+| `npm run test:debug` | Watch mode, `--runInBand`. |
+
+## Integration / live tests
+
+- **None** in this repo. No `.env` or stack credentials required for **`npm test`**.
+
+## Build dependency
+
+- **`npm test` always builds first** (`pretest`). Ensure **`src/assets/regions.json`** exists or can be downloaded so `endpoints` tests pass.
diff --git a/.cursor/rules/typescript-contentstack-utils.mdc b/.cursor/rules/typescript-contentstack-utils.mdc
new file mode 100644
index 0000000..70f23c6
--- /dev/null
+++ b/.cursor/rules/typescript-contentstack-utils.mdc
@@ -0,0 +1,34 @@
+---
+description: Contentstack utils package patterns — RTE, embedded items, GQL, endpoints (delivery-oriented companion, not CDA/CMA SDK)
+globs:
+ - src/**/*.ts
+alwaysApply: false
+---
+
+# `@contentstack/utils` — domain patterns
+
+This repository implements **companion utilities** for Contentstack **content consumption** scenarios (typically with the **Delivery SDK** and **CDA / GraphQL** responses). It does **not** implement stack configuration, delivery tokens, or HTTP clients—callers fetch entry JSON elsewhere and pass it into these helpers.
+
+## Mental model
+
+| Area | Source anchors | Notes |
+|------|----------------|-------|
+| Render options / callbacks | `src/options/`, `src/render-embedded-objects.ts` | `RenderOption`-style maps: node types, marks, `block` / `inline` embeds, `reference`, `display`, `default`. |
+| JSON RTE → HTML | `src/json-to-html.ts`, `src/nodes/*`, `src/helper/*` | Supercharged RTE path uses `paths` arrays for nested fields (see `README.md`). |
+| Embedded object types | `src/Models/embedded-object.ts`, `src/Models/json-rte-model.ts` | Align typings with shapes coming from **delivery** entry JSON, not management APIs. |
+| GraphQL | `src/gql.ts`, `src/updateAssetURLForGQL.ts` | Docs/comments describe use **after** GraphQL fetches; asset URL rewriting is response-shape specific. |
+| Live Preview / CSLP tags | `src/entry-editable.ts` | `addTags` / exported `addEditableTags` — preserve existing attribute and locale behavior when changing tag generation. |
+| Region endpoints | `src/endpoints.ts` | **`getContentstackEndpoint(region, service?, omitHttps?)`** reads **`src/assets/regions.json`**; throws plain `Error` with human-readable messages on bad region/service. |
+
+## Terminology
+
+- Prefer **CDA / Delivery / JSON RTE / GraphQL** vocabulary when describing behavior—**not** CMA unless you are explicitly discussing something management-only (rare here).
+- **“SDK”** in docs often means **this utils package** or the **Delivery SDK** together—disambiguate in user-facing text.
+
+## Concurrency / IO
+
+- Pure synchronous transforms dominate; no retry or rate-limit layer. Do not add HTTP clients without an explicit product requirement.
+
+## Official docs alignment
+
+- Behavior should stay consistent with current **Content Delivery** / **Live Preview** / **JSON RTE** documentation. When in doubt, cite the relevant Contentstack doc set in PR descriptions rather than guessing CMS semantics.
diff --git a/.cursor/rules/typescript.mdc b/.cursor/rules/typescript.mdc
new file mode 100644
index 0000000..ad2d6fb
--- /dev/null
+++ b/.cursor/rules/typescript.mdc
@@ -0,0 +1,34 @@
+---
+description: TypeScript conventions for @contentstack/utils (src and tests)
+globs:
+ - src/**/*.ts
+ - __test__/**/*.ts
+alwaysApply: false
+---
+
+# TypeScript — `@contentstack/utils`
+
+## Tooling
+
+- **TypeScript ~4.9** (`package.json`, `tsconfig.json`).
+- **Bundler output:** `tsc` emits to `dist/lib` with declarations in `dist/types`; **Rollup** produces `dist/index.es.js` (`rollup.config.js`).
+- **Strict mode** is on with **`strictNullChecks: false`** — new code should still minimize unnecessary null/undefined gaps when touching APIs.
+
+## Layout
+
+- **Library code:** `src/**/*.ts` only (`tsconfig.json` `include`); **tests** are under `__test__/` (excluded from `tsc` program but type-checked via Jest/tsconfig paths).
+- **Public exports:** Maintain **`src/index.ts`** as the single export surface unless intentionally adding secondary entry points.
+
+## Style and lint
+
+- Match existing naming (PascalCase types, camelCase functions, existing file layout under `Models/`, `nodes/`, `helper/`, `options/`).
+- **ESLint** flat config: `eslint.config.js` — `@typescript-eslint` recommended for `__test__`; source files use `js.configs.recommended` baseline.
+- **Prettier:** `npm run format` scopes `src/**/*.ts`; keep formatting consistent when editing tests too.
+
+## JSON / assets
+
+- **`src/assets/regions.json`:** Consumed by `src/endpoints.ts`; populated by **`npm run download-regions`** during `prebuild`. Do not assume the file is committed (see root `.gitignore`).
+
+## Logging
+
+- No shared logger dependency; avoid introducing `console` noise in library paths unless consistent with nearby code.
diff --git a/.github/workflows/check-branch.yml b/.github/workflows/check-branch.yml
new file mode 100644
index 0000000..c63e084
--- /dev/null
+++ b/.github/workflows/check-branch.yml
@@ -0,0 +1,20 @@
+name: 'Check Branch'
+
+on:
+ pull_request:
+
+jobs:
+ check_branch:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Comment PR
+ if: github.base_ref == 'staging' && github.head_ref != 'development'
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ message: |
+ We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the development branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
+ - name: Check branch
+ if: github.base_ref == 'staging' && github.head_ref != 'development'
+ run: |
+ echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the development branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
+ exit 1
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1ddd95c..33b9343 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,22 +1,30 @@
-# This is a basic workflow to help you get started with Actions
-
name: Unit-Test-CI
-# Controls when the action will run. Triggers the workflow on push or pull request
-# events but only for the master branch
on:
push:
- branches: [ master ]
+ branches: [ master, staging, development ]
pull_request:
- branches: [ master ]
+ branches: [ master, staging, development ]
jobs:
- build:
+ build-test:
runs-on: ubuntu-latest
- # Steps represent a sequence of tasks that will be executed as part of the job
steps:
- - uses: actions/checkout@v2
- - name: Install modules
- run: npm install
- - name: Run tests
- run: npm run test
+ - uses: actions/checkout@v3
+ - uses: ArtiomTr/jest-coverage-report-action@v2
+ id: coverage-utils-js
+ with:
+ output: comment, report-markdown
+ - uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ header: Contentstack Utils JS Coverage
+ recreate: true
+ message: ${{ steps.coverage-utils-js.outputs.report }}
+ - name: Test Report
+ uses: dorny/test-reporter@v1
+ if: success() || failure()
+ with:
+ name: JEST Tests
+ path: reports/junit/jest-*.xml
+ reporter: jest-junit
+ fail-on-error: true
\ No newline at end of file
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..3566f96
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,68 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: '*'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'javascript' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # ℹ️ Command-line programs to run using the OS shell.
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
+
+ # - run: |
+ # echo "Run, Build Application using script"
+ # ./location_of_script_within_repo/buildscript.sh
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/issues-jira.yml b/.github/workflows/issues-jira.yml
new file mode 100644
index 0000000..7bf0469
--- /dev/null
+++ b/.github/workflows/issues-jira.yml
@@ -0,0 +1,31 @@
+name: Create Jira Ticket for Github Issue
+
+on:
+ issues:
+ types: [opened]
+
+jobs:
+ issue-jira:
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Login to Jira
+ uses: atlassian/gajira-login@master
+ env:
+ JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
+ JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
+ JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
+
+ - name: Create Jira Issue
+ id: create_jira
+ uses: atlassian/gajira-create@master
+ with:
+ project: ${{ secrets.JIRA_PROJECT }}
+ issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
+ summary: Github | Issue | ${{ github.event.repository.name }} | ${{ github.event.issue.title }}
+ description: |
+ *GitHub Issue:* ${{ github.event.issue.html_url }}
+
+ *Description:*
+ ${{ github.event.issue.body }}
+ fields: "${{ secrets.ISSUES_JIRA_FIELDS }}"
\ No newline at end of file
diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml
new file mode 100644
index 0000000..eab0907
--- /dev/null
+++ b/.github/workflows/npm-publish.yml
@@ -0,0 +1,34 @@
+# This workflow will publish a package to GitHub Packages when a release is created
+# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
+
+name: Publish package to NPM repository
+on:
+ release:
+ types: [created]
+
+jobs:
+ publish-npm:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '22.x'
+ registry-url: 'https://registry.npmjs.org'
+ - run: npm ci
+ - run: npm publish
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ publish-git:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '22.x'
+ registry-url: 'https://npm.pkg.github.com'
+ scope: '@contentstack'
+ - run: npm ci
+ - run: npm publish --access public
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.GIT_TOKEN }}
diff --git a/.github/workflows/policy-scan.yml b/.github/workflows/policy-scan.yml
new file mode 100644
index 0000000..ff25923
--- /dev/null
+++ b/.github/workflows/policy-scan.yml
@@ -0,0 +1,46 @@
+name: Checks the security policy and configurations
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+jobs:
+ security-policy:
+ if: github.event.repository.visibility == 'public'
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ shell: bash
+ steps:
+ - uses: actions/checkout@master
+ - name: Checks for SECURITY.md policy file
+ run: |
+ if ! [[ -f "SECURITY.md" || -f ".github/SECURITY.md" ]]; then exit 1; fi
+ security-license:
+ if: github.event.repository.visibility == 'public'
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ shell: bash
+ steps:
+ - uses: actions/checkout@master
+ - name: Checks for License file
+ run: |
+ expected_license_files=("LICENSE" "LICENSE.txt" "LICENSE.md" "License.txt")
+ license_file_found=false
+ current_year=$(date +"%Y")
+
+ for license_file in "${expected_license_files[@]}"; do
+ if [ -f "$license_file" ]; then
+ license_file_found=true
+ # check the license file for the current year, if not exists, exit with error
+ if ! grep -q "$current_year" "$license_file"; then
+ echo "License file $license_file does not contain the current year."
+ exit 2
+ fi
+ break
+ fi
+ done
+
+ if [ "$license_file_found" = false ]; then
+ echo "No license file found. Please add a license file to the repository."
+ exit 1
+ fi
\ No newline at end of file
diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml
new file mode 100644
index 0000000..2307d48
--- /dev/null
+++ b/.github/workflows/sca-scan.yml
@@ -0,0 +1,18 @@
+name: Source Composition Analysis Scan
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+jobs:
+ security-sca:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - name: Run Snyk to check for vulnerabilities
+ uses: snyk/actions/node@master
+ env:
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
+ with:
+ args: --all-projects --fail-on=all
+ json: true
+ continue-on-error: true
+ - uses: contentstack/sca-policy@main
diff --git a/.gitignore b/.gitignore
index 0fb2594..582c800 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,16 +1,19 @@
*.DS_Store
examples/*
-node_modules/*
+node_modules/
.idea/*
-reports/*
-apidocs-templates/*
-testcase-report/*
+reports/
+apidocs-templates/
+testcase-report/
test/smtpconfig.js/*
test/config.js/*
test/sync_config.js/*
test/report.json/*
tap-html.html
*html-report
-dist/*
+dist/
coverage/
-.dccache
\ No newline at end of file
+.dccache
+snyk_output.log
+talisman_output.log
+regions.json
\ No newline at end of file
diff --git a/.husky/commit-msg b/.husky/commit-msg
new file mode 100755
index 0000000..80416c7
--- /dev/null
+++ b/.husky/commit-msg
@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+npx --no-install commitlint --edit "$1"
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100755
index 0000000..4f1fbbc
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,69 @@
+#!/usr/bin/env sh
+# Pre-commit hook to run Snyk and Talisman scans, completing both before deciding to commit
+
+# Function to check if a command exists
+command_exists() {
+ command -v "$1" >/dev/null 2>&1
+}
+
+# Check if Snyk is installed
+if ! command_exists snyk; then
+ echo "Error: Snyk is not installed. Please install it and try again."
+ exit 1
+fi
+
+# Check if Talisman is installed
+if ! command_exists talisman; then
+ echo "Error: Talisman is not installed. Please install it and try again."
+ exit 1
+fi
+
+# Allow bypassing the hook with an environment variable
+if [ "$SKIP_HOOK" = "1" ]; then
+ echo "Skipping Snyk and Talisman scans (SKIP_HOOK=1)."
+ exit 0
+fi
+
+# Initialize variables to track scan results
+snyk_failed=false
+talisman_failed=false
+
+# Run Snyk vulnerability scan
+echo "Running Snyk vulnerability scan..."
+snyk test --all-projects > snyk_output.log 2>&1
+snyk_exit_code=$?
+
+if [ $snyk_exit_code -eq 0 ]; then
+ echo "Snyk scan passed: No vulnerabilities found."
+elif [ $snyk_exit_code -eq 1 ]; then
+ echo "Snyk found vulnerabilities. See snyk_output.log for details."
+ snyk_failed=true
+else
+ echo "Snyk scan failed with error (exit code $snyk_exit_code). See snyk_output.log for details."
+ snyk_failed=true
+fi
+
+# Run Talisman secret scan (continues even if Snyk failed)
+echo "Running Talisman secret scan..."
+talisman --githook pre-commit > talisman_output.log 2>&1
+talisman_exit_code=$?
+
+if [ $talisman_exit_code -eq 0 ]; then
+ echo "Talisman scan passed: No secrets found."
+else
+ echo "Talisman scan failed (exit code $talisman_exit_code). See talisman_output.log for details."
+ talisman_failed=true
+fi
+
+# Evaluate results after both scans
+if [ "$snyk_failed" = true ] || [ "$talisman_failed" = true ]; then
+ echo "Commit aborted due to issues found in one or both scans."
+ [ "$snyk_failed" = true ] && echo "- Snyk issues: Check snyk_output.log"
+ [ "$talisman_failed" = true ] && echo "- Talisman issues: Check talisman_output.log"
+ exit 1
+fi
+
+# If both scans pass, allow the commit
+echo "All scans passed. Proceeding with commit.cd ."
+rm -f snyk_output.log talisman_output.log
+exit 0
\ No newline at end of file
diff --git a/.jsdoc.json b/.jsdoc.json
deleted file mode 100644
index b29cc4e..0000000
--- a/.jsdoc.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "tags": {
- "allowUnknownTags": true,
- "dictionaries": ["jsdoc"]
- },
- "source": {
- "include": ["src"],
- "excludePattern": "(node_modules/|jsdocs)"
- },
- "templates": {
- "cleverLinks": false,
- "monospaceLinks": true
- },
- "opts": {
- "destination": "./jsdocs/",
- "encoding": "utf8",
- "private": true,
- "recurse": true,
- "template": "./node_modules/docdash",
- "sort": false
- },
- "docdash": {
- "static": true,
- "sort": false
- }
-}
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
index 33e1639..46aa587 100644
--- a/.npmignore
+++ b/.npmignore
@@ -2,5 +2,8 @@ src
tsconfig.json
tslint.json
.prettierrc
+.talismanrc
jestconfig.json
-CODEOWNERS
\ No newline at end of file
+jest.config.ts
+CODEOWNERS
+reports/
\ No newline at end of file
diff --git a/.talismanrc b/.talismanrc
index dbc73fd..78e5520 100644
--- a/.talismanrc
+++ b/.talismanrc
@@ -1,3 +1,34 @@
fileignoreconfig:
+- filename: .github/workflows/secrets-scan.yml
+ ignore_detectors:
+ - filecontent
- filename: package-lock.json
- checksum: 9746d3b1ac67da5dc0f3ec6f8798166bc8b9c1e4c736de01f7c52b2f9cc194be
+ checksum: 85c2c0c45183180b6793501e09529c5396a66a73e876ade9a80f625b8d174102
+- filename: __test__/find-render-content.test.ts
+ checksum: c2508ae1fb2b20f6fe3d354558704076ecdcbe7e1ece46addaa5eb8354e60233
+- filename: __test__/json-to-html.test.ts
+ checksum: 8ef368136341314dc597a1e0a3a7b45ac9255897b376395db5e7e032b661682e
+- filename: __test__/entry-editable.test.ts
+ checksum: 32e5e047c56ef0e74456eb6275c6ea8d2ffbef38901bc3eb97ae0a62e431f5a2
+- filename: src/entry-editable.ts
+ checksum: e130c19526679f220073ed9cc918fa28906ebf99c33c00cf8ee58f2178caddcf
+- filename: .husky/pre-commit
+ checksum: 5baabd7d2c391648163f9371f0e5e9484f8fb90fa2284cfc378732ec3192c193
+- filename: src/endpoints.ts
+ checksum: 721a1df93b02d04c1c19a76c171fe2748e4abb1fc3e43452e76fecfd8f384751
+- filename: src/options/default-node-options.ts
+ checksum: d455330cc4f9306889fb299171364a37ad2c3bafe1fbd334033edc94f21694a6
+- filename: package.json
+ checksum: 033eb21070795be5b426183f52d784347110fcb724bc9f8d63f94898ac5f0086
+- filename: src/Models/metadata-model.ts
+ checksum: a101e109db1ec6ee0cb16a116f9b099e547c3104881e4fa1eaef2849e2d0aaf0
+- filename: src/json-to-html.ts
+ checksum: a843710fc9f54bf4c7996f39561dc66491d62a9d9eeca50fa2c7c37bd6141f53
+- filename: src/render-embedded-objects.ts
+ checksum: 35d56d4f7b625611fef18414fccdbff014c1d90d02e17eb0efa4d6166b73e23b
+- filename: .cursor/rules/code-review.mdc
+ checksum: 43d4fddb706e5ad6c92fe0af30bd5f44eec9b83c31dc93d3d4cc5e6208d351cc
+- filename: .cursor/rules/dev-workflow.md
+ checksum: b9a4d68439ce9564730506ab6c4712f5034a645858bdb78ac57e43ba183cb981
+- filename: skills/code-review/SKILL.md
+ checksum: 4ec638a87a795e5cc0b0e66b569e04749cb27f9d3be29d4ea69f56b48225c943
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..0798e0e
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,52 @@
+# Agent guidance — `@contentstack/utils`
+
+## What this package is
+
+**[@contentstack/utils](https://www.npmjs.com/package/@contentstack/utils)** (`contentstack-utils-javascript`) is a **JavaScript/TypeScript utilities library** for Contentstack. It is **not** the Content Delivery API (CDA) SDK or the Content Management API (CMA) SDK. It focuses on **JSON RTE / Supercharged RTE** rendering (`jsonToHTML`), **embedded entry and asset** rendering (`render`, `renderContent`), **GraphQL-oriented helpers** (`GQL`, `updateAssetURLForGQL`), **Live Preview–style editable tags** (`addEditableTags` / `addTags`), and **region endpoint lookup** (`getContentstackEndpoint`). Typical usage is **alongside** the Delivery SDK (see repository `README.md` examples with `@contentstack/delivery-sdk`).
+
+- **Repository:** [github.com/contentstack/contentstack-utils-javascript](https://github.com/contentstack/contentstack-utils-javascript)
+
+## Tech stack
+
+| Area | Details |
+|------|---------|
+| Language | TypeScript **4.9** (`tsconfig.json`, `strict: true`, `strictNullChecks: false`) |
+| Build | **TypeScript** (`tsc`) → `dist/lib`; **Rollup** (`rollup -c`) → `dist/index.es.js`; types in `dist/types/` |
+| Test | **Jest 29** + **ts-jest**, **jsdom** environment (`jest.config.ts`) |
+| Lint / format | **ESLint 9** flat config (`eslint.config.js`); **Prettier 3** (`npm run format`) — there is **no** `lint` npm script; use `npx eslint` as needed |
+| Runtime HTTP / JSON for API calls | **None** in library code; `regions.json` is a **build-time** asset (see below) |
+
+## Source layout and public API
+
+| Role | Path |
+|------|------|
+| Public entry (sources) | `src/index.ts` |
+| Options / render types | `src/options/` |
+| RTE / node model | `src/Models/`, `src/nodes/` |
+| Helpers | `src/helper/` |
+| GQL + asset URL rewrite | `src/gql.ts`, `src/updateAssetURLForGQL.ts` |
+| Endpoints helper | `src/endpoints.ts` + `src/assets/regions.json` (generated; see build) |
+| Published bundle | `dist/` (per `package.json` `main` / `types`) |
+
+## Common commands
+
+| Command | Purpose |
+|---------|---------|
+| `npm run build` | Cleans `dist`, ensures `src/assets/regions.json` (download or warning), runs `tsc` + Rollup |
+| `npm test` | Runs `pretest` → **build**, then Jest with coverage; outputs under `reports/` |
+| `npm run test:debug` | Jest watch, in-band |
+| `npm run format` | Prettier on `src/**/*.ts` |
+| `npm run download-regions` | Fetches `regions.json` only (used by `prebuild`) |
+
+**Tests:** Unit tests only, under `__test__/**/*.test.ts`, with mocks in `__test__/mock/`. There are **no** live/integration tests requiring stack credentials in this repository.
+
+## Credentials / environment
+
+- **Unit tests:** No API keys or `.env` required.
+- **Build:** `download-regions` calls a public URL (`artifacts.contentstack.com`); offline builds may warn and rely on an existing `src/assets/regions.json`. Note `regions.json` is listed in `.gitignore`; clones may need a successful `npm run build` (or manual file) before tests pass.
+- **Publish:** GitHub release workflow uses `NPM_TOKEN` / `GIT_TOKEN` secrets (maintainers only).
+
+## More detail for AI / IDE rules
+
+- [`.cursor/rules/README.md`](.cursor/rules/README.md) — Cursor rules index (`alwaysApply`, globs, when to use).
+- [`skills/README.md`](skills/README.md) — Topic skills (testing, code review, package mental model).
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8c22d9..4121676 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,135 @@
# Changelog
+## [1.9.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.9.0)
+- Feat: Variant utilities `getVariantAliases` and `getVariantMetadataTags` to read variant alias strings from CDA entry `publish_details.variants` (requires fetches with the `x-cs-variant-uid` header set to aliases per [CDA variants](https://www.contentstack.com/docs/developers/apis/content-delivery-api#get-all-entry-variants)).
+
+## [1.8.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.8.0)
+- Fix: JSON-to-HTML now outputs valid HTML for nested lists when JSON RTE exports the nested list as a sibling of the preceding list item (`
`). The SDK folds such sibling ``/`
` nodes into the previous `
` so the rendered HTML has the nested list inside the parent list item (PROD-2115).
+
+## [1.7.1](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.7.1)
+- Fix: Guard against null/undefined in getTag to prevent TypeError when addEditableTags/addTags processes entries with null content (Issue #193)
+
+## [1.7.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.7.0)
+- Added option in addTags to disable lowercasing of locale
+
+## [1.6.3](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.6.3)
+ - Refactor: Simplified endpoints.ts to use compile-time JSON import instead of runtime file loading
+ - Build: Updated build process to download regions.json to src/assets directory
+ - Test: Added comprehensive test coverage for endpoints.ts
+ - Chore: Removed postinstall/postupdate scripts and simplified package.json scripts
+
+## [1.6.2](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.6.2)
+ - Fix: Missing attr in node does not add empty attr
+
+## [1.6.1](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.6.1)
+ - Fix: Improved error handling in getContentstackEndpoint
+ - Fix: Enhanced error messages for better debugging
+ - Refactor: Removed redundant try/catch wrapper and improved code structure
+ - Test: Updated and improved test coverage for error scenarios
+
+## [1.6.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.6.0)
+ - Feat: Adds Helper functions for Contentstack Endpoints
+
+## [1.5.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.5) (2025-10-27)
+ - fix: handle null and undefined values in getTag function
+ - fix: refernce variant cslp generation fix
+
+## [1.4.4](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.4) (2025-09-24)
+ -Enhance break and newline handling, update dependencies
+
+## [1.4.3](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.3) (2025-09-22)
+ - Fix data-cslp generation logic in case of applied_variants
+
+## [1.4.2](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.2) (2025-09-01)
+ - Improve null checks in find embedded entry and find embedded asset functions
+
+## [1.4.1](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.1) (2025-05-26)
+ - Chore: Handle case sensitivity for contentType and locale
+
+## [1.4.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.4.0) (2025-04-21)
+ - Fix: customRenderOption for entry-embedded-as-link nodes
+
+## [1.3.20](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.20) (2025-02-24)
+ - Fix: Added data-mtec as allowed attribute
+
+## [1.3.19](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.19) (2025-02-24)
+ - Fix: Added fix for html injection in keys and values of attributes
+
+## [1.3.18](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.18) (2025-02-17)
+ - Fix: Added fix for html injection
+
+## [1.3.17](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.17) (2025-02-11)
+ - Enh: updateAssetURLForGQL update for multilpe entries
+ - Fix: Added support of br tag (\n) after just enter
+
+## [1.3.16](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.16) (2025-01-27)
+ - Enh: Added support for colgroup and col tags inside table tag
+ - Fix: Updated rendorOption code block in reaadme file
+
+## [1.3.15](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.15) (2024-11-18)
+ - Fix: Added Table merge cell functionality
+
+## [1.3.14](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.14) (2024-11-12)
+ - Fix: Add data-type attr to inlineCode
+
+## [1.3.13](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.13) (2024-10-22)
+ - Enh: Node version bump
+
+## [1.3.12](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.12) (2024-09-30)
+ - Fix: addTags methods changes for Variants
+
+## [1.3.11](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.11) (2024-08-21)
+ - Fix: Reference to HTML fixed to support assets that are referenced
+
+## [1.3.10](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.10) (2024-07-08)
+ - Enhancement: Update default node options
+
+## [1.3.9](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.9) (2024-07-08)
+ - Fix: SRE vulnerabilities fixed
+
+## [1.3.8](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.8) (2024-06-24)
+ - Feat: Support for Image type asset in JsonToHtml
+
+## [1.3.7](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.7) (2024-06-18)
+ - Fix: Cheerio and DOMPurify packages removed
+
+## [1.3.6](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.6) (2024-05-31)
+ - Fix: handle case of td or th nodes with attr void:true
+
+## [1.3.5](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.5) (2024-05-31)
+ - Feat: updateAssetURLForGQL added
+ - Fix: add rowspan and colspan attribute to td and th nodes
+
+## [1.3.4](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.4) (2024-05-13)
+ - Fixes for vulnerability issues related to regular expression and options
+
+## [1.3.3](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.3) (2024-02-28)
+ - Fix for parsing nested children when entry is referenced as link
+
+## [1.3.2](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.2) (2024-02-14)
+ - Added style attribute fragment as
+
+## [1.3.1](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.1) (2023-12-13)
+ - Text level rendering suppport
+ - Dependencies update
+ - Multiple array support
+
+## [1.3.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.0) (2023-05-02)
+ - JSON RTE asset nested in reference field
+ - Bug fixes
+
+## [1.2.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.2.0) (2023-02-27)
+ - Added Dom parser for HTML parsing
+
+## [1.1.3](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.1.3) (2022-10-19)
+ - Resolving embedded items in Json RTE without include Embedded query
+
+## [1.1.2](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.1.2) (2022-04-21)
+ - Image link and embed tag support for attribute url
+
+## [1.1.1](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.1.1) (2021-12-08)
+ - Render option support added for new tags
+
## [1.1.0](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.1.0) (2021-10-19)
- Live preview edit tags support added
diff --git a/CODEOWNERS b/CODEOWNERS
index d81d223..4beb650 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -1 +1,11 @@
-* @contentstack/security-admin @contentstack/sdk-admin
+* @contentstack/devex-pr-reviewers
+
+.github/workflows/sca-scan.yml @contentstack/security-admin
+
+.github/workflows/codeql-anaylsis.yml @contentstack/security-admin
+
+**/.snyk @contentstack/security-admin
+
+.github/workflows/policy-scan.yml @contentstack/security-admin
+
+.github/workflows/issues-jira.yml @contentstack/security-admin
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..477c426
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,120 @@
+# Contributing to Contentstack Utils JavaScript
+
+Thank you for your interest in contributing to Contentstack Utils JavaScript. This document provides guidelines and instructions for contributing.
+
+## Pull Request Target Branch
+
+**All pull requests must be raised against the `development` branch.**
+
+Do not open PRs against `master` or `staging`. Create your feature or fix branch from `development`, and open your PR to merge into `development`. Maintainers will handle promotion to other branches after review.
+
+## Getting Started
+
+### Prerequisites
+
+- **Node.js** 10 or later
+- **npm** (comes with Node.js)
+- **Git**
+
+### Development Setup
+
+1. **Fork the repository** on GitHub and clone your fork locally:
+
+ ```bash
+ git clone https://github.com/YOUR_USERNAME/contentstack-utils-javascript.git
+ cd contentstack-utils-javascript
+ ```
+
+2. **Add the upstream remote** (optional, for syncing with the main repo):
+
+ ```bash
+ git remote add upstream https://github.com/contentstack/contentstack-utils-javascript.git
+ ```
+
+3. **Create a branch from `development`** for your work:
+
+ ```bash
+ git fetch upstream
+ git checkout development
+ git pull upstream development
+ git checkout -b your-feature-or-fix-name
+ ```
+
+4. **Install dependencies:**
+
+ ```bash
+ npm install
+ ```
+
+5. **Build the project:**
+
+ ```bash
+ npm run build
+ ```
+
+## Development Workflow
+
+### Running Tests
+
+- Run the full test suite: `npm test`
+- Run tests in watch mode (for development): `npm run test:debug`
+
+All tests must pass before submitting a PR. New features and bug fixes should include or update tests as appropriate.
+
+### Code Style
+
+- **ESLint:** The project uses ESLint. Fix auto-fixable issues with your editor or by running the linter.
+- **Prettier:** Code is formatted with Prettier. Use `npm run format` to format `src/**/*.ts`.
+
+Ensure your code adheres to the existing style so that CI and pre-commit checks pass.
+
+### Commit Messages
+
+This project uses [Conventional Commits](https://www.conventionalcommits.org/) enforced by Commitlint.
+
+- Use a **type** and a **short subject** (e.g. `feat: add jsonToHTML option`, `fix: handle empty nodes`).
+- Allowed types include: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`, `sample`.
+- Subject should be lowercase, imperative, and not end with a period.
+- Add a blank line and a longer body when the change needs more explanation.
+
+Husky runs a commit-msg hook to validate commit messages. Invalid messages will be rejected.
+
+### Pre-commit Hooks
+
+Husky is used for Git hooks. Before each commit, the pre-commit hook runs. Ensure your working tree is clean and that tests and lint pass locally to avoid failed commits.
+
+## Submitting Changes
+
+1. **Keep your branch up to date** with `development`:
+
+ ```bash
+ git fetch upstream
+ git rebase upstream/development
+ ```
+
+2. **Open a Pull Request** against the **`development`** branch (not `master` or `staging`).
+
+3. **Fill out the PR template** (if one exists) and provide:
+ - A clear title and description of the change
+ - Link to any related issue
+ - Summary of testing done
+
+4. **Address review feedback** promptly. Maintainers may request changes before merging.
+
+5. **Do not force-push** after review has started unless the maintainer asks you to; use new commits for updates when possible so review history is preserved.
+
+## Reporting Issues
+
+- Use the GitHub issue tracker for bugs and feature requests.
+- Search existing issues first to avoid duplicates.
+- Include steps to reproduce for bugs, and your environment (Node version, OS).
+- For security issues, see [SECURITY.md](SECURITY.md).
+
+## Additional Resources
+
+- [README](README.md) – Project overview and usage
+- [CHANGELOG](CHANGELOG.md) – Version history and changes
+- [SECURITY](SECURITY.md) – Security and vulnerability reporting
+- [CODEOWNERS](CODEOWNERS) – Code ownership and review expectations
+
+Thank you for contributing.
diff --git a/LICENSE b/LICENSE
index d4dfd97..9535c61 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,6 @@
-The MIT License (MIT)
+MIT License
-
-Copyright (c) 2016-2022 Contentstack
+Copyright (c) 2016-2026 Contentstack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -10,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 9496be3..8bcfd98 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,3 @@
-
-
-
-
-
# Contentstack JavaScript Utils SDK:
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. Read More.
@@ -15,7 +10,6 @@ To get started with JavaScript, you will need the following:
- Node.js 10 or later
## SDK Installation and Setup
-> Note: If you are using JavaScript Contentstack SDK, you don’t need to run the command as ‘@contentstack/utils’ is already imported in the SDK.
Use the following command to install Contentstack JavaScript Utils SDK:
```sh
@@ -27,49 +21,62 @@ Let’s learn how you can use Utils SDK to render RTE embedded items and Superch
### Create Render Option
To render embedded items on the front-end, use the renderOptions function, and define the UI elements you want to show in the front-end of your website, as shown in the example below:
```js
-const renderOptions = {
- // to render Supercharged RTE NodeType content like paragraph, link, table, order list, un-order list and more.
- p: (node, next) => {
- `
${next(node.children)}
` // you will need to call next function with node children contents
- }
- h1: (node, next) => {
- `
${next(node.children)}
` // you will need to call next function with node children contents
- }
- // to render Supercharged RTE MarkType content like bold, italic, underline, strikethrough, inlineCode, subscript, and superscript
- bold: (text) => {
- `${next(node.children)}`
- }
- // to render block-type embedded items
- block: {
- 'product': (item, metadata) => {
- `
-
${item.title}
-
-
${item.price}
-
`
- },
- // to render the default
- '$default': (item, metadata) => {
- `
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem.
"
+const paragraphHtmlWithNewLine = "
Ritesh test
Shift enter single enter
"
const h1Html = "
Lorem ipsum dolor sit amet.
"
const h2Html = "
Vestibulum a ligula eget massa sagittis aliquam sit amet quis tortor.
"
const h3Html = "
Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.
"
const h4Html = "
MaNullam feugiat turpis quis elit interdum, vitae laoreet quam viverra
"
const h5Html = "
Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.
"
const h6Html = "
Nunc porta diam vitae purus semper, ut consequat lorem vehicula.
"
-const orderListHtml = "
Morbi in quam molestie, fermentum diam vitae, bibendum ipsum.
Pellentesque mattis lacus in quam aliquam congue
Integer feugiat leo dignissim, lobortis enim vitae, mollis lectus.
Sed in ante lacinia, molestie metus eu, fringilla sapien.
"
-const unorderListHtml = "
Sed quis metus sed mi hendrerit mollis vel et odio.
Integer vitae sem dignissim, elementum libero vel, fringilla massa.
Integer imperdiet arcu sit amet tortor faucibus aliquet.
Aenean scelerisque velit vitae dui vehicula, at congue massa sagittis.
"
+const orderListHtml = "
Morbi in quam molestie, fermentum diam vitae, bibendum ipsum.
Pellentesque mattis lacus in quam aliquam congue
Integer feugiat leo dignissim, lobortis enim vitae, mollis lectus.
Sed in ante lacinia, molestie metus eu, fringilla sapien.
"
+const unorderListHtml = "
Sed quis metus sed mi hendrerit mollis vel et odio.
Integer vitae sem dignissim, elementum libero vel, fringilla massa.
Integer imperdiet arcu sit amet tortor faucibus aliquet.
Aenean scelerisque velit vitae dui vehicula, at congue massa sagittis.
"
+const imagetags = "The Batman"
+const escapeHtml = "
<p>Welcome to Contentstack! <script>console.log(/"Hello from Contentstack!/");</script> Explore our platform to create, manage, and publish content seamlessly.</p>
"
+const breakTestHtml = "
Normal text with break tag after break.
"
+const newlineBreakTestHtml = "
Text before newline break Text after newline break