@archlast/sdk-core
v0.1.1
Published
Archlast SDK Core - Platform-agnostic client base with HTTP transport and types
Downloads
148
Readme
@archlast/sdk-core
Platform-agnostic core for Archlast SDKs. This package provides the base client class, HTTP transport layer, and shared types used by all platform-specific SDKs.
Installation
npm install @archlast/sdk-coreUsage
This package is typically used as a dependency of platform-specific SDKs (@archlast/client, @archlast/sdk-next, @archlast/sdk-expo), not directly by end users.
Direct Usage (Advanced)
If you need to build a custom platform integration:
import { BaseClient } from "@archlast/sdk-core";
class MyPlatformClient extends BaseClient {
constructor(options: ClientOptions) {
super(options);
// Add platform-specific functionality
}
}
const client = new MyPlatformClient({
baseUrl: "http://localhost:4000",
appId: "my-app",
});
// Use inherited methods
const state = await client.getAuthState();
const result = await client.query("myQuery", { arg1: "value" });Features
- BaseClient: Core client with HTTP transport and auth methods
- HttpClient: Platform-agnostic HTTP client with error handling
- Type definitions: Shared types across all platforms
- No React dependencies: Can be used in any JavaScript/TypeScript environment
API
BaseClient
The main client class that all platform clients extend.
Methods
getAuthState()- Get current authentication statesignUp(input)- Sign up new usersignIn(input)- Sign in with email/username and passwordsignOut()- Sign out and revoke sessionrequestPasswordReset(email)- Request password resetresetPassword(token, password)- Reset passwordquery(name, args)- Call a query functionmutate(name, args)- Call a mutation functionaction(name, args)- Call an action function
HttpClient
Low-level HTTP client used by BaseClient.
Methods
get(path, params)- GET requestpost(path, body)- POST requestput(path, body)- PUT requestdelete(path)- DELETE requestuploadFile(path, file)- Upload file
Types
All types are exported from the package:
AuthUser- User informationAuthSession- Session informationAuthState- Authentication stateSignUpInput- Sign up parametersSignInInput- Sign in parametersClientOptions- Client configuration optionsPaginatedResponse<T>- Paginated query responseSdkError,AuthError,NetworkError,ValidationError- Error types
License
MIT
