title: Schemas
description: Schemas for the @socotra/ec-react-schemas package.
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/v4';
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
accountStateEnumSchema | AccountStateEnum |
accountCreateSchema | AccountCreateRequest |
accountUpdateSchema | AccountUpdateRequest |
Billings
credit-distribution-request-schema.ts
creditDistributionRequestSchema | CreditDistributionRequest |
credit-distribution-response-schema.ts
creditDistributionResponseSchema | CreditDistributionResponse |
credit-distribution-reverse-request.ts
creditDistributionReverseRequestSchema | CreditDistributionReverseRequest |
credit-distribution-schemas.ts
creditDistributionStateEnumSchema | CreditDistributionStateEnum |
delinquency-schemas.ts
advanceLapseToEnumSchema | |
delinquencyLevelEnumSchema | |
delinquencyStateEnumSchema | |
delinquencyReferenceTypeEnumSchema | |
delinquencySettingsSchema | DelinquencySettings |
delinquencyReferenceSchema | DelinquencyReferenceType |
delinquencyResponseSchema | DelinquencyResponse |
| AdvanceLapseTo |
| DelinquencyLevel |
| DelinquencyState |
| DelinquencyReference |
ledger-account-response-schema.ts
ledgerAccountResponseSchema | LedgerAccountResponse |
ledger-account-schemas.ts
ledgerAccountReferenceTypeEnumSchema | LedgerAccountReferenceTypeEnum |
ledgerAccountAccountingTypeEnumSchema | LedgerAccountAccountingTypeEnum |
ledgerAccountLineItemSchema | LedgerAccountLineItem |
payment-request-schema.ts
PaymentRequestSchema | PaymentRequest |
payment-schemas.ts
creditItemContainerTypeEnumSchema | CreditItemContainerTypeEnum |
creditItemSchema | CreditItem |
transactionMethodEnumSchema | TransactionMethodEnum |
paymentStateEnumSchema | |
| paymentStateEnum |
Charges
charge-enums.ts
chargeCategoryEnumSchema | |
chargeCategorySchema | ChargeCategory |
charge-response-schema.ts
chargeResponseSchema | ChargeResponse |
Config
account-evaluate-constraints-request.ts
accountEvaluateConstraintsRequestSchema | AccountEvaluateConstraintsRequest |
account-schema.ts
accountConfigSchema | AccountConfigRecord |
accountConfigRecordSchema | |
| AccountConfig |
auto-renewal-plan-schema.ts
autoRenewalPlanSchema | AutoRenewalPlan |
autoRenewalPlanRecordsSchema | |
bootstrap.ts
bootstrapResourceGroupSchema | BootstrapResourceGroup |
bootstrapResourceInstance | BootstrapResourceInstance |
bootstrapResourcesSchema | BootstrapResources |
bootstrapSchema | Bootstrap |
constraint-schema.ts
constraintConfigSchema | ConstraintConfig |
constraint-tables-schema.ts
constraintTablesSchema | ConstraintTables |
coverage-terms-schema.ts
CoverageTermValueSchema | CoverageTermValue |
coverageTermOptionSchema | CoverageTermOption |
coverageTermSchema | CoverageTermsConfigRecord |
coverageTermsRecordSchema | |
| CoverageTermsConfig |
data-model-schema.ts
data-type-schema.ts
dataTypeConfigSchema | DataTypeConfigRecord |
dataTypesRecordSchema | |
| DataTypeConfig |
delinquency-plan-schema.ts
delinquencyLevelSchema | |
advanceLapseToSchema | |
delinquencyPlanSchema | DelinquencyPlan |
delinquencyPlanRecordsSchema | |
element-schema.ts
elementConfigSchema | ElementConfigRecord |
elementConfigRecordSchema | |
| ElementConfig |
dependency-map-response.ts
dependencyMapResponseSchema | DependencyMapResponse |
evaluate-constraint-request.ts
evaluateConstraintsRequestSchema | EvaluateConstraintsRequest |
evaluate-constraint-response.ts
evaluateConstraintsResponseSchema | EvaluateConstraintsResponse |
field-schema.ts
fieldConfigSchema | FieldConfigRecord |
fieldConfigRecordSchema | |
| FieldConfig |
payment-schema.ts
paymentConfigSchema | PaymentConfig |
paymentConfigRecordSchema | PaymentConfigRecord |
product-schema.ts
productConfigSchema | ProductConfigRecord |
productConfigRecordSchema | |
| ProductConfig |
quantifiers.ts
quantifiersSchema | Quantifiers |
optionalQuantifiersSchema | OptionalQuantifiers |
reversal-type-schema.ts
reversalCreditTypeEnumSchema | ReversalCreditTypeEnum |
reversalTypeSchema | ReversalType |
reversalTypesRecordsSchema | |
| ReversalTypeConfigRecord |
tenant-schema.ts
tenantBaseConfigSchema | TenantBaseConfig |
transaction-types-schema.ts
transactionTypeCategorySchema | TransactionTypeCategory |
transactionTypeSchema | TransactionType |
transactionTypesRecordsSchema | |
| TransactionTypeConfigRecord |
Documents
document-response.ts
documentInstanceResponseSchema | DocumentInstanceResponse |
Policies
policy-schemas.ts
policyBillingLevelEnumSchema | |
policyBillingTriggerEnumSchema | |
| PolicyBillingLevel |
| PolicyBillingTrigger |
policy-snapshot-response.ts
policySnapshotResponseSchema | PolicySnapshotResponse |
policy-term-response.ts
policyTermResponseSchema | PolicyTermResponse |
policyTermSummaryResponse | PolicyTermSummaryResponse |
policy-term-schemas.ts
documentSummarySchema | DocumentSummary |
elementSummarySchema | ElementSummary |
subsegmentSummarySchema | SubsegmentSummary |
term-schemas.ts
documentSummarySchema | DocumentSummary |
elementSummarySchema | ElementSummary |
subsegmentSummarySchema | SubsegmentSummary |
| DocumentState |
| DocumentReference |
term-summary.ts
termSummarySchema | TermSummary |
transaction-snapshot-response.ts
segmentResponseSchema | SegmentResponse |
transactionSnapshotResponseSchema | TransactionSnapshotResponse |
transaction-underwriting-response.ts
transactionUnderwritingFlagsResponse | TransactionUnderwritingFlagsResponse |
Quotes
quote-price-response.ts
quotePriceChargeCategoryEnum | |
quotePriceChargeResponseSchema | QuotePriceChargeResponse |
quotePriceResponseSchema | QuotePriceResponse |
| QuotePriceChargeCategory |
quote-request.ts
quoteRequestSchema | QuoteRequest |
quote-schemas.ts
quoteStateSchema | QuoteState |
quoteBillingTriggerEnumSchema | |
quoteBillingLevelEnumSchema | |
| QuoteBillingTrigger |
| QuoteBillingLevel |
quote-underwriting-response.ts
quoteUnderwritingFlagsResponse | QuoteUnderwritingFlagsResponse |
reset-quote-request.ts
resetQuoteFlagsActionEnumSchema | |
resetQuoteRequestSchema | ResetQuoteRequest |
| ResetQuoteFlagsAction |
Shared
anchor-mode.ts
anchorModeEnumSchema | |
| AnchorMode |
anchor-type.ts
anchorTypeEnumSchema | |
| AnchorType |
billing-level.ts
billingLevelEnumSchema | |
| BillingLevel |
cadence.ts
currencies.ts
currencyEnumSchema | |
| CurrencyType |
days.ts
dayOfWeekEnumSchema | |
weekOfMonthEnumSchema | |
| DayOfWeek |
| WeekOfMonth |
document-reference-type.ts
documentReferenceTypeEnumSchema | |
| DocumentReference |
document-state.ts
documentStateEnumSchema | |
| DocumentState |
element-request.ts
elementCreateRequestSchema | ElementCreateRequest |
elementRequestSchema | ElementRequest |
element-response.ts
elementResponseSchema | ElementResponse |
field-values.ts
| PrimitiveValue |
| DataFieldValue |
preferences-response.ts
preferencesResponseSchema | PreferencesResponse |
timezones.ts
timezoneEnumSchema | |
| TimezoneType |
underwriting-flag-response.ts
underwritingFlagEnumSchema | UnderwritingFlagEnum |
underwritingFlagResponseSchema | UnderwritingFlagResponse |
underwriting-flags-request.ts
underwritingFlagCreateRequestSchema | UnderwritingFlagCreateRequest |
underwritingFlagsUpdateRequestSchema | UnderwritingFlagsUpdateRequest |
validation-result.ts
ulidSchema | |
validationItemSchema | ValidationItem |
validationResultSchema | ValidationResult |
Transactions
add-change-instruction-create-request.ts
addChangeInstructionCreateRequestSchema | AddChangeInstructionCreateRequest |
add-change-instruction-response.ts
addChangeInstructionResponseSchema | AddChangeInstructionResponse |
delete-change-instruction-create-request.ts
deleteChangeInstructionCreateRequestSchema | DeleteChangeInstructionCreateRequest |
delete-change-instruction-response.ts
deleteChangeInstructionResponseSchema | DeleteChangeInstructionResponse |
modify-change-instruction-create-request.ts
modifyChangeInstructionCreateRequestSchema | ModifyChangeInstructionCreateRequest |
modify-change-instruction-response.ts
modifyChangeInstructionResponseSchema | ModifyChangeInstructionResponse |
params-change-instruction-create-request.ts
paramsChangeInstructionCreateRequestSchema | ParamsChangeInstructionCreateRequest |
params-change-instruction-response.ts
paramsChangeInstructionResponseSchema | ParamsChangeInstructionResponse |
policy-transaction-response.ts
policyTransactionResponseSchema | PolicyTransactionResponse |
reset-transaction-options-request.ts
resetTransactionOptionsRequestSchema | ResetTransactionOptionsRequest |
transaction-enums.ts
transactionStateEnumSchema | |
transactionCategoryEnumSchema | |
| TransactionCategory |
| TransactionState |
transaction-price-response.ts
transactionPriceResponseSchema | TransactionPriceResponse |
transaction-underwriting-response.ts
transactionUnderwritingResponseSchema | TransactionUnderwritingResponse |