Skip to main content

API Schemas

@superbright/indexeddb-orm ships generated Zod schemas for every object in the inResi REST API. They are published under the /schemas subpath so consumers can validate API responses without maintaining hand-written types.

Installation

No extra packages needed — schemas are bundled with the ORM. Zod is a peer dependency.

pnpm add @superbright/indexeddb-orm zod

Usage

import { UnitSchema, PropertySchema, MediaSchema } from '@superbright/indexeddb-orm/schemas';

// Parse an API response
const unit = UnitSchema.parse(apiResponse.data);

// Safe parse (no throw)
const result = PropertySchema.safeParse(data);
if (result.success) {
console.log(result.data.name);
}

// Inferred TypeScript types
import type { Unit, Property } from '@superbright/indexeddb-orm/schemas';

Available schemas

SchemaTypeDescription
UnitSchemaUnitResidential unit with pricing, dimensions, media
PropertySchemaPropertyBuilding / property record
MediaSchemaMediaImage or video asset
UserSchemaUserPlatform user
FloorPlanSchemaFloorPlanFloor plan with rooms and styles
RoomSchemaRoomIndividual room within a floor plan
StyleSchemaStyleFurniture style / theme
RenderedStyleSchemaRenderedStyleRendered floor plan images for a style
UnitAmenitySchemaUnitAmenityAmenity attached to a unit
UnitRenderedStyleSchemaUnitRenderedStyleJoin between a unit and a rendered style
FloorplanStylesSchemaFloorplanStylesJoin between a floor plan and a style
FurnitureSchemaFurnitureFurniture item
FurnitureInRoomsSchemaFurnitureInRoomsFurniture placement within a room
EmbedEnumsSchemaEmbedEnumsEnum values used by the embed API
PropertyAmenitySchemaPropertyAmenityAmenity attached to a property
PropertyHighlightSchemaPropertyHighlightHighlight tag for a property
ExternalServicesSchemaExternalServicesThird-party integration record
ExternalServiceUpdateSchemaExternalServiceUpdatePatch payload for an integration
ExternalServicesUpdateRequestSchemaExternalServicesUpdateRequestBulk update request
ExternalServiceConfigSchemaExternalServiceConfigIntegration config object
RenderJobSchemaRenderJobBackground render job
QueueJobSchemaQueueJobGeneric queue job
UploadUrlSchemaUploadUrlPre-signed upload URL response
LeadSchemaLeadSales lead record
LeadActivitySchemaLeadActivityActivity event on a lead
LeadActivityItemSchemaLeadActivityItemActivity item in a lead timeline
LeadsListResponseSchemaLeadsListResponsePaginated leads response
LeadActivitiesResponseSchemaLeadActivitiesResponsePaginated activities response
LeadDetailsResponseSchemaLeadDetailsResponseLead detail payload
PaginationSchemaPaginationPage metadata
UserWebhookSchemaUserWebhookWebhook integration record
ErrorSchemaErrorStandard API error
ErrorUnprocessableEntitySchemaErrorUnprocessableEntity422 validation error

Extending schemas

All schemas are plain Zod objects, so you can extend or pick from them:

import { UnitSchema } from '@superbright/indexeddb-orm/schemas';

// Add fields that your API layer returns but aren't in the base spec
const UnitWithScoreSchema = UnitSchema.extend({
_score: z.number().optional(),
});

// Pick only the fields you need
const UnitSummarySchema = UnitSchema.pick({
id: true,
name: true,
base_price: true,
slug: true,
});

Response schema overrides

A second subpath (/response-schemas) exports stricter Zod validators for core embed API response shapes:

import { PropertyResponseSchema, BootstrapDataSchema } from '@superbright/indexeddb-orm/response-schemas';

These are generated from src/scripts/response-schema-overrides.json because the OpenAPI spec is missing full Media/Property shapes, required markers, and nullable annotations for several embed-specific schemas. The overrides fill those gaps until the spec is updated.

This is a workaround, not a solution. Once the OpenAPI spec is updated with the correct shapes, the override file and custom generation section can be deleted.

Generated files

All three files live in src/api/ and are committed — never edit them by hand:

FileSourceTool
src/api/api.generated.tsLive API (/docs/json)openapi-typescript
src/api/schemas.generated.tsopenapi.json componentsscripts/gen-schemas.mjs
src/api/response-schemas.generated.tssrc/scripts/response-schema-overrides.jsonscripts/gen-schemas.mjs

Keeping schemas up to date

Run the appropriate script depending on which environment you want to generate against:

pnpm generate:api-schema:local   # http://localhost:3000
pnpm generate:api-schema:dev # https://api.dev.inresi.link
pnpm generate:api-schema:prod # https://api.inresiapp.com

Each script validates the spec, generates src/api/api.generated.ts via openapi-typescript, then runs scripts/gen-schemas.mjs to regenerate the two Zod schema files.

After regenerating, build and publish:

pnpm generate:api-schema:prod
pnpm build
npm version patch
npm publish

prepublishOnly runs generate:api-schema:dev automatically, so the generated files are always fresh on publish.