@qm-center/sync-client-types
v0.2.0
Published
TypeScript types for qm-sync-client - generated from Rust with Specta
Maintainers
Readme
@qm-center/sync-client-types
TypeScript types for qm-sync-client - generated from Rust with Specta.
Installation
npm install @qm-center/sync-client-types
# or for local development
npm linkUsage
import {
AuthHeaders,
HttpRequest,
HttpResponse,
Checkpoint,
SyncRecord,
PushRequest,
PullResponse,
DeltaRequest,
DeltaResponse,
createSyncClientConfig,
createAuthHeaders,
withBearer,
} from '@qm-center/sync-client-types';
// Create config
const config = createSyncClientConfig(
'https://sync.example.com',
'my-app-id',
'my-api-key'
);
// Create headers
const headers = withBearer(
createAuthHeaders(config.apiKey, config.appId),
accessToken
);
// Build request
const request: HttpRequest = {
method: 'POST',
url: `${config.serverUrl}/api/v1/sync/${config.appId}/delta`,
headers,
body: JSON.stringify(deltaRequest),
};Regenerating Types
Types are generated from Rust using Specta. To regenerate:
cd ../qm-sync-client
GENERATE_TS_TYPES=1 cargo buildThen update src/index.ts with the generated types.
Local Development
To use in a local project without publishing:
# In this directory
npm install
npm run build
npm link
# In your project
npm link @qm-center/sync-client-typesPublic package on NPM
npm publish --access public
npm view @qm-center/sync-client-types 