|
| 1 | +# AGENTS.md — AI / automation context |
| 2 | + |
| 3 | +## Project |
| 4 | + |
| 5 | +| | | |
| 6 | +|---|---| |
| 7 | +| **Name** | **`@contentstack/delivery-sdk`** (npm) — **Contentstack TypeScript Content Delivery SDK** | |
| 8 | +| **Purpose** | TypeScript client for the **Content Delivery API (CDA)**: stacks, entries, assets, queries, sync, live preview, cache. Built on **`@contentstack/core`** (**Axios** HTTP + retry helpers) and **`@contentstack/utils`**. | |
| 9 | +| **Repository** | [contentstack/contentstack-typescript](https://github.com/contentstack/contentstack-typescript.git) | |
| 10 | + |
| 11 | +## Tech stack |
| 12 | + |
| 13 | +| Area | Details | |
| 14 | +|------|---------| |
| 15 | +| **Language** | **TypeScript**, **ES modules** (`"type": "module"`) | |
| 16 | +| **Runtime** | Node **>= 18** (`package.json` `engines`) | |
| 17 | +| **Build** | **Rollup** (`npm run build:rollup`) + **`tsc`** declarations (`config/tsconfig.decl-esm.json`) → **`dist/modern/`** | |
| 18 | +| **Tests** | **Jest** + **ts-jest**: **`test/unit`**, **`test/api`**, **`test/browser`**; **Playwright** e2e (`test/e2e`, `npm run test:e2e`) | |
| 19 | +| **Lint** | **ESLint** (`.eslintrc.json`) | |
| 20 | + |
| 21 | +## Source layout |
| 22 | + |
| 23 | +| Path | Role | |
| 24 | +|------|------| |
| 25 | +| `src/stack/contentstack.ts` | **`stack(config)`** factory — wires **`httpClient`** from **`@contentstack/core`**, region/host, live preview | |
| 26 | +| `src/stack/stack.ts` | **Stack** class | |
| 27 | +| `src/query/**` | Queries (entry, asset, taxonomy, content type, …) | |
| 28 | +| `src/entries/**`, `src/assets/**`, `src/sync/**`, `src/cache/**` | Domain modules | |
| 29 | +| `src/common/**` | Types, utils, errors, pagination | |
| 30 | +| `src/index.ts` | Public package exports | |
| 31 | +| `test/utils/stack-instance.ts` | **`stackInstance()`** — loads **dotenv**, **`HOST`**, **`API_KEY`**, **`DELIVERY_TOKEN`**, **`ENVIRONMENT`**, optional live-preview vars | |
| 32 | + |
| 33 | +## Common commands |
| 34 | + |
| 35 | +```bash |
| 36 | +npm install |
| 37 | +npm run build |
| 38 | +npm run test:unit # jest ./test/unit |
| 39 | +npm run test:api # live API — needs .env (see stack-instance) |
| 40 | +npm run test:browser |
| 41 | +npm run test:e2e # Playwright (builds browser bundle first) |
| 42 | +npm run test:all # unit + browser + api |
| 43 | +``` |
| 44 | + |
| 45 | +## Environment variables (API / integration tests) |
| 46 | + |
| 47 | +Loaded via **`dotenv`** in **`test/utils/stack-instance.ts`**: |
| 48 | + |
| 49 | +- **`HOST`**, **`API_KEY`**, **`DELIVERY_TOKEN`**, **`ENVIRONMENT`** — stack connection |
| 50 | +- Optional: **`PREVIEW_TOKEN`**, **`LIVE_PREVIEW_HOST`** for live preview tests |
| 51 | + |
| 52 | +Do not commit secrets. |
| 53 | + |
| 54 | +## Further guidance |
| 55 | + |
| 56 | +- **Cursor rules:** [`.cursor/rules/README.md`](.cursor/rules/README.md) |
| 57 | +- **Skills:** [`skills/README.md`](skills/README.md) |
| 58 | + |
| 59 | +Product docs: [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/). |
0 commit comments