@grupolapa/desarrollos-sdk
v0.1.0
Published
Framework-agnostic TypeScript SDK for Grupo LAPA public desarrollo integrations.
Readme
Desarrollos SDK
Framework-agnostic TypeScript helpers for third-party websites that integrate with Grupo LAPA developments through the public API.
Installation
npm install @grupolapa/desarrollos-sdkpnpm add @grupolapa/desarrollos-sdkThe public API base URL is:
https://grupolapa.com/api/public/v1/desarrollosAgent-readable integration instructions are available at:
https://grupolapa.com/api/public/v1/desarrollos/agent.jsonBrowser Reads and Quotes
import { createDesarrollosClient } from "@grupolapa/desarrollos-sdk";
import {
calculateQuote,
getResolvedSchemeForUnit,
} from "@grupolapa/desarrollos-sdk/quote";
import {
getSelectableUnitHotspots,
resolveInitialSitemapMap,
} from "@grupolapa/desarrollos-sdk/sitemap";
const client = createDesarrollosClient({
baseUrl: "https://grupolapa.com/api/public/v1/desarrollos",
});
const desarrolloKey = "viamare";
const [{ snapshot }, inventory, sitemap, paymentMethods] = await Promise.all([
client.getSnapshot({ desarrolloKey }),
client.getInventory({ desarrolloKey }),
client.getSitemap({ desarrolloKey }),
client.getPaymentMethods({ desarrolloKey }),
]);
const map = resolveInitialSitemapMap(sitemap);
const hotspots = map ? getSelectableUnitHotspots(map) : [];
const unit = inventory.inventory.find(
(item) => item.id === hotspots[0]?.unitId,
);
const scheme = unit
? getResolvedSchemeForUnit(unit, snapshot.content.paymentSchemes, null)
: null;
const quote =
unit && scheme
? calculateQuote(
unit,
{
unitId: unit.id,
scheme: scheme.id,
plusvaliaAnnualPct:
snapshot.content.financeRules.defaults.plusvaliaAnnualPct,
postDeliveryYears:
snapshot.content.financeRules.defaults.postDeliveryYears,
downPaymentPct: snapshot.content.financeRules.defaults.downPaymentPct,
includeIva: false,
},
scheme,
snapshot.content.financeRules,
)
: null;Trusted Server Flow
Keep lapa_dev_<prefix>_<secret> API keys on a server. Use the trusted server
client to list allowed developments and mint short-lived browser session tokens.
Browser reservation writes should use only those session tokens.
import { createDesarrollosServerClient } from "@grupolapa/desarrollos-sdk/server";
const serverClient = createDesarrollosServerClient({
baseUrl: "https://grupolapa.com/api/public/v1/desarrollos",
apiKey: process.env.LAPA_DESARROLLOS_API_KEY!,
});
export async function createBrowserSession(origin: string) {
return await serverClient.createBrowserSession({
desarrolloKey: "viamare",
origin,
});
}import { createDesarrollosClient } from "@grupolapa/desarrollos-sdk";
const browserClient = createDesarrollosClient({
baseUrl: "https://grupolapa.com/api/public/v1/desarrollos",
});
await browserClient.createReservation({
desarrolloKey: "viamare",
sessionToken,
request: {
items: [{ unitId: "unit_1" }],
payment: {
provider: "stripe",
returnUrl: "https://partner.example.com/return",
},
},
});Sitemap Rendering
The API returns image and overlay asset URLs plus SVG-native shape metadata. The SDK does not mutate the DOM. Use the sitemap helpers to choose maps and resolve unit hotspots, then render the overlay with the frontend framework of your choice.
import {
getShapeForUnit,
getSitemapMapAssetPlan,
resolveInitialSitemapMap,
} from "@grupolapa/desarrollos-sdk/sitemap";
const map = resolveInitialSitemapMap(sitemap);
if (map) {
const assets = getSitemapMapAssetPlan(map);
const shape = getShapeForUnit(map, selectedUnitId);
}Exports
@grupolapa/desarrollos-sdk: browser-safe client, public types, andDesarrollosApiError.@grupolapa/desarrollos-sdk/server: trusted server API-key client.@grupolapa/desarrollos-sdk/quote: quote, selection, payment, inventory, formatting, Entrada/action, and product helpers.@grupolapa/desarrollos-sdk/sitemap: sitemap asset, hotspot, and shape helpers.@grupolapa/desarrollos-sdk/types: domain and public REST TypeScript types.
