Storeware Docs

createHostedApp

The same app object, for an app Storeware hosts, with its installations and data.

import { ... } from '@storeware/plugin-sdk';

createHostedApp

The same StorewareApp as createStorewareApp, for an app Storeware hosts.

function createHostedApp(env: HostedEnv, options?: HostedAppOptions): StorewareApp<HostedInstallation>

appData

The small store Storeware keeps for one installation of a hosted app: settings, a cursor, what a shop chose. Kept as JSON, so what reads back is what JSON.stringify made of what was written.

function appData(env: HostedEnv, installationId: string): AppData

AppDataError

Something an app asked of its data that would break a limit, found before asking.

new AppDataError(message: string)

HostedInstallation

An installation of this app, as Storeware's runtime hands it over.

NameTypeDescription
installationIdstring
storeIdstring
status'active' | 'uninstalled'
scopesstring[]
webhookSecretstringVerifies Storeware's signed requests for this installation.
sessionSecretstringVerifies admin session tokens for this installation.
accessTokenstring | nullA short-lived API token for the shop. Null once uninstalled, and for a moment when the installation has asked for too many this minute.
accessTokenExpiresAtnumber | nullMilliseconds since the epoch. Null with no token.

AppDataEntry

One key this app keeps for one installation.

NameTypeDescription
keystring
valueT
updatedAtstring

StorewareHost

env.STOREWARE: the capability Storeware's runtime hands a hosted app.

NameTypeDescription
installation(by: { storeId: string; } | { installationId: string; }) => Promise<HostedInstallation | null>An installation of this app, by shop or by id. Null when it is not this app's, or when that shop runs a different release of it: code only ever reaches the shops that run it.
dataGet(installationId: string, key: string) => Promise<AppDataEntry | null>
dataPut(installationId: string, key: string, value: unknown) => Promise<AppDataEntry>
dataDelete(installationId: string, key: string) => Promise<boolean>
dataList(installationId: string, options?: { prefix?: string; cursor?: string; limit?: number; }) => Promise<{ entries: AppDataEntry[]; cursor: string | null; }>

HostedEnv

The whole env of a hosted app. Nothing else is in it.

NameTypeDescription
STOREWAREStorewareHost
STOREWARE_API_URLstringhttps://api.storeware.ai, the one host the code may always reach.
STOREWARE_APPstringThis app's slug.
STOREWARE_APP_ORIGINstringWhere this app is served, https://&lt;slug&gt;.storewareapps.com.

HostedAppOptions

Where a hosted app's API calls and install links point, when not Storeware's own.

NameTypeDescription
apiUrl?stringStoreware's API. env.STOREWARE_API_URL when not given.
adminUrl?stringWhere install links point. Storeware's admin when not given.
fetchImpl?typeof fetch

AppData

One installation's data, typed.

NameTypeDescription
get<T = unknown>(key: string) => Promise<AppDataEntry<T> | null>
put<T = unknown>(key: string, value: T) => Promise<AppDataEntry<T>>
delete(key: string) => Promise<boolean>
list<T = unknown>(options?: { prefix?: string; cursor?: string; limit?: number; }) => Promise<{ entries: AppDataEntry<T>[]; cursor: string | null; }>A page of keys in order, from cursor when given. At most 100 a page.

APP_DATA_MAX_VALUE_BYTES

The largest value kept under one key, as JSON, in bytes.

const APP_DATA_MAX_VALUE_BYTES: number

APP_DATA_MAX_KEYS

The most keys one installation may keep.

const APP_DATA_MAX_KEYS: 1000

APP_DATA_MAX_TOTAL_BYTES

The most bytes one installation may keep, across every key.

const APP_DATA_MAX_TOTAL_BYTES: number

APP_DATA_MAX_KEY_LENGTH

The longest key.

const APP_DATA_MAX_KEY_LENGTH: 200

On this page