|
| 1 | +# AI agent docs — `@contentstack/datasync-mongodb-sdk` |
| 2 | + |
| 3 | +You are working on the **Contentstack DataSync MongoDB SDK** — a library that queries **MongoDB** (or a Mongo-compatible store) holding content synced via **Contentstack DataSync**, **not** the Content **Delivery** (CDA) or **Management** (CMA) HTTP SDKs. Core behavior uses the **MongoDB driver** and queries against **persisted sync data**, not live stack REST calls for normal reads. |
| 4 | + |
| 5 | +## Single source of truth |
| 6 | + |
| 7 | +| Layer | Role | |
| 8 | +|-------|------| |
| 9 | +| **[`.cursor/rules/README.md`](.cursor/rules/README.md)** | Optional Cursor pointer (the **only** file under `.cursor/rules/`); links to **`AGENTS.md`** and **`skills/`** | |
| 10 | +| **`AGENTS.md`** (this file) | Universal entry: identity, out-of-scope, links, tech stack, commands, skills index | |
| 11 | +| **`skills/<name>/SKILL.md`** | Full conventions and checklists (source of truth for depth) | |
| 12 | + |
| 13 | +**Flow:** [`.cursor/rules/README.md`](.cursor/rules/README.md) → **`AGENTS.md`** → **`skills/<name>/SKILL.md`** |
| 14 | + |
| 15 | +## Out of scope (unless comparing or documenting migration) |
| 16 | + |
| 17 | +- **Not** the CDA or CMA **HTTP** client SDKs. |
| 18 | +- **Not** live Contentstack **REST** reads for normal query paths — this SDK targets **synced data in MongoDB**. |
| 19 | + |
| 20 | +## Repository |
| 21 | + |
| 22 | +| | | |
| 23 | +|--|--| |
| 24 | +| **npm** | `@contentstack/datasync-mongodb-sdk` | |
| 25 | +| **Git** | [https://github.com/contentstack/datasync-mongodb-sdk](https://github.com/contentstack/datasync-mongodb-sdk) | |
| 26 | +| **Product docs** | [Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync) | |
| 27 | + |
| 28 | +## Tech stack |
| 29 | + |
| 30 | +| Area | Details | |
| 31 | +|------|---------| |
| 32 | +| Language | TypeScript `^4.9.5` (`package.json`); `tsc` → `dist/`, declarations `typings/` (`tsconfig.json`) | |
| 33 | +| Runtime | Node `>=8` (`engines`); README may suggest a newer Node for local dev | |
| 34 | +| Build | `npm run compile` (`tsc`); `npm run build-ts` (`clean` + `tsc`) | |
| 35 | +| Test | Jest `^29` + ts-jest, Node env, coverage on (`jest.config.js`). **`npm test` is `jest` only** — no `pretest` in `package.json` | |
| 36 | +| Lint | **TSLint** — `npm run tslint` + `tslint.json` on `src/**/*.ts`. **No ESLint** / no `npm run lint` in this repo | |
| 37 | +| Runtime deps | `mongodb`, `lodash`, `sift` | |
| 38 | +| Docs | `npm run build-doc` (builds then JSDoc → `docs/`) | |
| 39 | + |
| 40 | +## Source layout and public entry points |
| 41 | + |
| 42 | +| Role | Path | |
| 43 | +|------|------| |
| 44 | +| Package entry | `dist/index.js` (`main`) | |
| 45 | +| Public API | `src/index.ts` — `Contentstack`, `Contentstack.Stack(config, db?)` | |
| 46 | +| Query / connection | `src/stack.ts` | |
| 47 | +| Defaults + validation | `src/config.ts`, `src/util.ts` | |
| 48 | +| Messages | `src/messages.ts` | |
| 49 | +| Tests + fixtures | `test/`, `test/data/` | |
| 50 | +| Declarations | `typings/*.d.ts` | |
| 51 | +| Example | `example/index.js` | |
| 52 | + |
| 53 | +## Commands |
| 54 | + |
| 55 | +| Command | Purpose | |
| 56 | +|---------|---------| |
| 57 | +| `npm run build-ts` | Clean `dist/`, `typings/`, `coverage/`, then `tsc` | |
| 58 | +| `npm run compile` | `tsc` only | |
| 59 | +| `npm test` | Jest (coverage per `jest.config.js`) | |
| 60 | +| `npm run tslint` | TSLint `src/**/*.ts` | |
| 61 | +| `npm run clean` | Rimraf `dist`, `typings`, `coverage` | |
| 62 | +| `npm run build-doc` | Full build + JSDoc to `docs/` | |
| 63 | + |
| 64 | +## Test model and credentials |
| 65 | + |
| 66 | +- **Integration-style** tests against a **real MongoDB** (`Stack.connect()`, inserts, queries, teardown). **Not** live Contentstack HTTP API calls. |
| 67 | +- Default URI from merged **`src/config.ts`** (e.g. `mongodb://localhost:27017`); tests often use **`test/config.ts`** (`dbName` e.g. `sync-test`). |
| 68 | +- **No** committed `.env` for tests; override via **`contentStore`** (including `url`) in code. **Do not** commit production Mongo URIs or secrets. |
| 69 | +- **No** Testcontainers or CI Mongo service defined in-repo — local MongoDB is the documented path for developers running tests. |
| 70 | + |
| 71 | +## Skills index |
| 72 | + |
| 73 | +Canonical detail lives under **`skills/<kebab-case>/SKILL.md`**. See **[`skills/README.md`](skills/README.md)**. |
| 74 | + |
| 75 | +| Skill | `SKILL.md` | |
| 76 | +|-------|------------| |
| 77 | +| Dev workflow, hooks, CI | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | |
| 78 | +| TypeScript / TSLint / `src/` layout | [`skills/typescript/SKILL.md`](skills/typescript/SKILL.md) | |
| 79 | +| DataSync MongoDB SDK behavior | [`skills/datasync-mongodb/SKILL.md`](skills/datasync-mongodb/SKILL.md) | |
| 80 | +| Testing | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | |
| 81 | +| Code review | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | |
| 82 | + |
| 83 | +## Using Cursor |
| 84 | + |
| 85 | +- Open **[`.cursor/rules/README.md`](.cursor/rules/README.md)** — the sole file in **`.cursor/rules/`** — for pointers to **`AGENTS.md`** and **`skills/`**. |
| 86 | +- Full guidance: **`skills/<name>/SKILL.md`** (attach or `@`-reference those paths in chat per your Cursor setup); there are **no** `.cursor/rules/*.mdc` files in this repo. |
| 87 | + |
| 88 | +## Contributor workflow (concise) |
| 89 | + |
| 90 | +- **`.husky/pre-commit`:** **Snyk** + **Talisman** when installed; `SKIP_HOOK=1` only if your team allows. |
| 91 | +- **CI:** `.github/workflows/` includes CodeQL, SCA, policy scans, **check-version-bump** — see each file for triggers. |
| 92 | +- **Version bump workflow** path filters may **not** list `src/`; maintainers may need to align the workflow with this layout (see [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md)). |
0 commit comments