Registry / http-networking / contensis-core-api

contensis-core-api

JSON →
library1.2.2jsnpmunverified

The `contensis-core-api` package, currently at version 1.2.2, serves as a foundational dependency library within the Contensis ecosystem. Written in TypeScript, it provides common types, interfaces, and base methods shared across higher-level Contensis client libraries, specifically `contensis-delivery-api` and `contensis-management-api`. Its primary purpose is to offer standardized HTTP request handling, error structures, and data models that ensure consistency and reduce code duplication across various Contensis API interactions. While not typically consumed directly by most application developers, it provides the underlying infrastructure for interacting with the Contensis HTTP Delivery API and Management API. As a core dependency, its release cadence is usually tied to the evolution of the broader Contensis API clients, adhering to semantic versioning for internal changes.

npm install contensis-core-api
INSTALL
IMPORT
SIG · CONTENSIS-CORE-API
C
contensis-core-api
http-networkingjavascriptv1.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpClient
import { HttpClient } from 'contensis-core-api';
const HttpClient = require('contensis-core-api').HttpClient;
Primarily used internally by Contensis client libraries, but available for custom low-level HTTP handling.
HttpMethod
import { HttpMethod } from 'contensis-core-api';
import { HTTP_METHOD } from 'contensis-core-api';
Enum defining standard HTTP verbs (e.g., 'GET', 'POST').
CallError
import { CallError } from 'contensis-core-api';
import { ApiError } from 'contensis-core-api';
Base class for API-related errors, useful for custom error handling logic when interacting with Contensis APIs at a lower level.

Illustrates the usage of core types like `HttpClient`, `HttpMethod`, and `CallError`, demonstrating a low-level HTTP request pattern. This package is typically a dependency and not used directly for API calls by end-user applications.

import { HttpClient, HttpMethod, CallError, IHttpClient } from 'contensis-core-api'; interface MyApiOptions { rootUrl: string; accessToken: string; } // Demonstrating how to set up a basic HttpClient (typically abstracted by higher-level Contensis clients) class CustomContensisHttpClient implements IHttpClient { private client: HttpClient; constructor(options: MyApiOptions) { this.client = new HttpClient(options.rootUrl); // In a real scenario, authentication headers would be added here or via middleware this.client.setDefaultHeader('Authorization', `Bearer ${options.accessToken}`); } async request<T>(method: HttpMethod, path: string, options?: RequestInit): Promise<T> { try { const response = await this.client.request<T>(method, path, options); console.log(`Successfully made ${method} request to ${path}`); return response; } catch (error) { if (error instanceof CallError) { console.error(`API Call Error: ${error.message} (Status: ${error.status})`); } else { console.error('An unexpected error occurred:', error); } throw error; } } } // Example usage (conceptual, as direct use is rare) const myClient = new CustomContensisHttpClient({ rootUrl: process.env.CONTENSIS_ROOT_URL ?? 'https://api.contensis.com', accessToken: process.env.CONTENSIS_ACCESS_TOKEN ?? 'YOUR_ACCESS_TOKEN_HERE' }); async function fetchData() { try { // This is a simplified example; actual paths and types would vary. // Higher-level Contensis SDKs (`contensis-delivery-api`) provide structured methods. const data = await myClient.request<any>(HttpMethod.GET, '/some/api/path'); console.log('Received data:', data); } catch (e) { console.log('Failed to fetch data via core client.'); } } fetchData();
Debug
Known issues
gotchaThis package is a core dependency for other Contensis client libraries (`contensis-delivery-api`, `contensis-management-api`). Direct consumption by application developers is generally not recommended, as the higher-level SDKs provide a more abstracted and feature-rich interface for interacting with the Contensis CMS.
fix
For interacting with Contensis APIs, prefer `contensis-delivery-api` for read-only content or `contensis-management-api` for content management operations.
affects: >=1.0.0
breakingMajor version updates of `contensis-core-api` typically coincide with breaking changes in the consuming client libraries. Changes in internal types, interfaces, or HTTP client behavior in this core package can propagate as breaking changes in the higher-level SDKs. Developers should consult the changelog of `contensis-delivery-api` or `contensis-management-api` when upgrading.
fix
Always check the release notes and migration guides for `contensis-delivery-api` and `contensis-management-api` when updating to a new major version of any Contensis SDK. Pay attention to type definition changes and API instantiation methods.
affects: >=1.0.0
gotchaThe package requires Node.js >=12, as specified in its `engines` field. Using it with older Node.js versions may lead to runtime errors due to unsupported syntax or built-in features (like `fetch` polyfills in consuming libraries).
fix
Ensure your Node.js environment meets the minimum requirement. For client-side usage, ensure your build process correctly handles browser compatibility.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: (0 , contensis_core_api_1.HttpClient) is not a constructor
Attempting to `require` an ESM-only module or using incorrect CommonJS syntax for named exports. The `contensis-core-api` package is written in TypeScript and likely built for ESM, though it might provide CJS bundles.
fix
Use ES module `import` syntax: `import { HttpClient } from 'contensis-core-api';`. If in a CommonJS environment, configure your project for ESM or ensure your transpiler handles `import`/`export` correctly.
TS2307: Cannot find module 'contensis-core-api' or its corresponding type declarations.
TypeScript compiler cannot locate the package's type definitions. This can happen if the package is not installed, or if `tsconfig.json` is not correctly configured to include `node_modules/@types` or the package's own types.
fix
Ensure `contensis-core-api` is installed (`npm install contensis-core-api` or `yarn add contensis-core-api`). Verify `tsconfig.json` includes `"compilerOptions": { "moduleResolution": "Node" }` and implicitly or explicitly includes `node_modules` in its `include` path.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
contensis-core-api — npm install contensis-core-api · libregistry