@sdkwork/sdk-common
v1.0.8
Published
SDKwork SDK Common - High cohesion, low coupling SDK foundation library
Maintainers
Readme
@sdkwork/sdk-common
Common foundation package for generated TypeScript SDKs.
Install
npm install @sdkwork/sdk-commonAuthentication Modes
Choose one mode per client instance.
- API Key mode
Authorization: Bearer {apiKey}
- Dual-token mode
Access-Token: {accessToken}Authorization: Bearer {authToken}
Quick Start
import { createBaseHttpClient, createTokenManager } from '@sdkwork/sdk-common';
const tokenManager = createTokenManager({
accessToken: 'your-access-token',
authToken: 'your-auth-token',
});
const client = createBaseHttpClient({
baseUrl: 'https://api.example.com',
tokenManager,
});
const profile = await client.get<{ id: string; name: string }>('/v1/profile');
console.log(profile.name);API key mode example:
import { createBaseHttpClient } from '@sdkwork/sdk-common';
const client = createBaseHttpClient({
baseUrl: 'https://api.example.com',
apiKey: 'your-api-key',
});Exported Modules
core: request/result types, constants, retry/cache/logger config typesauth: token manager and auth header builderhttp:BaseHttpClientandcreateBaseHttpClienterrors: SDK error hierarchy and type guardsutils: retry, cache, logger, string/encoding/date/object helpers
Publishing
This SDK includes cross-platform publish scripts in bin/:
bin/publish-core.mjsbin/publish.shbin/publish.ps1
Check
./bin/publish.sh --action checkPublish
./bin/publish.sh --action publish --channel release.\bin\publish.ps1 --action publish --channel test --dry-runSet
NPM_TOKEN(and optionalNPM_REGISTRY_URL) before release publish.
License
MIT
SDKWork Documentation Contract
Domain: platform Capability: sdk-common Package type: node-package Status: standard
Public API
Public exports are declared in specs/component.spec.json under contracts.publicExports.
Required SDK Surface
- None declared in
specs/component.spec.json.
Configuration
Configuration keys and runtime entrypoints are declared in specs/component.spec.json.
SaaS/Private/Local Behavior
This module follows the canonical standards linked from specs/component.spec.json, including deployment and runtime configuration rules where applicable.
Security
Do not add secrets, live tokens, manual auth headers, or app-local credential handling to this module.
Extension Points
Extension points are limited to declared public exports, runtime entrypoints, SDK clients, events, and config keys.
Verification
pnpm typecheck
Owner And Status
Owner and lifecycle status are tracked in specs/component.spec.json.
