npm.io
1.4.2 • Published 2d ago

@alphayard/appkit

Licence
UNLICENSED
Version
1.4.2
Deps
0
Size
164 kB
Vulns
0
Weekly
0

@alphayard/appkit

Reusable AppKit SDK client for mobile apps, web apps, and service-to-service integrations.

Features

  • auth token storage helpers
  • branding and Color Studio config helpers
  • localization helpers
  • identity endpoints
  • CMS collection helpers
  • file storage helpers
  • communication helpers for email and SMS
  • organization and invite helpers for admin contexts
  • AI Studio helpers for published apps, flows, and agents

Install

npm install @alphayard/appkit

Usage

import { AppKit } from '@alphayard/appkit';

const client = new AppKit({
  clientId: 'client-id',
  domain: 'https://your-appkit-domain.com',
  baseURL: 'https://your-appkit-domain.com',
  storage: 'memory',
});

AI Studio

const { aiConfig, apps } = await client.ai.list();

const events = await client.ai.runFlow({
  flowId: 'flow-id',
  inputVariables: { message: 'Summarize my account' },
});

for await (const event of events) {
  console.log(event.data);
}

Color Studio

const colorConfig = await client.getColorStudioConfig();

const updated = await client.updateColorStudioConfig({
  ...colorConfig.branding,
  tokens: {
    ...colorConfig.branding.tokens,
    activeColorThemeId: 'core-theme',
  },
});

console.log(updated.colorStudio.activeTheme);
await client.updateColorStudioVariable({
  key: 'chat.accent',
  value: '#06B6D4',
});

await client.updateColorStudioGroup({
  groupId: 'chat',
  group: { name: 'Chat', description: 'Conversation colors.' },
});

await client.setActiveColorTheme({ themeId: 'core-theme', makeDefault: true });
await client.duplicateColorTheme({ themeId: 'core-theme', name: 'Spring Theme' });

Color Studio writes go through the admin application API, so the SDK must be configured with appId and an admin-capable authenticated context.

Organizations

Organization helpers use the authenticated admin API, so the SDK needs an admin-capable token.

const { organizations } = await client.organizations.getMine();

const organization = await client.organizations.create({
  name: 'Acme Studio',
  website: 'https://acme.example',
});

await client.organizations.updateProfile(organization.id, {
  logoUrl: '/uploads/acme-logo.png',
  contact: { email: 'ops@acme.example' },
});

const invite = await client.organizations.createInvite({
  organizationId: organization.id,
  role: 'member',
});

Mobile Splash

const splash = await client.getSplashConfig();

console.log(splash?.logoUrl);
console.log(splash?.variants.dark.backgroundImageUrl);

Build tooling can fetch the same unauthenticated config directly:

curl "https://your-appkit-domain.com/api/v1/mobile/splash?app_slug=my-app"