The CommonGrants.Types
namespace contains types that are used throughout the protocol.
Types
Learn more about the base data types supported by the CommonGrants protocol:
String
Type | Description |
---|
string | A sequence of characters |
uuid | A universally unique identifier |
url | A Uniform Resource Locator (URL) |
Numeric
Type | Description |
---|
numeric | A number with an arbitrary precision and scale |
integer | A whole number without decimals |
decimalString | A decimal number encoded as a string to preserve scale |
Date and time
Type | Description |
---|
isoTime | Time without timezone in ISO 8601 format (HH:mm:ss) |
isoDate | Calendar date in ISO 8601 format (YYYY-MM-DD) |
utcDateTime | Datetime with UTC timezone in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ) |
offsetDateTime | Datetime with timezone in ISO 8601 format (YYYY-MM-DDThh:mm:ss±hh:mm) |
Other types
Type | Description |
---|
boolean | A true or false value |
array | An ordered list of values |
record | A collection of key-value pairs |
null | A null value |
unknown | A value of with any type |
Usage
You can use the types listed above to define custom models in your TypeSpec project.
import "@common-grants/core"
// Exposes the `Types` namespace so that it can be accessed
// without a `CommonGrants` prefix
id: Types.uuid; // CommonGrants-defined type
description: string; // Standard TypeSpec type
tags: Array<string>; // A templated type