|
| 1 | +--- |
| 2 | +name: contentstack-js-cda |
| 3 | +description: Contentstack Content Delivery (CDA) JavaScript SDK — Stack, tokens, regions, queries, sync, live preview in src/core/. |
| 4 | +--- |
| 5 | + |
| 6 | +# Contentstack JavaScript CDA SDK skill |
| 7 | + |
| 8 | +This repository ships **`contentstack`**, the **Content Delivery API** read client. It is **not** the Content Management API client (`@contentstack/management`). |
| 9 | + |
| 10 | +## Mental model |
| 11 | + |
| 12 | +1. **`Contentstack.Stack(options)`** (`src/core/stack.js`) configures the stack (**`api_key`**, **`delivery_token`**, **`environment`**, optional **`region`**, **`branch`**, **`host`**, **`live_preview`**, **`plugins`**, **`fetchOptions`**). |
| 13 | +2. **Modules** under **`src/core/modules/`** implement **entries**, **assets**, **queries**, **taxonomy**, **results**, etc., composed from the stack instance. |
| 14 | +3. **`src/core/lib/request.js`** performs **`fetch`**, query string building, retries, and **plugin** hooks. |
| 15 | +4. **`src/runtime/*`** provides platform-specific **`http`** and **localstorage** implementations selected at build time. |
| 16 | + |
| 17 | +## Configuration (see JSDoc on `Stack`) |
| 18 | + |
| 19 | +- **`region`** / **`host`** — CDN / API host selection (see `stack.js` and **`config.js`** defaults). |
| 20 | +- **`fetchOptions`** — **`timeout`**, **`retryLimit`**, **`retryDelay`**, **`retryCondition`** (defaults include **408** / **429**), **`retryDelayOptions`**, **`debug`**, **`logHandler`**. |
| 21 | +- **`live_preview`** — enable flag, **`host`**, **`management_token`** or **`preview_token`**; affects which host serves preview vs delivery. |
| 22 | +- **`plugins`** — `{ onRequest, onResponse }` hooks invoked from `request.js`. |
| 23 | + |
| 24 | +## Implementing features |
| 25 | + |
| 26 | +- Follow neighbors in **`src/core/modules/`** for method chaining, URL construction, and parameter passing into **`Request`**. |
| 27 | +- Consider **cache policy** and **sync** behaviors when changing read paths. |
| 28 | +- Multi-platform: verify **webpack** entries for **node**, **web**, **react-native**, **nativescript** if adding runtime dependencies. |
| 29 | + |
| 30 | +## Docs |
| 31 | + |
| 32 | +- Product: [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) |
| 33 | +- Types: root **`index.d.ts`** |
| 34 | + |
| 35 | +## Rule shortcut |
| 36 | + |
| 37 | +- `.cursor/rules/contentstack-javascript-cda.mdc` when editing `src/**/*.js` |
0 commit comments