@ultralightpro/types
v1.1.0
Published
TypeScript type definitions for Ultralight SDK - provides autocomplete and type checking for ultralight.ai(), ultralight.store(), and more
Maintainers
Readme
@ultralightpro/types
TypeScript type definitions for Ultralight apps.
Provides autocomplete and type checking for ultralight.ai(), ultralight.store(), and all SDK methods.
Installation
npm install -D @ultralightpro/typesUsage
Add a reference at the top of your entry file:
/// <reference types="@ultralightpro/types" />
export async function hello(name: string) {
// Now you get autocomplete for ultralight!
await ultralight.store('greetings', { name, time: Date.now() });
return `Hello, ${name}!`;
}Or add to your tsconfig.json:
{
"compilerOptions": {
"types": ["@ultralightpro/types"]
}
}What's Available
The ultralight global provides:
Data Storage
await ultralight.store('key', value);
await ultralight.load('key');
await ultralight.list('prefix/');
await ultralight.query('prefix/', { limit: 10, sort: { field: 'date', order: 'desc' } });AI (BYOK)
const response = await ultralight.ai({
messages: [{ role: 'user', content: 'Hello!' }],
temperature: 0.7,
});
console.log(response.content);User Context
if (ultralight.isAuthenticated()) {
const user = ultralight.user;
console.log(user.email);
}Cron Jobs
await ultralight.cron.register('daily', '0 9 * * *', 'myDailyTask');Global Utilities
These are also available globally:
_- Lodash-like utilities (groupBy, chunk, sortBy, etc.)uuid.v4()- UUID generationbase64.encode()/base64.decode()hash.sha256()/hash.sha512()dateFns.format()- Date formatting
React Apps
For UI apps, export a default function:
/// <reference types="@ultralightpro/types" />
import React from 'react';
import ReactDOM from 'react-dom/client';
const App: UltralightApp = (container, sdk) => {
const root = ReactDOM.createRoot(container);
root.render(<MyApp sdk={sdk} />);
};
export default App;