Legacy Apps SDKlegacy
Reference for the deprecated TypeScript Apps SDK (KAppServer, the client and React SDKs, and the apps CLI), and how to migrate an SDK app to a JSON app definition.
The Apps SDK was a TypeScript framework for building Kustomer apps as a hosted service. You wrote an Express server with KAppServer, which generated the app definition from code, registered it, received events and webhooks, and served client-side KViews.
Packages
How an SDK app looks
import { KAppServer } from '@kustomer/apps-server'
import pkg from '../package.json'
import changelog from '../changelog.json'
import { settings } from './settings'
import * as klasses from './klasses'
import * as events from './events'
const kapp = new KAppServer({
app: pkg.name,
version: pkg.version,
title: 'Acme Orders',
visibility: 'private',
description: 'Orders from Acme, on the customer timeline.',
roles: [],
url: process.env.BASE_URL,
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
iconUrl: `${process.env.BASE_URL}/assets/icon.png`,
changelog,
appDetails: {
appDeveloper: { name: 'Acme', website: 'https://acme.example', supportEmail: 'support@acme.example' },
},
settings,
})
kapp.onInstall = async (user, org) => {
kapp.log.info('onInstall', { user, org })
}
kapp.klasses.register(klasses.order.name, klasses.order.schema)
kapp.serverHooks.on('order', klasses.order.onHook)
kapp.events.on('customer', 'create', events.customer.create(kapp))
export default kappimport kapp from './kapp'
await kapp.start({ port: Number(process.env.PORT ?? 3000) })The constructor options are the same top-level keys as a JSON definition, plus the URL your server is reachable at. settings uses the same shape as a definition's settings.
Migrate to an app definition
Most SDK apps translate directly. The work is moving logic that ran in your handlers into Kustomer workflows, actions and commands, so that Kustomer runs it instead of your server.
Export what the SDK registers
Fetch your latest registered version with
GET /v1/apps/available/{appVersion}. Copy its listing details,roles,settingsandappDetailsinto your JSON file as a starting point.Replace each handler
Work through the table above. Build each workflow in the workflow editor, test it, then export it into the definition. See Build workflows in the editor first.
Keep names and Klasses
Keep the same
appname and Klass names so installed orgs keep their data. Klasses aren't deleted on upgrade, so existing records carry over.Ship a major version
Register the definition as a new major version: it removes your server from the app, and orgs should review the change. Once every org has upgraded, you can retire the server.