@nova-lang/schema
v0.4.1
Published
Nova schema library — type definitions, validation helpers, and code generation templates
Maintainers
Readme
@nova-lang/schema
Nova schema library — type definitions, validation helpers, and code generation templates.
Install
npm install @nova-lang/schemaUsage
@use "nova/schema"Modules
Types (types.nv)
Foundational type definitions — Int8 through Int64, UInt8 through UInt64, Float32/64, String, Char, Bool, Bytes, Date, DateTime, UUID, JSON, Any, Void, Never, Null, Array, Map, Record, Tuple, Union, Intersection, Optional.
Validation (validation.nv)
| Function | Description |
|----------|-------------|
| validate-required(value, fieldName) | Check value is not empty |
| validate-min(value, min, fieldName) | Check minimum value |
| validate-max(value, max, fieldName) | Check maximum value |
| validate-range(value, min, max, fieldName) | Check value range |
| validate-length(value, minLen, maxLen, fieldName) | Check string/array length |
| validate-email(value, fieldName) | Validate email format |
| validate-url(value, fieldName) | Validate URL format |
| validate-pattern(value, pattern, fieldName) | Match regex pattern |
| validate-one-of(value, options, fieldName) | Check value in options |
| validate-type(value, expectedType, fieldName) | Validate value type |
| validate-schema(value, schemaName) | Validate against schema |
API (api.nv)
| Function | Description |
|----------|-------------|
| api-endpoint(method, path, desc) | Define API endpoint |
| api-request(body) | Define request body |
| api-response(status, body) | Define response |
| api-section(title) | Group endpoints |
Code Generation (codegen.nv)
| Function | Description |
|----------|-------------|
| codegen-go(schemaName, fields) | Generate Go types |
| codegen-typescript(schemaName, fields) | Generate TypeScript types |
| codegen-python(schemaName, fields) | Generate Python types |
| codegen-rust(schemaName, fields) | Generate Rust types |
| codegen-java(schemaName, fields) | Generate Java types |
| codegen-protobuf(schemaName, fields) | Generate Protobuf definitions |
| codegen-json-schema(schemaName, fields) | Generate JSON Schema |
Database (db.nv)
| Function | Description |
|----------|-------------|
| db-table(name, @body) | Define table schema |
| db-column(name, type, constraints) | Define column |
| db-index(name, table, columns) | Define index |
| db-foreign-key(column, ref-table, ref-column) | Define foreign key |
| db-relation(name, type, from, to) | Define relation |
| db-migration(version, desc, @body) | Define migration |
| db-query(sql, params) | Define SQL query |
| db-seed(table, data) | Define seed data |
GraphQL (graphql.nv)
| Function | Description |
|----------|-------------|
| gql-schema(name, @body) | Define GraphQL schema |
| gql-type(name, kind, @body) | Define type/input/interface |
| gql-field(name, type, args) | Define field |
| gql-input(name, @body) | Define input type |
| gql-enum(name, values) | Define enum |
| gql-union(name, types) | Define union |
| gql-interface(name, @body) | Define interface |
| gql-query(name, @body) | Define query |
| gql-mutation(name, @body) | Define mutation |
| gql-subscription(name, @body) | Define subscription |
| gql-directive(name, locations, args) | Define directive |
gRPC (grpc.nv)
| Function | Description |
|----------|-------------|
| grpc-service(name, @body) | Define gRPC service |
| grpc-rpc(name, input, output, stream) | Define RPC method |
| grpc-message(name, @body) | Define message |
| grpc-field(name, type, tag) | Define field |
| grpc-enum(name, values) | Define enum |
| grpc-oneof(name, @body) | Define oneof |
| grpc-map(name, key-type, value-type) | Define map field |
| grpc-option(name, value) | Set protobuf option |
| grpc-package(name) | Set protobuf package |
| grpc-import(path) | Import protobuf file |
OpenAPI (openapi.nv)
| Function | Description |
|----------|-------------|
| openapi-spec(title, version, @body) | Define OpenAPI spec |
| openapi-path(path, method, @body) | Define API path |
| openapi-parameter(name, type, location, required) | Define parameter |
| openapi-response(status, desc, @body) | Define response |
| openapi-request-body(content-type, @body) | Define request body |
| openapi-schema(name, @body) | Define schema |
| openapi-property(name, type, required) | Define property |
| openapi-tag(name, desc) | Define tag |
| openapi-security(scheme, type) | Define security scheme |
| openapi-server(url, desc) | Define server |
License
MIT
