EC React Schemas
Schemas for the Socotra Insurance Suite
This package provides a comprehensive collection of zod
schemas that
define the core data structures for Socotra’s Enterprise Components.
These schemas are fundamental to ensuring type safety, data integrity,
and validation across the platform, from backend services to frontend
components.
Core Philosophy
Zod Schemas are powerful tools for data validation and type inference. They are used to define the structure of the data that is passed into and out of the library. They are also used to define the structure of the data that is stored in the database.
By leveraging the power of Zod, we can ensure that the data that is passed into and out of the library is always valid and of the correct type. This is especially important for complex data structures that are used in the library, such as policies, accounts, and transactions.
Key Features
Domain Schemas: Business-specific data models (e.g., Policies, Invoices, Accounts).
Config Schemas: Structures for configuration objects (e.g., Product and UI configurations).
Service Schemas: Data contracts for API requests and responses.
Shared Schemas: Common, reusable data structures used across multiple domains.
Installation
This package has a peer dependency on zod
. Install both packages in
your project:
npm i @socotra/ec-react-schemas zod
Usage
Import schemas directly from the package to use them for data
validation, type inference, or in conjunction with libraries like
react-hook-form
.
import { policyResponseSchema } from '@socotra/ec-react-schemas';
import { z } from 'zod';
type Policy = z.infer<typeof policyResponseSchema>;
function validatePolicy(data: unknown): Policy {
return policyResponseSchema.parse(data);
}
Documentation
The documentation for this package is generated from a script that must be run after the package is built.
To contribute to the documentation, clone the repo and run the following command after adding, updating, or removing schemas:
git clone https://github.com/socotra/ec-react.git
cd ec-react/packages/schemas
pnpm run docs:generate
This will update the README.md
file with the documentation for the
schemas. Copy and paste this file into
ec-react/packages/docs/src/schemas/index.md
Finally, run pnpm run sync
to update the documentation in the
README.md
files of this and other packages.
Follow instructions in the packages/docs/README.md
file to build the
documentation and update the Socotra Documentation
repo.
Available Schemas
Accounts
account-request.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
Billings
credit-distribution-request-schema.ts
Zod Schema |
Type |
---|---|
|
|
credit-distribution-response-schema.ts
Zod Schema |
Type |
---|---|
|
|
credit-distribution-reverse-request.ts
Zod Schema |
Type |
---|---|
|
|
credit-distribution-schemas.ts
Zod Schema |
Type |
---|---|
|
|
delinquency-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invoice-response-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
invoice-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
ledger-account-response-schema.ts
Zod Schema |
Type |
---|---|
|
|
ledger-account-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
payment-request-schema.ts
Zod Schema |
Type |
---|---|
|
|
payment-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
|
|
Charges
charge-enums.ts
Zod Schema |
Type |
---|---|
|
|
|
|
charge-response-schema.ts
Zod Schema |
Type |
---|---|
|
|
Config
account-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
auto-renewal-plan-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
bootstrap.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
|
constraint-schema.ts
Zod Schema |
Type |
---|---|
|
|
constraint-tables-schema.ts
Zod Schema |
Type |
---|---|
|
|
coverage-terms-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
|
|
data-model-schema.ts
Zod Schema |
Type |
---|---|
|
|
data-type-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
delinquency-plan-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
element-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
field-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
payment-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
product-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
quantifiers.ts
Zod Schema |
Type |
---|---|
|
|
|
|
reversal-type-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
tenant-schema.ts
Zod Schema |
Type |
---|---|
|
|
transaction-types-schema.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
Documents
document-response.ts
Zod Schema |
Type |
---|---|
|
|
Policies
policy-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
policy-snapshot-response.ts
Zod Schema |
Type |
---|---|
|
|
policy-term-response.ts
Zod Schema |
Type |
---|---|
|
|
|
|
policy-term-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
term-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
|
|
term-summary.ts
Zod Schema |
Type |
---|---|
|
|
transaction-snapshot-response.ts
Zod Schema |
Type |
---|---|
|
|
|
|
transaction-underwriting-response.ts
Zod Schema |
Type |
---|---|
|
|
Quotes
quote-dependency-map-response.ts
Zod Schema |
Type |
---|---|
|
|
quote-evaluate-constraint-request.ts
Zod Schema |
Type |
---|---|
|
|
quote-evaluate-constraint-response.ts
Zod Schema |
Type |
---|---|
|
|
quote-price-response.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
quote-request.ts
Zod Schema |
Type |
---|---|
|
|
quote-schemas.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
|
|
quote-underwriting-response.ts
Zod Schema |
Type |
---|---|
|
|
reset-quote-request.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
Transactions
add-change-instruction-create-request.ts
Zod Schema |
Type |
---|---|
|
|
add-change-instruction-response.ts
Zod Schema |
Type |
---|---|
|
|
delete-change-instruction-create-request.ts
Zod Schema |
Type |
---|---|
|
|
delete-change-instruction-response.ts
Zod Schema |
Type |
---|---|
|
|
modify-change-instruction-create-request.ts
Zod Schema |
Type |
---|---|
|
|
modify-change-instruction-response.ts
Zod Schema |
Type |
---|---|
|
|
params-change-instruction-create-request.ts
Zod Schema |
Type |
---|---|
|
|
params-change-instruction-response.ts
Zod Schema |
Type |
---|---|
|
|
policy-transaction-response.ts
Zod Schema |
Type |
---|---|
|
|
reset-transaction-options-request.ts
Zod Schema |
Type |
---|---|
|
|
transaction-enums.ts
Zod Schema |
Type |
---|---|
|
|
|
|
|
|
|
transaction-price-response.ts
Zod Schema |
Type |
---|---|
|
|
transaction-underwriting-response.ts
Zod Schema |
Type |
---|---|
|
|