@qaecy/cue-sdk
v0.0.1
Published
Headless JavaScript SDK for building apps on the QAECY platform
Maintainers
Readme
@qaecy/cue-sdk
Headless JavaScript SDK for building apps on the QAECY platform. A framework-agnostic client that handles authentication and API access — the programmatic counterpart to the @qaecy/cue-widget.
Installation
npm install @qaecy/cue-sdk firebase
firebaseis a peer dependency and must be installed alongside the SDK.
Quick start
import { Cue } from '@qaecy/cue-sdk';
const cue = new Cue({
apiKey: 'YOUR_FIREBASE_API_KEY',
appId: 'YOUR_FIREBASE_APP_ID',
measurementId: 'YOUR_MEASUREMENT_ID',
});
// Listen for auth state changes
cue.auth.onAuthStateChanged((user) => {
console.log(user ? `Signed in as ${user.displayName}` : 'Signed out');
});
// Sign in
await cue.auth.signIn('google');
// or
await cue.auth.signIn('microsoft');
// or
await cue.auth.signIn('password', { email: '[email protected]', password: 'secret' });
// Search documents
const results = await cue.api.search({
term: 'What are the fire safety requirements?',
projectId: 'my-project-id',
});
console.log(results.response);
console.log(results.sources);
// Sign out
await cue.auth.signOut();Configuration
| Option | Type | Required | Description |
|---|---|---|---|
| apiKey | string | ✅ | Firebase API key |
| appId | string | ✅ | Firebase App ID |
| measurementId | string | ✅ | Firebase Measurement ID |
| gatewayUrl | string | — | Override the default API gateway URL |
| useEmulator | boolean | — | Connect to local emulators (default: false) |
Auth
cue.auth.signIn(provider)
Sign in with Google or Microsoft via a browser popup:
const user = await cue.auth.signIn('google');
const user = await cue.auth.signIn('microsoft');cue.auth.signIn('password', credentials)
Sign in with email and password:
const user = await cue.auth.signIn('password', {
email: '[email protected]',
password: 's3cr3t',
});cue.auth.signOut()
await cue.auth.signOut();cue.auth.currentUser
Returns the currently signed-in Firebase User, or null.
cue.auth.onAuthStateChanged(listener)
Subscribe to auth state changes. Returns an unsubscribe function.
const unsubscribe = cue.auth.onAuthStateChanged((user) => {
if (user) startApp(user);
});
// Later:
unsubscribe();cue.auth.getToken(forceRefresh?)
Get the Firebase ID token for the current user:
const token = await cue.auth.getToken();API
All API methods require the user to be authenticated first.
cue.api.search(request)
Search project documents using natural language:
const results = await cue.api.search({
term: 'fire resistance requirements',
projectId: 'my-project-id',
categories: ['buildings', 'regulations'], // optional
});
// results.response — AI-generated answer
// results.sources — source documentscue.api.sparql(query, projectId)
Execute a SPARQL query against the project's triplestore:
const data = await cue.api.sparql(
`SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10`,
'my-project-id',
);Advanced
Access the raw Firebase Auth instance for advanced use cases:
const firebaseAuth = cue.auth.firebaseAuth;License
MIT
