|
| 1 | +# Contentstack Utils (Java) – Agent guide |
| 2 | + |
| 3 | +This document is the main entry point for AI agents working in **contentstack-utils-java**. Repo: [contentstack-utils-java](https://github.com/contentstack/contentstack-utils-java). |
| 4 | + |
| 5 | +## Project |
| 6 | + |
| 7 | +- **Name:** Contentstack Utils (Java) — Maven artifact `com.contentstack.sdk:utils`. |
| 8 | +- **Purpose:** Library for **rendering Rich Text Editor (RTE) content and embedded items** from Contentstack entry JSON (REST/CDA-style with `_embedded_items`) and GraphQL-shaped responses. It does **not** perform HTTP calls or manage API keys; use it with the [Contentstack Java Delivery SDK](https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/java) after fetching entries. |
| 9 | + |
| 10 | +## Tech stack |
| 11 | + |
| 12 | +- **Language:** Java **17** (`maven-compiler-plugin` `<release>17</release>` in `pom.xml`). |
| 13 | +- **Build:** Maven. |
| 14 | +- **Testing:** JUnit 4, Maven Surefire, JaCoCo (see `pom.xml`; Surefire uses `testFailureIgnore`). |
| 15 | +- **JSON / HTML:** `org.json`, Jsoup, `commons-text`; `javax.validation` API; `spring-web` is a compile dependency (not a public HTTP client surface for this module). |
| 16 | + |
| 17 | +## Main entry points |
| 18 | + |
| 19 | +- **`Contentstack.stack(...)`** — Not in this repo; provided by the Java SDK (see root `README.md`). |
| 20 | +- **`com.contentstack.utils.Utils`** — `render`, `renderContent`, `jsonToHTML`, variant helpers, etc. |
| 21 | +- **`com.contentstack.utils.GQL`** — GraphQL entry `jsonToHTML`. |
| 22 | +- **`com.contentstack.utils.render.DefaultOption`** / **`interfaces.Option`** — custom RTE/embedded rendering. |
| 23 | +- **Paths:** `src/main/java/com/contentstack/utils/` (production), `src/test/java/com/contentstack/utils/` (tests). Optional **`sample/`** demonstrates Delivery SDK + Utils together. |
| 24 | + |
| 25 | +## Commands |
| 26 | + |
| 27 | +- **Build and test:** `mvn clean test` |
| 28 | +- **Compile only:** `mvn clean compile` |
| 29 | +- **Single test class:** `mvn test -Dtest=UtilTests` |
| 30 | +- **Javadoc (optional):** `mvn javadoc:javadoc` |
| 31 | + |
| 32 | +CI uses Java **17** (`.github/workflows/maven-publish.yml`). **Snyk** runs on PRs (`.github/workflows/sca-scan.yml`). |
| 33 | + |
| 34 | +## Rules and skills |
| 35 | + |
| 36 | +### `.cursor/rules/` |
| 37 | + |
| 38 | +| Resource | Role | |
| 39 | +|----------|------| |
| 40 | +| **README.md** | Index of all rules and when they apply | |
| 41 | +| **dev-workflow.md** | Branches, tests, PRs, optional TDD | |
| 42 | +| **java.mdc** | Applies to `**/*.java`: Java 17, `com.contentstack.utils`, JSON/Jsoup | |
| 43 | +| **contentstack-utils-java.mdc** | Applies to `src/main/java/**/*.java`: Utils/GQL, RTE, embedded JSON | |
| 44 | +| **testing.mdc** | Applies to `src/test/**/*.java`: JUnit 4, fixtures, JaCoCo | |
| 45 | +| **code-review.mdc** | Always applied: PR checklist | |
| 46 | + |
| 47 | +### `skills/` |
| 48 | + |
| 49 | +| Skill | Use when | |
| 50 | +|-------|----------| |
| 51 | +| **contentstack-utils-java** | Changing RTE, embedded items, `Utils` / `GQL`, `DefaultOption`, callbacks | |
| 52 | +| **testing** | Adding or refactoring tests and fixtures | |
| 53 | +| **code-review** | Reviewing PRs or pre-merge self-review | |
| 54 | +| **framework** | Editing `pom.xml`, plugins, publishing, or `sample/` dependency management | |
| 55 | + |
| 56 | +See **`skills/README.md`** for details. For editor-wide Cursor user skills (if configured), this repo’s project skills live only under **`./skills/`**. |
| 57 | + |
| 58 | +## Official documentation |
| 59 | + |
| 60 | +- [Contentstack Developers](https://www.contentstack.com/docs/) |
| 61 | +- [Content Delivery API](https://www.contentstack.com/docs/apis/content-delivery-api/) |
| 62 | +- Root **`README.md`** — Maven coordinates and embedded-items examples |
0 commit comments