Modular, framework-agnostic SDK for Mixcore projects. Built with TypeScript and distributed as ESM/CJS modules.
- Modular architecture: Import only what you need
- TypeScript-first: Full type safety and autocompletion
- Framework-agnostic: Works with any JavaScript framework
- Production-ready: Well-tested and documented
- Secure by design: Configuration injection prevents hardcoded secrets
- Extensible: Plugin/adapter architecture for custom implementations
Package | Description |
---|---|
@mixcore/shared | Shared utilities, helpers and constants |
@mixcore/base | Base classes, abstract models and interfaces |
@mixcore/api | API clients and endpoint wrappers |
@mixcore/config | Configuration management |
@mixcore/database | Database domain services |
@mixcore/file | File handling utilities |
@mixcore/user | User/auth services |
@mixcore/template | Template rendering services |
npm install @mixcore/api @mixcore/database # or whichever packages you need
import { createMixcoreSdk } from '@mixcore/api';
import { ApiService } from '@mixcore/api';
import { ModuleDataService } from '@mixcore/database';
// Initialize SDK with configuration
const sdk = createMixcoreSdk(
{ apiBaseUrl: 'https://api.mixcore.net' },
{
api: new ApiService({ apiBaseUrl: 'https://api.mixcore.net' }),
database: new ModuleDataService({ api: new ApiService({ apiBaseUrl: 'https://api.mixcore.net' }) })
// Add other domain services as needed
}
);
// Use services through SDK instance
const data = await sdk.database.fetchDataItems('module-id');
- Never hardcode secrets in your application
- Always inject configuration (API keys, URLs) at runtime
- Use environment variables for sensitive values
Method | Parameters | Returns | Description |
---|---|---|---|
createMixcoreSdk |
config: MixcoreSdkConfig , services: MixcoreSdkOptions |
MixcoreSdkInstance |
Creates configured SDK instance |
Option | Type | Required | Description |
---|---|---|---|
apiBaseUrl |
string | Yes | Base URL for API requests |
apiKey |
string | No | API key for authentication |
timeout |
number | No | Request timeout in ms |
- Node.js 18+
- pnpm
git clone https://github.com/mixcore/javascript-sdk.git
cd javascript-sdk
pnpm install
pnpm build
pnpm test
Test coverage reports are generated in coverage/
directory.
The SDK uses GitHub Actions for continuous integration and deployment:
- Validate: Runs linting and type checking
- Test: Runs unit tests with coverage reporting via Codecov
- Publish: Automatically publishes to npm on main branch merges
- All packages must pass tests with minimum 80% coverage
- Version numbers must follow semantic versioning
- NPM_TOKEN secret must be configured in GitHub
Contributions welcome! Please see our Contribution Guidelines.
The SDK is framework-agnostic but here are guidelines for popular frameworks:
// Create a context/provider for the SDK
import { createContext } from 'react';
import { createMixcoreSdk } from '@mixcore/api';
const SdkContext = createContext(null);
function App() {
const sdk = createMixcoreSdk(
{ apiBaseUrl: process.env.REACT_APP_API_URL },
{ /* services */ }
);
return (
<SdkContext.Provider value={sdk}>
{/* Your app */}
</SdkContext.Provider>
);
}
// Provide SDK instance via Vue's provide/inject
import { createApp } from 'vue';
import { createMixcoreSdk } from '@mixcore/api';
const app = createApp(App);
app.provide('mixcoreSdk', createMixcoreSdk(
{ apiBaseUrl: import.meta.env.VITE_API_URL },
{ /* services */ }
));
// Create an injectable service wrapper
import { Injectable } from '@angular/core';
import { createMixcoreSdk } from '@mixcore/api';
@Injectable({ providedIn: 'root' })
export class MixcoreService {
sdk = createMixcoreSdk(
{ apiBaseUrl: environment.apiUrl },
{ /* services */ }
);
}
// Use Svelte stores for SDK instance
import { writable } from 'svelte/store';
import { createMixcoreSdk } from '@mixcore/api';
export const sdk = writable(createMixcoreSdk(
{ apiBaseUrl: import.meta.env.VITE_API_URL },
{ /* services */ }
));
Mixcore Community License (MCL). See LICENSE for details.