File size: 5,011 Bytes
1477a90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | import "../common/properties.tsp";
namespace Shared;
// See: https://github.com/ulid/spec/issues/94
/**
* ULID (Universally Unique Lexicographically Sortable Identifier).
*/
@pattern("^[0-7][0-9A-HJKMNP-TV-Z]{25}$")
@example("01G65Z755AFWAKHE12NY0CQ9FH")
@friendlyName("ULID")
@summary("ULID")
scalar ULID extends string;
/**
* A key is a unique string that is used to identify a resource.
*/
@pattern(
"^[a-z0-9]+(?:_[a-z0-9]+)*$",
"Must start with a lowercase letter or a number. Can contain lowercase letters, numbers, and underscores."
)
@minLength(1)
@maxLength(64)
@friendlyName("ResourceKey")
@summary("Resource Key")
@example("resource_key")
scalar ResourceKey extends string;
/**
* ULID ID or Resource Key.
*/
@friendlyName("ULIDOrResourceKey")
@summary("ULID ID or Resource Key")
union ULIDOrResourceKey {
id: ULID,
key: ResourceKey,
}
/**
* ExternalResourceKey is a unique string that is used to identify a resource in an
* external system.
*/
@maxLength(256)
@minLength(1)
@friendlyName("ExternalResourceKey")
@summary("External Resource Key")
@example("019ae40f-4258-7f15-9491-842f42a7d6ac")
scalar ExternalResourceKey extends string;
/**
* ULID ID or External Resource Key.
*/
@friendlyName("ULIDOrExternalResourceKey")
@summary("ULID ID or External Resource Key")
union ULIDOrExternalResourceKey {
id: ULID,
key: ExternalResourceKey,
}
/**
* [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in
* UTC.
*/
@encode(DateTimeKnownEncoding.rfc3339)
@friendlyName("DateTime")
@summary("RFC3339 Date-Time")
@example(DateTime.fromISO("2023-01-01T01:01:01.001Z"))
scalar DateTime extends utcDateTime;
// This is a reasonably good RE2-safe ISO8601 duration pattern that allows fractional components (though overly permissive)
// It matches patterns such as
// - P1Y
// - P1.5Y
// - P1Y2M1D
// - P1Y2MT <= invalid: must have time component defined after T
// - P1Y2MT1H2S
// - P1Y2.3MT1.4H2S <= invalid: spec only allows for a single fractional component
//
// A stricter alternative that doesn't allow fractional components is: ^P(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+S)?)?$
// ^before using the stricter pattern make sure to double escape the backslashes
/**
* [ISO 8601 Duration](https://docs.digi.com/resources/documentation/digidocs/90001488-13/reference/r_iso_8601_duration_format.htm)
* string.
*/
@encode(DurationKnownEncoding.ISO8601)
@pattern("^P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$")
@friendlyName("ISO8601Duration")
@summary("ISO 8601 Duration")
@example("P1Y")
scalar ISO8601Duration extends string;
/**
* Three-letter [ISO4217](https://www.iso.org/iso-4217-currency-codes.html)
* currency code. Custom three-letter currency codes are also supported for
* convenience.
*/
@pattern("^[A-Z]{3}$")
@friendlyName("CurrencyCode")
@minLength(3)
@maxLength(3)
@example("USD")
scalar CurrencyCode extends string;
/**
* [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) alpha-2 country
* code. Custom two-letter country codes are also supported for convenience.
*/
@pattern("^[A-Z]{2}$")
@friendlyName("CountryCode")
@minLength(2)
@maxLength(2)
@example("US")
scalar CountryCode extends string;
/**
* Numeric represents an arbitrary precision number.
*/
@pattern("^\\-?[0-9]+(\\.[0-9]+)?$")
@friendlyName("Numeric")
scalar Numeric extends string;
/**
* Monetary amount in a specific currency.
*/
@friendlyName("CurrencyAmount")
model CurrencyAmount {
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
amount: Shared.Numeric;
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
currency: Shared.CurrencyCode;
}
/**
* Tax identifier code is a normalized tax code shown on the original identity
* document.
*/
@minLength(1)
@maxLength(32)
@friendlyName("BillingTaxIdentificationCode")
scalar TaxIdentificationCode extends string;
/**
* Recurring period with an anchor and an interval.
*/
@friendlyName("RecurringPeriod")
model RecurringPeriod {
/**
* A date-time anchor to base the recurring period on.
*/
@summary("Anchor time")
@example(DateTime.fromISO("2023-01-01T01:01:01.001Z"))
anchor: DateTime;
/**
* The interval duration in ISO 8601 format.
*/
@summary("Interval in ISO 8601 duration format")
@example("P1M")
interval: ISO8601Duration;
}
/**
* A period with defined start and end dates.
*
* The period is always inclusive at the start and exclusive at the end.
*/
@friendlyName("ClosedPeriod")
model ClosedPeriod {
/**
* The start of the period.
*
* The period is inclusive at the start.
*/
@summary("Start")
@example(DateTime.fromISO("2023-01-01T01:01:01.001Z"))
from: DateTime;
/**
* The end of the period.
*
* The period is exclusive at the end.
*/
@summary("End")
@example(DateTime.fromISO("2023-01-01T01:01:01.001Z"))
to: DateTime;
}
|