|
| 1 | +--- |
| 2 | +name: contentstack-typescript-datasync-mongodb |
| 3 | +description: Mental model and file map for the TypeScript DataSync MongoDB SDK — Stack, config, MongoDB driver usage (not CDA/CMA). |
| 4 | +--- |
| 5 | + |
| 6 | +# Skill: Contentstack TypeScript — DataSync MongoDB SDK |
| 7 | + |
| 8 | +Use this skill when changing **query behavior**, **connection lifecycle**, or **configuration defaults** for **`@contentstack/datasync-mongodb-sdk`**. |
| 9 | + |
| 10 | +## What this SDK is |
| 11 | + |
| 12 | +- **DataSync MongoDB SDK:** queries **local/synced** MongoDB collections populated by Contentstack **DataSync** (e.g. via content-store-mongodb). **Not** a REST client for **Delivery** or **Management** APIs. |
| 13 | + |
| 14 | +## Entry and flow |
| 15 | + |
| 16 | +1. **`Contentstack.Stack(config, existingDb?)`** — `src/index.ts` → constructs **`Stack`**. |
| 17 | +2. **`Stack.connect()`** — establishes MongoDB client / DB (see `src/stack.ts`). |
| 18 | +3. Fluent API — **`contentType()`**, **`entries()`**, **`assets()`**, filters, **`language()`**, **`includeReferences()`**, etc., ending in **`find()`** / similar per implementation. |
| 19 | + |
| 20 | +## Where to change things |
| 21 | + |
| 22 | +| Concern | Primary location | |
| 23 | +|---------|------------------| |
| 24 | +| Defaults and mergeable config | `src/config.ts` | |
| 25 | +| Connection, queries, cursor logic | `src/stack.ts` | |
| 26 | +| Validation helpers (URI, config) | `src/util.ts` | |
| 27 | +| User-facing error/warning strings | `src/messages.ts` | |
| 28 | +| Package export surface | `src/index.ts` | |
| 29 | + |
| 30 | +## Dependencies (facts from package.json) |
| 31 | + |
| 32 | +- **`mongodb`** — database access. |
| 33 | +- **`lodash`** — merging and data manipulation. |
| 34 | +- **`sift`** — matching filters. |
| 35 | + |
| 36 | +## Config concepts |
| 37 | + |
| 38 | +- **`contentStore`:** `url`, `dbName`, **`collection`** (asset/entry/schema names), `locale`, `limit`, `skip`, `projections`, `options` (MongoClient), `referenceDepth`, `indexes`, internal type keys, etc. |
| 39 | +- **Locales** can influence collection naming in advanced setups (see tests that prefix collection names with locale segments). |
| 40 | + |
| 41 | +## Related |
| 42 | + |
| 43 | +- Cursor rule: [`.cursor/rules/datasync-mongodb.mdc`](../../.cursor/rules/datasync-mongodb.mdc) |
| 44 | +- Cursor rule: [`.cursor/rules/typescript.mdc`](../../.cursor/rules/typescript.mdc) |
| 45 | +- Entry point: [`AGENTS.md`](../../AGENTS.md) |
0 commit comments