Skip to content

Your first app

We’ll build an app for a window fitter: it asks which brand they install and tells the assistant to write it on every line of the quote.

Terminal window
npm install @prezzando/plugin-sdk

The package carries the contract, the validator and a CLI. It has no dependency on Prezzando itself: an app is an ordinary module.

windows.ts
import { definePlugin, PLUGIN_API_VERSION } from "@prezzando/plugin-sdk";
export default definePlugin({
id: "windows",
apiVersion: PLUGIN_API_VERSION,
version: "1.0.0",
name: "Windows and doors",
summary: "From the survey to the quote, with your own price list.",
icon: "hammer",
settings: [
{
key: "brand",
type: "text",
label: "Brand you install",
help: "Written next to each item, so the client knows what they're buying.",
maxLength: 60,
},
],
prompt: (ctx) => {
const brand = typeof ctx.settings.brand === "string" ? ctx.settings.brand : "";
if (!brand) return null;
return `### Windows and doors\n\nThis company fits ${brand}. Name the series in the detail of every item.`;
},
});

Three things are worth naming.

definePlugin validates the shape when the module loads, not when a customer first uses the app: a malformed manifest stops the host from starting, which is where a programming error belongs.

settings are descriptors, not a form. The host draws the panel from them and validates the saved values against them, on the server too — a modified client can’t write a value outside the declared options.

prompt receives the settings and returns text, or null when there’s nothing to say. It runs on every request, so it must be synchronous and cheap: no network, no database.

Terminal window
npx prezzando-preview windows.ts

The storefront card, the settings panel and the resulting prompt, in the browser, reloading every time you save the file. See Seeing it before shipping.

Terminal window
npx prezzando-plugin validate windows.ts
npx prezzando-plugin panel windows.ts --settings '{"brand":"Schüco"}'
npx prezzando-plugin prompt windows.ts --settings '{"brand":"Schüco"}'

The CLI loads the manifest, applies the settings and prints what the panel and the model would get. It’s the fastest way to catch a prompt that says nothing because a setting was left empty.