|
1 | | -# AGENTS.md — AI / automation context |
| 1 | +# Contentstack TypeScript Delivery SDK – Agent guide |
2 | 2 |
|
3 | | -## Project |
| 3 | +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. |
4 | 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) | |
| 5 | +## What this repo is |
10 | 6 |
|
11 | | -## Tech stack |
| 7 | +| Field | Detail | |
| 8 | +|--------|--------| |
| 9 | +| **Name:** | [contentstack-typescript](https://github.com/contentstack/contentstack-typescript) (`@contentstack/delivery-sdk`) | |
| 10 | +| **Purpose:** | TypeScript/JavaScript Content Delivery SDK for fetching and working with stack content in Node and browsers. | |
| 11 | +| **Out of scope:** | Not the Management API or CLI; use the appropriate Contentstack tools for non-delivery workflows. | |
| 12 | + |
| 13 | +## Tech stack (at a glance) |
12 | 14 |
|
13 | 15 | | Area | Details | |
14 | 16 | |------|---------| |
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/). |
| 17 | +| Language | TypeScript (`typescript` in `package.json`); Node **≥ 18** | |
| 18 | +| Build | Rollup (`rollup -c`), declaration emit (`config/tsconfig.decl-esm.json`) → `dist/modern/` | |
| 19 | +| Tests | Jest: `test/unit`, `test/api`, browser config; Playwright for e2e (`test/e2e`); bundler smoke tests under `test/bundlers/` | |
| 20 | +| Lint / coverage | No root `lint` script—use `npm run validate:all` and `.github/workflows/coverage-check.yml` for quality gates | |
| 21 | +| CI | `.github/workflows/coverage-check.yml`, `check-branch.yml`, `sca-scan.yml`, `policy-scan.yml`, `npm-publish.yml` | |
| 22 | + |
| 23 | +## Commands (quick reference) |
| 24 | + |
| 25 | +| Command type | Command | |
| 26 | +|--------------|---------| |
| 27 | +| Build | `npm run build` | |
| 28 | +| Test (common) | `npm run test:unit` / `npm run test:api` / `npm run test:all` | |
| 29 | +| Validate | `npm run validate:all` | |
| 30 | +| Full CI-style suite | `npm run test:cicd` or `npm run test:cicd:no-browser` (see `package.json`) | |
| 31 | + |
| 32 | +## Where the documentation lives: skills |
| 33 | + |
| 34 | +| Skill | Path | What it covers | |
| 35 | +|-------|------|----------------| |
| 36 | +| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Branches, CI, npm scripts, prerelease | |
| 37 | +| **Delivery SDK** | [`skills/contentstack-delivery-typescript/SKILL.md`](skills/contentstack-delivery-typescript/SKILL.md) | Public API, stack client, `@contentstack/core` usage | |
| 38 | +| **TypeScript & layout** | [`skills/typescript/SKILL.md`](skills/typescript/SKILL.md) | `src/`, Rollup outputs, modern CJS/ESM | |
| 39 | +| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | Jest, API tests, Playwright, bundler matrix | |
| 40 | +| **Build & platform** | [`skills/framework/SKILL.md`](skills/framework/SKILL.md) | Rollup, browser safety, bundler validation | |
| 41 | +| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist for SDK changes | |
| 42 | + |
| 43 | +## Using Cursor (optional) |
| 44 | + |
| 45 | +If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else. |
0 commit comments