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
| Schema | Type | Description |
|---|---|---|
UnitSchema | Unit | Residential unit with pricing, dimensions, media |
PropertySchema | Property | Building / property record |
MediaSchema | Media | Image or video asset |
UserSchema | User | Platform user |
FloorPlanSchema | FloorPlan | Floor plan with rooms and styles |
RoomSchema | Room | Individual room within a floor plan |
StyleSchema | Style | Furniture style / theme |
RenderedStyleSchema | RenderedStyle | Rendered floor plan images for a style |
UnitAmenitySchema | UnitAmenity | Amenity attached to a unit |
UnitRenderedStyleSchema | UnitRenderedStyle | Join between a unit and a rendered style |
FloorplanStylesSchema | FloorplanStyles | Join between a floor plan and a style |
FurnitureSchema | Furniture | Furniture item |
FurnitureInRoomsSchema | FurnitureInRooms | Furniture placement within a room |
EmbedEnumsSchema | EmbedEnums | Enum values used by the embed API |
PropertyAmenitySchema | PropertyAmenity | Amenity attached to a property |
PropertyHighlightSchema | PropertyHighlight | Highlight tag for a property |
ExternalServicesSchema | ExternalServices | Third-party integration record |
ExternalServiceUpdateSchema | ExternalServiceUpdate | Patch payload for an integration |
ExternalServicesUpdateRequestSchema | ExternalServicesUpdateRequest | Bulk update request |
ExternalServiceConfigSchema | ExternalServiceConfig | Integration config object |
RenderJobSchema | RenderJob | Background render job |
QueueJobSchema | QueueJob | Generic queue job |
UploadUrlSchema | UploadUrl | Pre-signed upload URL response |
LeadSchema | Lead | Sales lead record |
LeadActivitySchema | LeadActivity | Activity event on a lead |
LeadActivityItemSchema | LeadActivityItem | Activity item in a lead timeline |
LeadsListResponseSchema | LeadsListResponse | Paginated leads response |
LeadActivitiesResponseSchema | LeadActivitiesResponse | Paginated activities response |
LeadDetailsResponseSchema | LeadDetailsResponse | Lead detail payload |
PaginationSchema | Pagination | Page metadata |
UserWebhookSchema | UserWebhook | Webhook integration record |
ErrorSchema | Error | Standard API error |
ErrorUnprocessableEntitySchema | ErrorUnprocessableEntity | 422 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:
| File | Source | Tool |
|---|---|---|
src/api/api.generated.ts | Live API (/docs/json) | openapi-typescript |
src/api/schemas.generated.ts | openapi.json components | scripts/gen-schemas.mjs |
src/api/response-schemas.generated.ts | src/scripts/response-schema-overrides.json | scripts/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.