@nxgt/typespec 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +40 -9
  2. package/docs/README.md +1 -0
  3. package/docs/guide/columns.md +25 -11
  4. package/docs/guide/scalars.md +288 -0
  5. package/docs/roadmap.md +14 -0
  6. package/docs/troubleshooting.md +94 -2
  7. package/lib/scalars/color/hex-color-code.tsp +17 -0
  8. package/lib/scalars/color/hsl.tsp +18 -0
  9. package/lib/scalars/color/hsla.tsp +18 -0
  10. package/lib/scalars/color/rgb.tsp +18 -0
  11. package/lib/scalars/color/rgba.tsp +18 -0
  12. package/lib/scalars/color.tsp +6 -0
  13. package/lib/scalars/date-time/date-time.tsp +19 -0
  14. package/lib/scalars/date-time/date.tsp +17 -0
  15. package/lib/scalars/date-time/iso-duration.tsp +17 -0
  16. package/lib/scalars/date-time/local-date-time.tsp +15 -0
  17. package/lib/scalars/date-time/local-time.tsp +15 -0
  18. package/lib/scalars/date-time/time-zone.tsp +18 -0
  19. package/lib/scalars/date-time/time.tsp +17 -0
  20. package/lib/scalars/date-time/timestamp.tsp +15 -0
  21. package/lib/scalars/date-time/utc-offset.tsp +15 -0
  22. package/lib/scalars/date-time.tsp +10 -0
  23. package/lib/scalars/encoding/base64-url.tsp +17 -0
  24. package/lib/scalars/encoding/base64.tsp +18 -0
  25. package/lib/scalars/encoding/hexadecimal.tsp +15 -0
  26. package/lib/scalars/encoding/jwt.tsp +19 -0
  27. package/lib/scalars/encoding/sha256.tsp +16 -0
  28. package/lib/scalars/encoding/sha512.tsp +16 -0
  29. package/lib/scalars/encoding.tsp +7 -0
  30. package/lib/scalars/finance/currency.tsp +17 -0
  31. package/lib/scalars/finance/iban.tsp +19 -0
  32. package/lib/scalars/finance.tsp +3 -0
  33. package/lib/scalars/geo/latitude.tsp +14 -0
  34. package/lib/scalars/geo/longitude.tsp +14 -0
  35. package/lib/scalars/geo.tsp +3 -0
  36. package/lib/scalars/identifier/cuid2.tsp +17 -0
  37. package/lib/scalars/identifier/guid.tsp +12 -0
  38. package/lib/scalars/identifier/isbn.tsp +18 -0
  39. package/lib/scalars/identifier/ksuid.tsp +18 -0
  40. package/lib/scalars/identifier/nano-id.tsp +16 -0
  41. package/lib/scalars/identifier/object-id.tsp +16 -0
  42. package/lib/scalars/identifier/sem-ver.tsp +17 -0
  43. package/lib/scalars/identifier/ulid.tsp +17 -0
  44. package/lib/scalars/identifier/uuid-v4.tsp +16 -0
  45. package/lib/scalars/identifier/uuid-v7.tsp +16 -0
  46. package/lib/scalars/identifier/uuid.tsp +18 -0
  47. package/lib/scalars/identifier/xid.tsp +17 -0
  48. package/lib/scalars/identifier.tsp +13 -0
  49. package/lib/scalars/locale/country-code.tsp +17 -0
  50. package/lib/scalars/locale/locale.tsp +20 -0
  51. package/lib/scalars/locale.tsp +3 -0
  52. package/lib/scalars/network/cidr-v4.tsp +19 -0
  53. package/lib/scalars/network/cidr-v6.tsp +18 -0
  54. package/lib/scalars/network/email-address.tsp +20 -0
  55. package/lib/scalars/network/hostname.tsp +21 -0
  56. package/lib/scalars/network/http-url.tsp +21 -0
  57. package/lib/scalars/network/ip-v4.tsp +17 -0
  58. package/lib/scalars/network/ip-v6.tsp +18 -0
  59. package/lib/scalars/network/ip.tsp +17 -0
  60. package/lib/scalars/network/mac.tsp +16 -0
  61. package/lib/scalars/network/phone-number.tsp +18 -0
  62. package/lib/scalars/network.tsp +11 -0
  63. package/lib/scalars/number/big-int.tsp +15 -0
  64. package/lib/scalars/number/long.tsp +17 -0
  65. package/lib/scalars/number/negative-float.tsp +13 -0
  66. package/lib/scalars/number/negative-int.tsp +15 -0
  67. package/lib/scalars/number/non-negative-float.tsp +13 -0
  68. package/lib/scalars/number/non-negative-int.tsp +15 -0
  69. package/lib/scalars/number/non-positive-float.tsp +13 -0
  70. package/lib/scalars/number/non-positive-int.tsp +15 -0
  71. package/lib/scalars/number/port.tsp +14 -0
  72. package/lib/scalars/number/positive-float.tsp +13 -0
  73. package/lib/scalars/number/positive-int.tsp +15 -0
  74. package/lib/scalars/number/safe-int.tsp +16 -0
  75. package/lib/scalars/number.tsp +13 -0
  76. package/lib/scalars/string/emoji.tsp +21 -0
  77. package/lib/scalars/string/non-empty-string.tsp +15 -0
  78. package/lib/scalars/string.tsp +3 -0
  79. package/lib/scalars/value.tsp +2 -0
  80. package/lib/scalars.tsp +13 -12
  81. package/package.json +4 -4
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A CSS `rgba()` color in the comma syntax: `rgba(255, 0, 0, 0.5)`. As `rgb`
9
+ * plus an alpha: `0`, `1`, or a fraction with no trailing zero and a leading
10
+ * `0`.
11
+ *
12
+ * Specified by https://www.w3.org/TR/css-color-4/#rgb-functions.
13
+ */
14
+ @friendlyName("RGBA")
15
+ @format("rgba")
16
+ @pattern("^rgba\\((?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d), (?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d), (?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d), (?:0|1|0\\.\\d*[1-9])\\)$")
17
+ @extension("x-nxgt-scalar", "RGBA")
18
+ scalar rgba extends string;
@@ -0,0 +1,6 @@
1
+ // The color scalars, one file each under ./color/.
2
+ import "./color/hex-color-code.tsp";
3
+ import "./color/hsl.tsp";
4
+ import "./color/hsla.tsp";
5
+ import "./color/rgb.tsp";
6
+ import "./color/rgba.tsp";
@@ -0,0 +1,19 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An RFC 3339 date-time with its offset, `Z` or `±hh:mm`, kept as sent: `2024-03-10T12:00:00+02:00`.
9
+ * A time with no offset names no instant and is refused, and so is the offset `-00:00`:
10
+ * write `Z` or `+00:00`. An impossible day is refused. The range 0000 to 9999 in UTC is
11
+ * not in the pattern, nor is the leap second.
12
+ *
13
+ * Specified by https://www.rfc-editor.org/rfc/rfc3339.
14
+ */
15
+ @friendlyName("DateTime")
16
+ @format("date-time")
17
+ @pattern("^(?:\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|02-(?:0[1-9]|1\\d|2[0-8]))|(?:\\d\\d(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29)T(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)(?:Z|\\+(?:[01]\\d|2[0-3]):[0-5]\\d|-(?!00:00)(?:[01]\\d|2[0-3]):[0-5]\\d)$")
18
+ @extension("x-nxgt-scalar", "DateTime")
19
+ scalar dateTime extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A calendar date, `YYYY-MM-DD`, with no time and no time zone: `2024-02-29`. An impossible
9
+ * day, such as `2023-02-29`, is refused.
10
+ *
11
+ * Specified by https://www.rfc-editor.org/rfc/rfc3339#section-5.6.
12
+ */
13
+ @friendlyName("Date")
14
+ @format("date")
15
+ @pattern("^(?:\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|02-(?:0[1-9]|1\\d|2[0-8]))|(?:\\d\\d(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29)$")
16
+ @extension("x-nxgt-scalar", "Date")
17
+ scalar date extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An ISO 8601 duration, kept as sent and not normalised: `P1DT2H`. Weeks are not mixed with
9
+ * other units, and there is no sign. Named `isoDuration` because `duration` is TypeSpec's own.
10
+ *
11
+ * Specified by https://www.iso.org/iso-8601-date-and-time-format.html.
12
+ */
13
+ @friendlyName("Duration")
14
+ @format("duration")
15
+ @pattern("^P(?:\\d+W|(?!.*W)(?=\\d|T\\d)(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?=\\d)(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:[.,]\\d+)?S)?)?)$")
16
+ @extension("x-nxgt-scalar", "Duration")
17
+ scalar isoDuration extends string;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A date and a time on the wall clock, with no offset, not even `Z`: `2024-03-10T10:15:30`.
9
+ * The seconds are optional. An impossible day is refused.
10
+ */
11
+ @friendlyName("LocalDateTime")
12
+ @format("local-date-time")
13
+ @pattern("^(?:\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|02-(?:0[1-9]|1\\d|2[0-8]))|(?:\\d\\d(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00)-02-29)T(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$")
14
+ @extension("x-nxgt-scalar", "LocalDateTime")
15
+ scalar localDateTime extends string;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A time of day with no offset, `HH:MM`, `HH:MM:SS` or with a fraction: `10:15`. It names no
9
+ * instant until a date and a place are given; a `Z` or an offset is refused.
10
+ */
11
+ @friendlyName("LocalTime")
12
+ @format("local-time")
13
+ @pattern("^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$")
14
+ @extension("x-nxgt-scalar", "LocalTime")
15
+ scalar localTime extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An IANA time zone name in its exact case, kept as sent: `Europe/Paris`, `UTC`. Only the shape
9
+ * is checked, one to three words of letters, digits, `+`, `-` and `_`, each starting with a capital;
10
+ * the list of names is not in the pattern.
11
+ *
12
+ * Specified by https://www.iana.org/time-zones.
13
+ */
14
+ @friendlyName("TimeZone")
15
+ @format("time-zone")
16
+ @pattern("^[A-Z][A-Za-z0-9+\\-_]*(?:/[A-Z][A-Za-z0-9+\\-_]*){0,2}$")
17
+ @extension("x-nxgt-scalar", "TimeZone")
18
+ scalar timeZone extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An RFC 3339 `full-time`, kept as sent: seconds, an optional fraction, then `Z` or `±hh:mm`,
9
+ * such as `10:15:30+02:00`. A time with no offset is refused, and so is `-00:00`.
10
+ *
11
+ * Specified by https://www.rfc-editor.org/rfc/rfc3339#section-5.6.
12
+ */
13
+ @friendlyName("Time")
14
+ @format("time")
15
+ @pattern("^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)(?:\\.\\d+)?(?:Z|\\+(?:[01]\\d|2[0-3]):[0-5]\\d|-(?!00:00)(?:[01]\\d|2[0-3]):[0-5]\\d)$")
16
+ @extension("x-nxgt-scalar", "Time")
17
+ scalar time extends string;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An instant as an integer number of milliseconds since 1970-01-01T00:00:00Z, negative before
9
+ * 1970, within the range of a JavaScript `Date`, ±8640000000000000: `1710065730000`.
10
+ */
11
+ @friendlyName("Timestamp")
12
+ @minValue(-8640000000000000)
13
+ @maxValue(8640000000000000)
14
+ @extension("x-nxgt-scalar", "Timestamp")
15
+ scalar timestamp extends safeint;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A fixed offset from UTC, `±hh:mm`, from `-12:00` to `+14:00`: `+05:30`. It is not a place and
9
+ * knows nothing of daylight saving. `-00:00` is refused: write `+00:00`.
10
+ */
11
+ @friendlyName("UtcOffset")
12
+ @format("utc-offset")
13
+ @pattern("^(?:\\+(?:0\\d|1[0-3]):[0-5]\\d|\\+14:00|-(?!00:00)(?:0\\d|1[01]):[0-5]\\d|-12:00)$")
14
+ @extension("x-nxgt-scalar", "UtcOffset")
15
+ scalar utcOffset extends string;
@@ -0,0 +1,10 @@
1
+ // The date-time scalars, one file each under ./date-time/.
2
+ import "./date-time/date.tsp";
3
+ import "./date-time/date-time.tsp";
4
+ import "./date-time/iso-duration.tsp";
5
+ import "./date-time/local-date-time.tsp";
6
+ import "./date-time/local-time.tsp";
7
+ import "./date-time/time.tsp";
8
+ import "./date-time/time-zone.tsp";
9
+ import "./date-time/timestamp.tsp";
10
+ import "./date-time/utc-offset.tsp";
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * URL-safe base64 (RFC 4648, section 5): `-` and `_`, no padding, in its one
9
+ * canonical spelling. The empty string is the encoding of no bytes.
10
+ *
11
+ * Specified by https://www.rfc-editor.org/rfc/rfc4648#section-5.
12
+ */
13
+ @friendlyName("Base64URL")
14
+ @format("base64-url")
15
+ @pattern("^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-][AQgw]|[A-Za-z0-9_-]{2}[AEIMQUYcgkosw048])?$")
16
+ @extension("x-nxgt-scalar", "Base64URL")
17
+ scalar base64Url extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * Standard base64 (RFC 4648, section 4) with its padding, in its one canonical
9
+ * spelling: `YR==` decodes to the same byte as `YQ==` and is not taken. The
10
+ * empty string is the encoding of no bytes.
11
+ *
12
+ * Specified by https://www.rfc-editor.org/rfc/rfc4648#section-4.
13
+ */
14
+ @friendlyName("Base64")
15
+ @format("byte")
16
+ @pattern("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$")
17
+ @extension("x-nxgt-scalar", "Base64")
18
+ scalar base64 extends string;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * One or more hexadecimal digits, in any case, kept as sent. An odd length is
9
+ * fine; no `0x` prefix.
10
+ */
11
+ @friendlyName("Hexadecimal")
12
+ @format("hexadecimal")
13
+ @pattern("^[0-9a-fA-F]+$")
14
+ @extension("x-nxgt-scalar", "Hexadecimal")
15
+ scalar hexadecimal extends string;
@@ -0,0 +1,19 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A signed JSON Web Token in compact form: three base64url parts joined by `.`.
9
+ * Only the shape is in the pattern: that each part is in its one canonical
10
+ * spelling, that the header and the payload are JSON objects and that the
11
+ * header's `alg` is not `none` are left out, and the signature is not verified.
12
+ *
13
+ * Specified by https://www.rfc-editor.org/rfc/rfc7519.
14
+ */
15
+ @friendlyName("JWT")
16
+ @format("jwt")
17
+ @pattern("^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$")
18
+ @extension("x-nxgt-scalar", "JWT")
19
+ scalar jwt extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A SHA-256 digest: 64 hexadecimal digits, in any case, kept as sent.
9
+ *
10
+ * Specified by https://csrc.nist.gov/pubs/fips/180-4/upd1/final.
11
+ */
12
+ @friendlyName("SHA256")
13
+ @format("sha256")
14
+ @pattern("^[0-9a-fA-F]{64}$")
15
+ @extension("x-nxgt-scalar", "SHA256")
16
+ scalar sha256 extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A SHA-512 digest: 128 hexadecimal digits, in any case, kept as sent.
9
+ *
10
+ * Specified by https://csrc.nist.gov/pubs/fips/180-4/upd1/final.
11
+ */
12
+ @friendlyName("SHA512")
13
+ @format("sha512")
14
+ @pattern("^[0-9a-fA-F]{128}$")
15
+ @extension("x-nxgt-scalar", "SHA512")
16
+ scalar sha512 extends string;
@@ -0,0 +1,7 @@
1
+ // The encoding scalars, one file each under ./encoding/.
2
+ import "./encoding/base64.tsp";
3
+ import "./encoding/base64-url.tsp";
4
+ import "./encoding/hexadecimal.tsp";
5
+ import "./encoding/jwt.tsp";
6
+ import "./encoding/sha256.tsp";
7
+ import "./encoding/sha512.tsp";
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An ISO 4217 currency code, uppercase: `EUR`, `USD`. The list of codes in
9
+ * force is not in the pattern: only the shape is.
10
+ *
11
+ * Specified by https://www.iso.org/iso-4217-currency-codes.html.
12
+ */
13
+ @friendlyName("Currency")
14
+ @format("currency")
15
+ @pattern("^[A-Z]{3}$")
16
+ @extension("x-nxgt-scalar", "Currency")
17
+ scalar currency extends string;
@@ -0,0 +1,19 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An International Bank Account Number in its electronic form, uppercase, no
9
+ * spaces: `FR1420041010050500013M02606`. Two letters, two check digits, then
10
+ * 11 to 30 letters or digits. The checksum (ISO 13616, mod 97) and the
11
+ * country and its length are not in the pattern.
12
+ *
13
+ * Specified by https://www.iso.org/standard/81090.html.
14
+ */
15
+ @friendlyName("IBAN")
16
+ @format("iban")
17
+ @pattern("^[A-Z]{2}\\d{2}[A-Z0-9]{11,30}$")
18
+ @extension("x-nxgt-scalar", "IBAN")
19
+ scalar iban extends string;
@@ -0,0 +1,3 @@
1
+ // The finance scalars, one file each under ./finance/.
2
+ import "./finance/currency.tsp";
3
+ import "./finance/iban.tsp";
@@ -0,0 +1,14 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A latitude in decimal degrees, WGS 84, from -90 to 90: `48.8566`. A number, never a string.
9
+ */
10
+ @friendlyName("Latitude")
11
+ @minValue(-90)
12
+ @maxValue(90)
13
+ @extension("x-nxgt-scalar", "Latitude")
14
+ scalar latitude extends float64;
@@ -0,0 +1,14 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A longitude in decimal degrees, WGS 84, from -180 to 180: `2.3522`. A number, never a string.
9
+ */
10
+ @friendlyName("Longitude")
11
+ @minValue(-180)
12
+ @maxValue(180)
13
+ @extension("x-nxgt-scalar", "Longitude")
14
+ scalar longitude extends float64;
@@ -0,0 +1,3 @@
1
+ // The geo scalars, one file each under ./geo/.
2
+ import "./geo/latitude.tsp";
3
+ import "./geo/longitude.tsp";
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A Cuid2: a lower-case letter, then lower-case letters and digits, 2 to 32
9
+ * characters in all (24 by default).
10
+ *
11
+ * Specified by https://github.com/paralleldrive/cuid2.
12
+ */
13
+ @friendlyName("Cuid2")
14
+ @format("cuid2")
15
+ @pattern("^[a-z][a-z0-9]{1,31}$")
16
+ @extension("x-nxgt-scalar", "Cuid2")
17
+ scalar cuid2 extends string;
@@ -0,0 +1,12 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /** Any 8-4-4-4-12 hexadecimal string, no version or variant check, in any case, kept as sent. */
8
+ @friendlyName("GUID")
9
+ @format("uuid")
10
+ @pattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
11
+ @extension("x-nxgt-scalar", "GUID")
12
+ scalar guid extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An ISBN-10 or an ISBN-13, digits only (no hyphen or space). An ISBN-10 may end
9
+ * in an uppercase `X`; an ISBN-13 starts with 978, or 979 followed by 1 to 9
10
+ * (979-0 is the ISMN). The check digit is not in the pattern.
11
+ *
12
+ * Specified by https://www.isbn-international.org/content/isbn-users-manual/29.
13
+ */
14
+ @friendlyName("ISBN")
15
+ @format("isbn")
16
+ @pattern("^(?:\\d{9}[\\dX]|(?:978\\d|979[1-9])\\d{9})$")
17
+ @extension("x-nxgt-scalar", "ISBN")
18
+ scalar isbn extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A KSUID: 27 characters of base62, at most `aWgEPTl1tmebfsQzFP4bxwgy80V` (160
9
+ * bits). The alphabet is in ASCII order and the length fixed, so the pattern
10
+ * bounds the value digit by digit.
11
+ *
12
+ * Specified by https://github.com/segmentio/ksuid.
13
+ */
14
+ @friendlyName("KSUID")
15
+ @format("ksuid")
16
+ @pattern("^(?:[0-9A-Z][0-9A-Za-z]{26}|a[0-9A-V][0-9A-Za-z]{25}|aW[0-9A-Za-f][0-9A-Za-z]{24}|aWg[0-9A-D][0-9A-Za-z]{23}|aWgE[0-9A-O][0-9A-Za-z]{22}|aWgEP[0-9A-S][0-9A-Za-z]{21}|aWgEPT[0-9A-Za-k][0-9A-Za-z]{20}|aWgEPTl[0][0-9A-Za-z]{19}|aWgEPTl1[0-9A-Za-s][0-9A-Za-z]{18}|aWgEPTl1t[0-9A-Za-l][0-9A-Za-z]{17}|aWgEPTl1tm[0-9A-Za-d][0-9A-Za-z]{16}|aWgEPTl1tme[0-9A-Za][0-9A-Za-z]{15}|aWgEPTl1tmeb[0-9A-Za-e][0-9A-Za-z]{14}|aWgEPTl1tmebf[0-9A-Za-r][0-9A-Za-z]{13}|aWgEPTl1tmebfs[0-9A-P][0-9A-Za-z]{12}|aWgEPTl1tmebfsQ[0-9A-Za-y][0-9A-Za-z]{11}|aWgEPTl1tmebfsQz[0-9A-E][0-9A-Za-z]{10}|aWgEPTl1tmebfsQzF[0-9A-O][0-9A-Za-z]{9}|aWgEPTl1tmebfsQzFP[0-3][0-9A-Za-z]{8}|aWgEPTl1tmebfsQzFP4[0-9A-Za][0-9A-Za-z]{7}|aWgEPTl1tmebfsQzFP4b[0-9A-Za-w][0-9A-Za-z]{6}|aWgEPTl1tmebfsQzFP4bx[0-9A-Za-v][0-9A-Za-z]{5}|aWgEPTl1tmebfsQzFP4bxw[0-9A-Za-f][0-9A-Za-z]{4}|aWgEPTl1tmebfsQzFP4bxwg[0-9A-Za-x][0-9A-Za-z]{3}|aWgEPTl1tmebfsQzFP4bxwgy[0-7][0-9A-Za-z]{2}|aWgEPTl1tmebfsQzFP4bxwgy80[0-9A-U]|aWgEPTl1tmebfsQzFP4bxwgy80V)$")
17
+ @extension("x-nxgt-scalar", "KSUID")
18
+ scalar ksuid extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A Nano ID of the default shape: 21 characters of `A-Za-z0-9_-`.
9
+ *
10
+ * Specified by https://github.com/ai/nanoid.
11
+ */
12
+ @friendlyName("NanoID")
13
+ @format("nano-id")
14
+ @pattern("^[A-Za-z0-9_-]{21}$")
15
+ @extension("x-nxgt-scalar", "NanoID")
16
+ scalar nanoId extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A MongoDB ObjectId as text: 24 hexadecimal digits, in any case, kept as sent.
9
+ *
10
+ * Specified by https://www.mongodb.com/docs/manual/reference/method/ObjectId/.
11
+ */
12
+ @friendlyName("ObjectID")
13
+ @format("object-id")
14
+ @pattern("^[0-9a-fA-F]{24}$")
15
+ @extension("x-nxgt-scalar", "ObjectID")
16
+ scalar objectId extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A Semantic Versioning 2.0.0 version, as semver.org's own regular expression
9
+ * reads it: `1.2.3`, `1.0.0-rc.1+build.5`. No `v` prefix.
10
+ *
11
+ * Specified by https://semver.org/spec/v2.0.0.html.
12
+ */
13
+ @friendlyName("SemVer")
14
+ @format("sem-ver")
15
+ @pattern("^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*)?$")
16
+ @extension("x-nxgt-scalar", "SemVer")
17
+ scalar semVer extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A ULID: 26 characters of Crockford base32, the first 0 to 7 (128 bits), in any
9
+ * case, kept as sent.
10
+ *
11
+ * Specified by https://github.com/ulid/spec.
12
+ */
13
+ @friendlyName("ULID")
14
+ @format("ulid")
15
+ @pattern("^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$")
16
+ @extension("x-nxgt-scalar", "ULID")
17
+ scalar ulid extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A version 4 (random) UUID with the RFC variant, in any case, kept as sent.
9
+ *
10
+ * Specified by https://www.rfc-editor.org/rfc/rfc9562.
11
+ */
12
+ @friendlyName("UUIDv4")
13
+ @format("uuid")
14
+ @pattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$")
15
+ @extension("x-nxgt-scalar", "UUIDv4")
16
+ scalar uuidV4 extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A version 7 (time-ordered) UUID with the RFC variant, in any case, kept as sent.
9
+ *
10
+ * Specified by https://www.rfc-editor.org/rfc/rfc9562.
11
+ */
12
+ @friendlyName("UUIDv7")
13
+ @format("uuid")
14
+ @pattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$")
15
+ @extension("x-nxgt-scalar", "UUIDv7")
16
+ scalar uuidV7 extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ // The id @nxgt/drizzle's id() and actors() columns hold by default.
8
+ /**
9
+ * An RFC 9562 UUID, any version 1 to 8 with the RFC variant, or the nil or
10
+ * the max UUID, in any case, kept as sent: `0b8e5c1e-2f4a-4c3b-9d6e-7f8a9b0c1d2e`.
11
+ *
12
+ * Specified by https://www.rfc-editor.org/rfc/rfc9562.
13
+ */
14
+ @friendlyName("UUID")
15
+ @format("uuid")
16
+ @pattern("^(?:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|0{8}-0{4}-0{4}-0{4}-0{12}|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$")
17
+ @extension("x-nxgt-scalar", "UUID")
18
+ scalar uuid extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An XID: 20 characters of lowercase base32hex (`0-9`, `a-v`). 12 bytes leave 4
9
+ * bits unused, so the last character is `0` or `g`.
10
+ *
11
+ * Specified by https://github.com/rs/xid.
12
+ */
13
+ @friendlyName("XID")
14
+ @format("xid")
15
+ @pattern("^[0-9a-v]{19}[0g]$")
16
+ @extension("x-nxgt-scalar", "XID")
17
+ scalar xid extends string;
@@ -0,0 +1,13 @@
1
+ // The identifier scalars, one file each under ./identifier/.
2
+ import "./identifier/cuid2.tsp";
3
+ import "./identifier/guid.tsp";
4
+ import "./identifier/isbn.tsp";
5
+ import "./identifier/ksuid.tsp";
6
+ import "./identifier/nano-id.tsp";
7
+ import "./identifier/object-id.tsp";
8
+ import "./identifier/sem-ver.tsp";
9
+ import "./identifier/ulid.tsp";
10
+ import "./identifier/uuid.tsp";
11
+ import "./identifier/uuid-v4.tsp";
12
+ import "./identifier/uuid-v7.tsp";
13
+ import "./identifier/xid.tsp";
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An ISO 3166-1 alpha-2 country code, uppercase: `FR`, `US`. The list of
9
+ * assigned codes is not in the pattern: only the shape is.
10
+ *
11
+ * Specified by https://www.iso.org/iso-3166-country-codes.html.
12
+ */
13
+ @friendlyName("CountryCode")
14
+ @format("country-code")
15
+ @pattern("^[A-Z]{2}$")
16
+ @extension("x-nxgt-scalar", "CountryCode")
17
+ scalar countryCode extends string;