-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcontentstack-javascript-cda.mdc
More file actions
36 lines (22 loc) · 1.96 KB
/
contentstack-javascript-cda.mdc
File metadata and controls
36 lines (22 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
description: "Contentstack CDA SDK patterns in src/core (Content Delivery API)"
globs: ["src/**/*.js"]
alwaysApply: false
---
# Contentstack CDA SDK (`src/core/`)
This package implements the **Content Delivery API (CDA)** read client, not the Content Management API (CMA).
## Stack & config
- **`Contentstack.Stack(options)`** (`src/core/stack.js`) — **`api_key`**, **`delivery_token`**, **`environment`**; optional **`region`**, **`branch`**, **`host`**, **`live_preview`**, **`plugins`**, **`fetchOptions`** (timeout, retries, `retryCondition`, `logHandler`, etc.).
- Default CDN paths and version come from **`config.js`** at the repo root; regional hosts follow existing `stack.js` logic (e.g. `{region}-cdn.contentstack.com`).
## HTTP & errors
- Requests are built in **`src/core/lib/request.js`**: query serialization, **`fetch`**, default retries on **408** / **429** (configurable), plugin hooks **`onRequest`** / **`onResponse`**.
- Failed responses reject with objects carrying **`error_message`**, **`error_code`**, **`errors`**, **`status`**, **`statusText`** when JSON parsing succeeds — keep new code compatible with this shape.
## Modules
- **Entry, Query, Assets, Taxonomy, Result**, etc. live under **`src/core/modules/`** — follow neighboring patterns for chaining, parameters, and URL assembly.
- **Cache**: policies and providers under **`src/core/cache.js`** and **`src/core/cache-provider/`**.
## Live preview
- When **`live_preview.enable`** is true, **`management_token`** vs **`preview_token`** affect host selection — mirror existing `stack.js` behavior and tests under **`test/live-preview/`**.
## Runtime targets
- **`src/runtime/node|web|react-native|nativescript/`** supply **`http`** and **`localstorage`** — changes that affect networking or storage must consider **all** bundled targets.
## Docs
- Align behavior with the official [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) documentation.