|
| 1 | +# `@contentstack/types-generator` |
| 2 | + |
| 3 | +**Purpose:** Library for generating TypeScript type definitions from Contentstack stack content types (via the Delivery SDK) and from GraphQL schema (introspection over the Contentstack GraphQL endpoint). |
| 4 | + |
| 5 | +- **Repository:** [github.com/contentstack/types-generator](https://github.com/contentstack/types-generator) |
| 6 | +- **Homepage:** [https://github.com/contentstack/types-generator](https://github.com/contentstack/types-generator) |
| 7 | + |
| 8 | +## Tech stack |
| 9 | + |
| 10 | +| Area | Details | |
| 11 | +| --- | --- | |
| 12 | +| Language | TypeScript **5.9** (`strict` in [tsconfig.json](tsconfig.json)) | |
| 13 | +| Runtime | Node (CI on **18.x** and **20.x**; release workflow uses **22.x**) | |
| 14 | +| Build | **tsup** → `dist/` ([tsup.config.ts](tsup.config.ts)): entries `index` ([src/index.ts](src/index.ts)), `web` ([src/web.ts](src/web.ts)) | |
| 15 | +| Tests | **Jest** + **ts-jest** ([jest.config.js](jest.config.js)); `dotenv/config` in setup | |
| 16 | +| Main dependencies | `@contentstack/delivery-sdk`, `axios`, `@gql2ts/from-schema`, `lodash`, `async`, `prettier` | |
| 17 | + |
| 18 | +This package targets **Content Delivery (CDA)** and **GraphQL** only—not the Management API (CMA). |
| 19 | + |
| 20 | +## Public API and source layout |
| 21 | + |
| 22 | +- **Package entry:** `main` / `module` / `types` point to `./dist/*` (see [package.json](package.json)). |
| 23 | +- **Exports:** `generateTS`, `graphqlTS`, and related symbols from [src/index.ts](src/index.ts) (re-exports from [src/generateTS/](src/generateTS/) and [src/graphqlTS/](src/graphqlTS/)). |
| 24 | +- **Key paths:** [src/sdk/](src/sdk/) (Delivery SDK wiring), [src/types/](src/types/), [src/format/](src/format/), [src/logger/](src/logger/), [src/constants/](src/constants/). |
| 25 | + |
| 26 | +## Common commands |
| 27 | + |
| 28 | +| Command | Purpose | |
| 29 | +| --- | --- | |
| 30 | +| `npm run build` | Run `tsup` (also runs on `npm run prepare`) | |
| 31 | +| `npm test` | Jest with `--testPathPattern=tests` and `NODE_OPTIONS=--experimental-vm-modules` | |
| 32 | +| `npm run test:unit:report:json` | Unit tests under `tests/unit` with coverage and JSON reports (used in CI) | |
| 33 | + |
| 34 | +There is **no ESLint** script in this package; rely on TypeScript strictness and project conventions. |
| 35 | + |
| 36 | +## Credentials and integration tests |
| 37 | + |
| 38 | +Integration tests need a live stack. Set a **`.env`** at the repo root (see integration tests under `tests/integration/`) or export variables in your shell. Typical names: |
| 39 | + |
| 40 | +`TOKEN`, `APIKEY`, `ENVIRONMENT`, `REGION`, `TOKENTYPE`, `BRANCH` |
| 41 | + |
| 42 | +CI injects these from GitHub Actions secrets (see [.github/workflows/node.js.yml](.github/workflows/node.js.yml)), including `TOKEN_WITH_NO_CT` and `APIKEY_WITH_NO_CT` where tests require them. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## AI guidance index |
| 47 | + |
| 48 | +- [Cursor rules (overview)](.cursor/rules/README.md) — when each rule applies and how to reference it. |
| 49 | +- [Skills index](skills/README.md) — deeper checklists and package mental model. |
0 commit comments