|
| 1 | +# @contentstack/core |
| 2 | + |
1 | 3 | [](https://www.contentstack.com/) |
2 | | -## TypeScript Core SDK for Contentstack |
| 4 | + |
| 5 | +TypeScript Core SDK for Contentstack - A foundational library providing core modules and utilities for Contentstack TypeScript SDKs. |
| 6 | + |
| 7 | +## About Contentstack |
3 | 8 |
|
4 | 9 | Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/). |
5 | 10 |
|
6 | | -### Prerequisite |
| 11 | +## Description |
7 | 12 |
|
8 | | -You need Node.js version 4.4.7 or later installed to use the Contentstack TS Core SDK. |
| 13 | +This package contains core modules and utilities used by the [Contentstack TypeScript Delivery SDK](https://github.com/contentstack/contentstack-javascript/). It provides essential functionality including HTTP client configuration, error handling, request management, parameter serialization, and retry policies. |
9 | 14 |
|
10 | | -## Installation |
| 15 | +## Features |
11 | 16 |
|
12 | | -``` |
| 17 | +- **HTTP Client**: Configurable Axios-based HTTP client with support for custom adapters |
| 18 | +- **Error Handling**: Comprehensive error classes for API and Contentstack-specific errors |
| 19 | +- **Request Management**: Request handling with interceptors and custom error callbacks |
| 20 | +- **Parameter Serialization**: Custom parameter serialization for API requests |
| 21 | +- **Retry Policies**: Built-in retry logic for handling rate limits and transient errors |
| 22 | +- **TypeScript Support**: Full TypeScript definitions included |
| 23 | +- **Multiple Build Formats**: Supports CommonJS, ESM, UMD, and TypeScript declarations |
| 24 | + |
| 25 | +## Important Note |
| 26 | + |
| 27 | +**This package is an internal dependency** used by Contentstack TypeScript SDKs. End users should **not** install this package directly. Instead, install the appropriate Contentstack SDK (e.g., [Contentstack TypeScript Delivery SDK](https://github.com/contentstack/contentstack-typescript/)), which will automatically include this package as a dependency. |
| 28 | + |
| 29 | +## For SDK Developers |
| 30 | + |
| 31 | +If you are developing or maintaining a Contentstack SDK and need to use this core package directly, you can install it as a dependency: |
| 32 | + |
| 33 | +```bash |
13 | 34 | npm install @contentstack/core |
14 | 35 | ``` |
15 | 36 |
|
16 | | -## Use case |
| 37 | +Then import the modules: |
17 | 38 |
|
18 | | -This package contains some core modules and utilities used by the [Contentstack Typescript Delivery SDK](https://github.com/contentstack/contentstack-javascript/) SDK. |
| 39 | +```typescript |
| 40 | +import { |
| 41 | + httpClient, |
| 42 | + ContentstackError, |
| 43 | + ApiError, |
| 44 | + // ... other exports |
| 45 | +} from '@contentstack/core'; |
| 46 | +``` |
19 | 47 |
|
20 | 48 | ## Development |
21 | 49 |
|
22 | | -### Create the build: |
| 50 | +### Prerequisites |
23 | 51 |
|
| 52 | +- Node.js version 4.4.7 or later |
| 53 | + |
| 54 | +### Setup |
| 55 | + |
| 56 | +Clone the repository and install dependencies: |
| 57 | + |
| 58 | +```bash |
| 59 | +git clone https://github.com/contentstack/contentstack-js-core.git |
| 60 | +cd contentstack-js-core |
| 61 | +npm install |
24 | 62 | ``` |
| 63 | + |
| 64 | +### Build |
| 65 | + |
| 66 | +Build all output formats (CommonJS, ESM, UMD, and TypeScript declarations): |
| 67 | + |
| 68 | +```bash |
25 | 69 | npm run build |
26 | 70 | ``` |
27 | 71 |
|
28 | | -### Run Scripts: |
29 | | - |
30 | | -Run the unit tests: |
| 72 | +Build specific formats: |
31 | 73 |
|
| 74 | +```bash |
| 75 | +npm run build:cjs # CommonJS |
| 76 | +npm run build:esm # ES Modules |
| 77 | +npm run build:umd # UMD |
| 78 | +npm run build:types # TypeScript declarations |
32 | 79 | ``` |
| 80 | + |
| 81 | +### Testing |
| 82 | + |
| 83 | +Run unit tests: |
| 84 | + |
| 85 | +```bash |
33 | 86 | npm run test |
34 | 87 | ``` |
35 | 88 |
|
36 | | -Run the lint tests: |
| 89 | +Run linting: |
37 | 90 |
|
38 | | -``` |
| 91 | +```bash |
39 | 92 | npm run lint |
40 | 93 | ``` |
41 | 94 |
|
42 | | -Pack the SDK: |
| 95 | +### Packaging |
43 | 96 |
|
44 | | -``` |
| 97 | +Create a package tarball: |
| 98 | + |
| 99 | +```bash |
45 | 100 | npm run package |
46 | | -``` |
| 101 | +``` |
| 102 | + |
| 103 | +### Clean |
| 104 | + |
| 105 | +Clean build artifacts: |
| 106 | + |
| 107 | +```bash |
| 108 | +npm run clean |
| 109 | +``` |
| 110 | + |
| 111 | +## License |
| 112 | + |
| 113 | +This project is licensed under the MIT License. See the [LICENSE.txt](LICENSE.txt) file for details. |
| 114 | + |
| 115 | +## Repository |
| 116 | + |
| 117 | +- **GitHub**: [contentstack/contentstack-js-core](https://github.com/contentstack/contentstack-js-core) |
| 118 | + |
| 119 | +## Related Projects |
| 120 | + |
| 121 | +- [Contentstack TypeScript Delivery SDK](https://github.com/contentstack/contentstack-javascript/) |
| 122 | + |
| 123 | +## Support |
| 124 | + |
| 125 | +For issues and feature requests, please visit the [GitHub Issues](https://github.com/contentstack/contentstack-js-core/issues) page. |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +Copyright (c) 2016-2025 Contentstack. All rights reserved. |
0 commit comments